소스 검색

Add dolicloud images

Laurent Destailleur 12 년 전
부모
커밋
63ecd0ef41
100개의 변경된 파일28827개의 추가작업 그리고 6개의 파일을 삭제
  1. 0 4
      .cvsignore
  2. 1 2
      .gitignore
  3. 11 0
      .settings/.jsdtscope
  4. 3 0
      .settings/org.eclipse.core.resources.prefs
  5. 2 0
      .settings/org.eclipse.php.core.prefs
  6. 1 0
      .settings/org.eclipse.wst.jsdt.ui.superType.container
  7. 1 0
      .settings/org.eclipse.wst.jsdt.ui.superType.name
  8. 15 0
      .settings/org.eclipse.wst.validation.prefs
  9. 152 0
      dolicloudimages/dolibarr/config/DolibarrScript.groovy
  10. 31 0
      dolicloudimages/dolibarr/config/dolibarr.cfg
  11. 44 0
      dolicloudimages/dolibarr/config/dolibarr.sql
  12. 76 0
      dolicloudimages/dolibarr/config/vhostHttps-dolibarr.template
  13. 481 0
      dolicloudimages/dolibarr/src/COPYING
  14. 130 0
      dolicloudimages/dolibarr/src/COPYRIGHT
  15. 977 0
      dolicloudimages/dolibarr/src/ChangeLog
  16. 6 0
      dolicloudimages/dolibarr/src/INSTALL
  17. 139 0
      dolicloudimages/dolibarr/src/README
  18. 130 0
      dolicloudimages/dolibarr/src/README-FR
  19. 2 0
      dolicloudimages/dolibarr/src/documents/.htaccess
  20. BIN
      dolicloudimages/dolibarr/src/documents/doctemplates/invoices/template_invoice.odt
  21. BIN
      dolicloudimages/dolibarr/src/documents/doctemplates/orders/template_order.odt
  22. BIN
      dolicloudimages/dolibarr/src/documents/doctemplates/proposals/template_proposal.odt
  23. BIN
      dolicloudimages/dolibarr/src/documents/doctemplates/thirdparties/template_thirdparty.odt
  24. 2 0
      dolicloudimages/dolibarr/src/documents/install.lock
  25. 96 0
      dolicloudimages/dolibarr/src/htdocs/accountancy/class/accountancyaccount.class.php
  26. 93 0
      dolicloudimages/dolibarr/src/htdocs/accountancy/class/accountancysystem.class.php
  27. 1 0
      dolicloudimages/dolibarr/src/htdocs/accountancy/index.php
  28. 274 0
      dolicloudimages/dolibarr/src/htdocs/adherents/admin/adherent.php
  29. 214 0
      dolicloudimages/dolibarr/src/htdocs/adherents/admin/adherent_extrafields.php
  30. 175 0
      dolicloudimages/dolibarr/src/htdocs/adherents/admin/mailman.php
  31. 198 0
      dolicloudimages/dolibarr/src/htdocs/adherents/admin/public.php
  32. 154 0
      dolicloudimages/dolibarr/src/htdocs/adherents/admin/spip.php
  33. 166 0
      dolicloudimages/dolibarr/src/htdocs/adherents/agenda.php
  34. 1019 0
      dolicloudimages/dolibarr/src/htdocs/adherents/card_subscriptions.php
  35. 224 0
      dolicloudimages/dolibarr/src/htdocs/adherents/cartes/carte.php
  36. 1 0
      dolicloudimages/dolibarr/src/htdocs/adherents/cartes/index.php
  37. 2137 0
      dolicloudimages/dolibarr/src/htdocs/adherents/class/adherent.class.php
  38. 320 0
      dolicloudimages/dolibarr/src/htdocs/adherents/class/adherent_type.class.php
  39. 183 0
      dolicloudimages/dolibarr/src/htdocs/adherents/class/adherentstats.class.php
  40. 313 0
      dolicloudimages/dolibarr/src/htdocs/adherents/class/cotisation.class.php
  41. 233 0
      dolicloudimages/dolibarr/src/htdocs/adherents/cotisations.php
  42. 254 0
      dolicloudimages/dolibarr/src/htdocs/adherents/document.php
  43. 1543 0
      dolicloudimages/dolibarr/src/htdocs/adherents/fiche.php
  44. 395 0
      dolicloudimages/dolibarr/src/htdocs/adherents/fiche_subscription.php
  45. 91 0
      dolicloudimages/dolibarr/src/htdocs/adherents/htpasswd.php
  46. 433 0
      dolicloudimages/dolibarr/src/htdocs/adherents/index.php
  47. 65 0
      dolicloudimages/dolibarr/src/htdocs/adherents/info.php
  48. 83 0
      dolicloudimages/dolibarr/src/htdocs/adherents/info_subscription.php
  49. 244 0
      dolicloudimages/dolibarr/src/htdocs/adherents/ldap.php
  50. 370 0
      dolicloudimages/dolibarr/src/htdocs/adherents/liste.php
  51. 181 0
      dolicloudimages/dolibarr/src/htdocs/adherents/note.php
  52. 283 0
      dolicloudimages/dolibarr/src/htdocs/adherents/stats/geo.php
  53. 232 0
      dolicloudimages/dolibarr/src/htdocs/adherents/stats/index.php
  54. 642 0
      dolicloudimages/dolibarr/src/htdocs/adherents/type.php
  55. 172 0
      dolicloudimages/dolibarr/src/htdocs/admin/accounting.php
  56. 169 0
      dolicloudimages/dolibarr/src/htdocs/admin/agenda.php
  57. 193 0
      dolicloudimages/dolibarr/src/htdocs/admin/agenda_extsites.php
  58. 162 0
      dolicloudimages/dolibarr/src/htdocs/admin/agenda_xcal.php
  59. 337 0
      dolicloudimages/dolibarr/src/htdocs/admin/barcode.php
  60. 450 0
      dolicloudimages/dolibarr/src/htdocs/admin/boxes.php
  61. 101 0
      dolicloudimages/dolibarr/src/htdocs/admin/clicktodial.php
  62. 596 0
      dolicloudimages/dolibarr/src/htdocs/admin/commande.php
  63. 1005 0
      dolicloudimages/dolibarr/src/htdocs/admin/company.php
  64. 208 0
      dolicloudimages/dolibarr/src/htdocs/admin/compta.php
  65. 164 0
      dolicloudimages/dolibarr/src/htdocs/admin/confexped.php
  66. 283 0
      dolicloudimages/dolibarr/src/htdocs/admin/const.php
  67. 192 0
      dolicloudimages/dolibarr/src/htdocs/admin/contract.php
  68. 374 0
      dolicloudimages/dolibarr/src/htdocs/admin/delais.php
  69. 1080 0
      dolicloudimages/dolibarr/src/htdocs/admin/dict.php
  70. 284 0
      dolicloudimages/dolibarr/src/htdocs/admin/dons.php
  71. 126 0
      dolicloudimages/dolibarr/src/htdocs/admin/events.php
  72. 626 0
      dolicloudimages/dolibarr/src/htdocs/admin/expedition.php
  73. 327 0
      dolicloudimages/dolibarr/src/htdocs/admin/external_rss.php
  74. 783 0
      dolicloudimages/dolibarr/src/htdocs/admin/facture.php
  75. 170 0
      dolicloudimages/dolibarr/src/htdocs/admin/fckeditor.php
  76. 463 0
      dolicloudimages/dolibarr/src/htdocs/admin/fichinter.php
  77. 677 0
      dolicloudimages/dolibarr/src/htdocs/admin/fournisseur.php
  78. 155 0
      dolicloudimages/dolibarr/src/htdocs/admin/geoipmaxmind.php
  79. 408 0
      dolicloudimages/dolibarr/src/htdocs/admin/ihm.php
  80. 86 0
      dolicloudimages/dolibarr/src/htdocs/admin/index.php
  81. 330 0
      dolicloudimages/dolibarr/src/htdocs/admin/ldap.php
  82. 337 0
      dolicloudimages/dolibarr/src/htdocs/admin/ldap_contacts.php
  83. 261 0
      dolicloudimages/dolibarr/src/htdocs/admin/ldap_groups.php
  84. 444 0
      dolicloudimages/dolibarr/src/htdocs/admin/ldap_members.php
  85. 349 0
      dolicloudimages/dolibarr/src/htdocs/admin/ldap_users.php
  86. 307 0
      dolicloudimages/dolibarr/src/htdocs/admin/limits.php
  87. 486 0
      dolicloudimages/dolibarr/src/htdocs/admin/livraison.php
  88. 133 0
      dolicloudimages/dolibarr/src/htdocs/admin/mailing.php
  89. 770 0
      dolicloudimages/dolibarr/src/htdocs/admin/mails.php
  90. 279 0
      dolicloudimages/dolibarr/src/htdocs/admin/menus.php
  91. 440 0
      dolicloudimages/dolibarr/src/htdocs/admin/menus/edit.php
  92. 347 0
      dolicloudimages/dolibarr/src/htdocs/admin/menus/index.php
  93. 225 0
      dolicloudimages/dolibarr/src/htdocs/admin/menus/menu.js.php
  94. 144 0
      dolicloudimages/dolibarr/src/htdocs/admin/menus/other.php
  95. 493 0
      dolicloudimages/dolibarr/src/htdocs/admin/modules.php
  96. 125 0
      dolicloudimages/dolibarr/src/htdocs/admin/notification.php
  97. 91 0
      dolicloudimages/dolibarr/src/htdocs/admin/osc-languages.php
  98. 358 0
      dolicloudimages/dolibarr/src/htdocs/admin/pdf.php
  99. 221 0
      dolicloudimages/dolibarr/src/htdocs/admin/perms.php
  100. 275 0
      dolicloudimages/dolibarr/src/htdocs/admin/prelevement.php

+ 0 - 4
.cvsignore

@@ -1,4 +0,0 @@
-.cache
-.buildpath
-main.inc.php
-master.inc.php

+ 1 - 2
.gitignore

@@ -2,5 +2,4 @@
 .buildpath
 main.inc.php
 master.inc.php
-/.project
-/.settings
+/.project

+ 11 - 0
.settings/.jsdtscope

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="">
+		<attributes>
+			<attribute name="provider" value="org.eclipse.wst.jsdt.web.core.internal.project.ModuleSourcePathProvider"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>

+ 3 - 0
.settings/org.eclipse.core.resources.prefs

@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding//build/exe/dolimed/Languages=ISO-8859-1
+encoding//build/exe/dolimed/Languages/MyFrench.isl=ISO-8859-1

+ 2 - 0
.settings/org.eclipse.php.core.prefs

@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+include_path=0;/nltechno\u00052;/dolibarr

+ 1 - 0
.settings/org.eclipse.wst.jsdt.ui.superType.container

@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary

+ 1 - 0
.settings/org.eclipse.wst.jsdt.ui.superType.name

@@ -0,0 +1 @@
+Window

+ 15 - 0
.settings/org.eclipse.wst.validation.prefs

@@ -0,0 +1,15 @@
+DELEGATES_PREFERENCE=delegateValidatorList
+USER_BUILD_PREFERENCE=enabledBuildValidatorList
+USER_MANUAL_PREFERENCE=enabledManualValidatorList
+USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.303.v201202090300
+eclipse.preferences.version=1
+override=true
+suspend=false
+vals/org.eclipse.php.core.org.eclipse.php.core.PHPTaskValidator/groups=0107include01111contentType130org.eclipse.php.core.phpsourceT0107exclude0104file115dolicloudimagesF02
+vals/org.eclipse.php.ui.HTMLValidatorForPHP/groups=0107include01111contentType130org.eclipse.php.core.phpsourceT0107exclude0204file110build/htmlF0104file115dolicloudimagesF02
+vals/org.eclipse.wst.html.ui.HTMLValidator/groups=0107include06111contentType136org.eclipse.wst.html.core.htmlsourceT07fileext04htmlF07fileext05xhtmlF07fileext03htmF07fileext04htplF07fileext03wmlF0107exclude0504file116htdocs/includes/F0204file114htdocs/custom/F0204file110build/htmlF0204file116htdocs/dev/spec/F0204file115dolicloudimagesF02
+vals/org.eclipse.wst.jsdt.web.core.JsBatchValidator/groups=0107include01113projectNature134org.eclipse.wst.jsdt.core.jsNature0107include11007fileext04htmlF07fileext05xhtmlF07fileext03htmF07fileext04htplF07fileext03jspF07fileext03jsfF07fileext03jsvF07fileext04jtplF111contentType136org.eclipse.wst.html.core.htmlsourceT111contentType134org.eclipse.jst.jsp.core.jspsourceT0107exclude0104file115dolicloudimagesF02
+vals/org.phpsrc.eclipse.pti.tools.codesniffer.CodeSnifferValidatorForPHP/global=TF01
+vals/org.phpsrc.eclipse.pti.tools.phpdepend.PHPUnitAutomaticTestExecutionValidatorForPHP/global=TF01
+vals/org.phpsrc.eclipse.pti.tools.phpdepend.PHPUnitAutomaticTestExecutionValidatorForPHP/groups=0107include01111contentType130org.eclipse.php.core.phpsourceT0107exclude0104file115dolicloudimagesF02
+vf.version=3

+ 152 - 0
dolicloudimages/dolibarr/config/DolibarrScript.groovy

@@ -0,0 +1,152 @@
+package com.saasplex.rm.utils
+
+import com.saasplex.rm.*
+import com.saasplex.rm.adapters.*
+
+
+public class DolibarrScript extends ScriptContext {
+
+    def installerUrl
+    def dbScriptUrl
+    def cfgFileUrl
+    def applicationUniqueKey
+    def cfgFileName = "htdocs/conf/conf.php"
+    def appName = "dolibarr"
+
+    def install() {
+        installerUrl = variables["installerUrl"]
+        dbScriptUrl = variables["dbScriptUrl"]
+        cfgFileUrl = variables["cfgFileUrl"]
+        
+	applicationUniqueKey = randomString(32)
+	setVar("applicationUniqueKey", applicationUniqueKey)	
+        
+        def domainName = getVar("domainName")
+        if(!domainName) throw new Exception("Missing required parameter domainName")
+        
+        //get the servers
+        def mysql = new Mysql() //default constructor chooses a agent
+        def agent = mysql.agent
+        def apache = new Apache2(agent) // we wnat to have both things in the same box
+        def os = new Linux(agent)
+        def fs = new FileSystem(agent)
+        
+        //get a unique identifier and a server
+        String uid = randomString(15)
+        def db
+        def ip
+        def app
+        def appPath
+        
+        // Set the url of the resource
+        resource.description = "dolibarr"
+        resource.url = "https://" + domainName
+ 
+        ip = agent.getIp()
+        
+        // Building the DB
+        try {
+            db = new DataBase() //this represents a database with its users and its recipe for creating tables,etc
+            /**
+              * Truncating the database name if it exceeds 40 characters. 
+              * 
+              * MySQL has limitations for Database/Table name length to 65 
+              * bytes.
+              */
+             def databaseName = uid+'_'+appName
+             if (databaseName.length() > 40) {
+                 databaseName = databaseName.substring(0,40)
+             }
+             
+             db.setName(databaseName.replaceAll(/\W/, "_"))
+             db.setScript(dbScriptUrl)
+             def dbUsername = "ebw" + randomString(7)
+             def dbPassword = randomString(10)
+             db.addUser(dbUsername, dbPassword) //mysql username limited to 16 chars. will truncate and delete/create so careful
+             mysql.createDataBase(db)
+             
+             //set the variables needed for replacing values in the cfg template
+             readVars(db)
+
+             // Building the web app
+             try {
+                 def osUsername = "ebw" + randomString(7)
+                 setParameter("osUsername", osUsername)
+                 variables.put("osUsername", osUsername)
+                 
+                 def osPassword = randomString(10)
+                 setParameter("osPassword", osPassword)
+                 variables.put("osPassword", osPassword)
+                 
+                 def osGroupname = "${osUsername}Group"
+                 setParameter("osGroupname", osGroupname)
+                 variables.put("osGroupname", osGroupname)
+                 
+                 os.createGroup(osGroupname)
+                 os.createUser(osUsername, osPassword, osGroupname)
+
+                 appPath = "/home/jail/home/$osUsername/$uid"
+                 
+                 app = new PhpApp() // represents a web app to be deployed on a web server,subclass of WebApp
+                 app.server = apache //we asing the appserver so when reading vars the Server based variables will be there
+                 app.name = appName
+                 app.domains = [domainName]
+                 app.sourceUrl = installerUrl
+                 app.path = appPath
+                 app.logName = "osaas/dolibarr/$uid" 
+                 app.addConfigFile(cfgFileName, cfgFileUrl)
+                 app.setHttpMode(app.HTTPS_ONLY)
+                 //app.setHttpMode(app.HTTP_HTTPS)
+                 
+                 // set the variables needed for replacing values in the cfg template,
+                 //  and sets parameters associated with this resource
+                 readVars(app)
+                 
+                 app.variables = getVariables()
+                 
+                 try {
+                     apache.createWebApp(app)
+                     fs.chown(appPath, "$osUsername:$osGroupname")
+                     fs.chmod(appPath, '700')
+                     fs.chmod(appPath+'/htdocs/conf/conf.php', '400')
+                 } catch (e) {
+                     log.error("Create Web Failed. So rolling back")
+                     apache.removeApp(app)
+                     throw e
+                 }
+            } catch(e) {
+                    log.error("Rolling Back Unix user creation")
+                    os.deleteUser(getParameter("osUsername"))
+                    os.deleteGroup(getParameter("osGroupname"))
+                    throw e
+            }
+            
+        } catch(e) {
+                log.error("Rolling Back DB creation")
+                mysql.dropDataBase(db)
+                log.error("DB Rolled Back")
+                throw e
+        }
+    }
+
+    def uninstall() {
+        def server = getAgent(["ip" : getParameter("webServer")])
+        def apache2 = new Apache2(server)
+        def mysql = new Mysql(server)
+        def os = new Linux(server)
+        def domainName = getParameter("webAppDomain")
+        def app = new PhpApp()
+        app.name = appName
+        app.domains = [domainName]
+        app.path = getParameter("webAppPath")
+        app.setHttpMode(getParameter("webAppHttpMode"))
+        app.server = apache2
+        apache2.removeApp(app)
+        mysql.dropDataBase(getParameter("dbName"))
+        mysql.deleteUser(getParameter("dbUser"))
+        os.deleteUser(getParameter("osUsername"))
+        os.deleteGroup(getParameter("osGroupname"))
+        setStatus("uninstalled")
+    }
+
+}

+ 31 - 0
dolicloudimages/dolibarr/config/dolibarr.cfg

@@ -0,0 +1,31 @@
+<?php
+#
+# File generated by Dolibarr installer 3.1.1 on 2012-04-19 17:13:21
+#
+# Take a look at conf.php.example file for an example of conf.php file
+# and explanations for all possibles parameters.
+#
+$dolibarr_main_url_root='https://@webAppDomain@/';
+$dolibarr_main_document_root='@webAppPath@/htdocs';
+#$dolibarr_main_url_root_alt='https://@webAppDomain@/htdocs/custom';
+#$dolibarr_main_document_root_alt='@webAppPath@/htdocs/custom';
+$dolibarr_main_data_root='@webAppPath@/documents';
+$dolibarr_main_db_host='localhost';
+$dolibarr_main_db_port='3306';
+$dolibarr_main_db_name='@dbName@';
+$dolibarr_main_db_user='@dbUser@';
+$dolibarr_main_db_pass='@dbPassword@';
+$dolibarr_main_db_type='mysqli';
+$dolibarr_main_db_character_set='utf8';
+$dolibarr_main_db_collation='utf8_general_ci';
+$dolibarr_main_authentication='dolibarr';
+
+# Specific settings
+$dolibarr_main_prod='1';
+$dolibarr_nocsrfcheck='0';
+$dolibarr_main_force_https='0';
+$dolibarr_main_cookie_cryptkey='@applicationUniqueKey@';
+$dolibarr_mailing_limit_sendbyweb='50';
+
+$dolibarr_memcached_view_disable=1;
+?>

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 44 - 0
dolicloudimages/dolibarr/config/dolibarr.sql


+ 76 - 0
dolicloudimages/dolibarr/config/vhostHttps-dolibarr.template

@@ -0,0 +1,76 @@
+<VirtualHost *:443 *:80>
+        ServerName @webAppDomain@
+        ServerAdmin admin@eazybusiness.com
+        
+        ServerAlias @webAppAliases@
+        DocumentRoot @webAppPath@/htdocs
+
+        AssignUserID @osUsername@ @osGroupname@
+
+        #ErrorLog /var/log/apache2/@webAppLogName@Error.log
+
+        # Possible values include: debug, info, notice, warn, error, crit,
+        # alert, emerg.
+        LogLevel warn
+
+        #CustomLog /var/log/apache2/@webAppLogName@Access.log combined
+
+        ServerSignature On
+        
+        # Insert filter
+        SetOutputFilter DEFLATE
+
+        # Netscape 4.x has some problems...
+        BrowserMatch ^Mozilla/4 gzip-only-text/html
+
+        # Netscape 4.06-4.08 have some more problems
+        BrowserMatch ^Mozilla/4\.0[678] no-gzip
+
+        # MSIE masquerades as Netscape, but it is fine
+        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
+
+        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
+        # the above regex won't work. You can use the following
+        # workaround to get the desired effect:
+        # BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
+
+        # Don't compress images
+        SetEnvIfNoCase Request_URI \
+        \.(?:gif|jpe?g|png)$ no-gzip dont-vary
+
+        # Make sure proxies don't deliver the wrong content
+        #Header append Vary User-Agent env=!dont-vary
+
+        DeflateFilterNote Input instream
+        DeflateFilterNote Output outstream
+        DeflateFilterNote Ratio ratio
+
+        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
+        #CustomLog deflate_log deflate
+
+        #   SSL Engine Switch:
+        #   Enable/Disable SSL for this virtual host.
+        SSLEngine on
+
+        RewriteEngine   on
+        RewriteCond     %{SERVER_PORT} ^80$
+        RewriteRule     ^(.*)$ https://%{SERVER_NAME}$1 [L,R]
+
+
+        <FilesMatch "\.(cgi|shtml|phtml|php)$">
+                SSLOptions +StdEnvVars
+        </FilesMatch>
+        <Directory /usr/lib/cgi-bin>
+                SSLOptions +StdEnvVars
+        </Directory>
+
+        BrowserMatch ".*MSIE.*" \
+                nokeepalive ssl-unclean-shutdown \
+                downgrade-1.0 force-response-1.0
+
+
+
+</VirtualHost>
+
+
+

+ 481 - 0
dolicloudimages/dolibarr/src/COPYING

@@ -0,0 +1,481 @@
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+                       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+                            Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+                  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                            NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                     END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library 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
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!

+ 130 - 0
dolicloudimages/dolibarr/src/COPYRIGHT

@@ -0,0 +1,130 @@
+
+License
+-------
+
+Dolibarr is released under the terms of the GNU General Public License as 
+published by the Free Software Foundation; either version 2 of the License,
+or (at your option) any later version
+
+However it uses some external libraries under different licences. This is compatibility summary:
+
+Composant         Version  License                     Compatible GPL   Usage
+----------------------------------------------------------------------------
+PHP libraries:
+AdoDb-Date        0.21		Modified BSD License		Yes				Date convertion (not into rpm package)
+CKEditor		  3.6.2		GPL or LGPL 2.1 or MPL 1.1	Yes				Editor WYSIWYG
+FPDI              1.4.1		Apache Software License 2.0	?				PDF templates management
+GeoIP			  2004      LGPL 2.1                    Yes             Sample code to make geoip convert (not into deb package)
+NuSoap            0.9.5		LGPL 2.1					Yes				Library to develop SOAP Web services (not into rpm and deb package)
+OdtPHP            1.0.1		GPL 2.0						Yes				Library to build/edit ODT files
+PHPExcel		  1.7.6		LGPL 2.1					Yes				Read/Write XLS files, read ODS files
+TCPDF             5.9.098	LGPL 3.0					Yes				PDF generation
+
+JS libraries:
+jQuery            1.7.2		GPL and MIT Licence			Yes				JS library
+jQuery UI         1.8.20	GPL and MIT Licence			Yes				JS library plugin UI
+jQuery Colorpicker 1.1	    MIT Licence					Yes				JS library for color picker for a defined list of colors
+jQuery DataTable  1.8.1     BSD							Yes				JS library for tables output
+jQuery Flot       0.7		MIT Licence					Yes				JS library to build graph
+jQuery FileUpload 5.0.3		GPL and MIT Licence			Yes				JS library to upload files
+jQuery JCrop      0.9.8		GPL and MIT Licence			Yes				JS library plugin Crop (to crop images)
+jQuery jeditable  1.7.1		GPL and MIT Licence			Yes				JS library plugin jeditable (to edit in place)
+jQuery jNotify	  1.1.00	Apache Software License 2.0	?				JS library plugin jNotify (to use ajax popups)
+jQuery jPicker	  1.1.00	GPL and MIT	Licence			Yes				JS library for color picker with not defined list of colors
+jQuery Layout     1.3.0		GPL and MIT Licence			Yes				JS library plugin Layout (RC-29.15)
+jQuery TableDnD   0.5		GPL and MIT Licence			Yes				JS library plugin TableDnD (to reorder table rows)
+jQuery Mobile	  1.0rc2	GPL and MIT Licence			Yes				JS library for smartphone (not used)
+jQuery Tiptip     1.3		GPL and MIT Licence			Yes				JS library for tooltips
+JSGantt           1.2		BSD Licence					Yes				JS library (to build Gantt reports)
+
+
+For licenses compatibility informations:
+http://www.fsf.org/licensing/licenses/index_html
+
+
+Copyright
+---------
+
+Copyright (C) 2012
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin	<regis@dolibarr.fr>
+- Juanjo Menent <jmenent@2byte.es>
+- Philippe Grand <philippe.grand@atoo-net.com>
+- Jean Heimburger <jean@tiaris.info>
+- Marcos García <marcosgdf@gmail.com>
+
+Copyright (C) 2011
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin	<regis@dolibarr.fr>
+- Juanjo Menent <jmenent@2byte.es>
+- Philippe Grand <philippe.grand@atoo-net.com>
+- Jean Heimburger <jean@tiaris.info>
+
+Copyright (C) 2010
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin <regis@dolibarr.fr>
+- Juanjo Menent <jmenent@2byte.es>
+- r2gnl
+- meos
+
+Copyright (C) 2009
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin <regis@dolibarr.fr>
+- Juanjo Menent <jmenent@2byte.es>
+
+Copyright (C) 2008
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin <regis@dolibarr.fr>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+
+Copyright (C) 2007
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Regis Houssin <regis@dolibarr.fr>
+- Auguria SARL <info@auguria.org>
+- Jean Heimburger <jean@tiaris.info>
+
+Copyright (C) 2006
+- Auguria SARL <info@auguria.org>
+- Marc Barilley/Ocebo <marc@ocebo.com>
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+- Regis Houssin <regis@dolibarr.fr>
+- Andre Cianfarani <acianfa@free.fr>
+- Yannick Warnier <ywarnier@beeznest.org>
+- Jean Heimburger <jean@tiaris.info>
+
+Copyright (C) 2005
+- Brice Davoleau <brice.davoleau@gmail.com>
+- Laurent Destailleur <eldy@users.sourceforge.net>
+- Benoit Mortier <benoit.mortier@opensides.be>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+- Eric Seigne <erics@rycks.com>
+- Matthieu Valleton <mv@seeschloss.org>
+- Regis Houssin <regis@dolibarr.fr>
+
+Copyright (C) 2004
+- Laurent Destailleur  <eldy@users.sourceforge.net>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+- Eric Seigne <erics@rycks.com>
+- Benoit Mortier <benoit.mortier@opensides.be>
+- Christophe Combelles  <ccomb@free.fr>
+
+Copyright (C) 2003
+- Jean-Louis Bergamo <jlb@j1b.org>
+- Xavier Dutoit <doli@sydesy.com>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+- Emmanuel Raviart <eraviart@entrouvert.com>
+- Eric Seigne <erics@rycks.com>
+
+Copyright (C) 2002
+- Jean-Louis Bergamo <jlb@j1b.org>
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+
+Copyright (C) 2001
+- Rodolphe Quiedeville <rodolphe@quiedeville.org>
+
+
+
+
+

+ 977 - 0
dolicloudimages/dolibarr/src/ChangeLog

@@ -0,0 +1,977 @@
+--------------------------------------------------------------
+English Dolibarr ChangeLog
+--------------------------------------------------------------
+
+
+***** ChangeLog for 3.2.2 compared to 3.2.1 *****
+
+- Fix: Modify spanish VAT to new rates.
+- Fix: Add error message when creating already existing product.
+- Fix: Edition of percentage of an event.
+- Fix: Minor look fix for theme bureau2crea.
+- Fix: Start and end date not saved at project creation
+- Fix: Default vat is zero for customer invoices if company does not use vat
+- Fix: Localtaxes unit prices precision
+
+
+
+***** ChangeLog for 3.2.1 compared to 3.2.0 *****
+
+- Fix: Edit of projects.
+- Fix: Activation of modules does not fails if directory install was removed.
+- Fix: [ bug #444 ] Regression on auto-closing for proposals and orders.
+- Fix: Update translations (catalan, french, spanish, brazilian).
+- Fix: [ bug #445 ] Hex escaping in descriptions.
+- Fix: error when validating shipment for non predefined products with a
+  selected warehouse.
+- Fix: Bad local taxes if price base type is TTC for spanish local taxes.
+- Fix: Phone not saved when using web service.
+- Fix: [ bug #464 ] Payment form should allow to add transmitter for bank transfers.
+- Fix: Allows to use a comma decimal separator in supplier invoices payments.
+- Fix: Translation for tr_TR, es_ES, pt_BR.
+- Fix: Products with no prices not visible.
+- Fix: Access to product card created with very old version of Dolibarr.
+- Fix: Delete temporary files after validating an invoice.
+- Fix: preview of supplier order and invoice template.
+- Fix: [ bug #485 ] Configurated amount for public auto-subscription form is not taken into account
+- Fix: Average amount graphs weren't comparing the previous year stats
+- Fix: Closed project didn't show the new status unless the page was refreshed
+- Fix: Files were not being uploaded to a project's task
+- Fix: [ bug #503 ] Unable to delete linked file to a deposit
+- Fix: [ bug #501 ] Error while trying to modify an user
+- Fix: [ bug #506 ] Can't set percentage of a started event
+- Fix: Bad assignation of const for pdf delivery module name
+
+
+
+***** ChangeLog for 3.2.0 compared to 3.1.3 *****
+
+WARNING: PHP lower than 5.x are no more supported.
+WARNING: Because of a major datastructure change onto supplier prices tables, be aware
+to make a backup of your database before making upgrade.
+
+For users:
+- New: Each user can remove/add its own boxes.
+- New: Add signature at end of predefined email text.
+- New: Can use personalized fields of products/services.
+- New: Can attach files on social contributions.
+- New: Show payments terms and conditions onto muscadet template.
+- New: Can open back a closed commercial proposal.
+- New: show thirdparty barcode on main tab.
+- New: Can input note (private and public) during note and expenses creation.
+- New: Print ticket show invoice ref into POS module.
+- New: Can edit customer discounts from invoice create and edit card.
+- New: task #11243: Show quantity into stocks for each sub-products into the sub-product tab.
+- New: task #10500: Option to choose if professional id are unique.
+- New: Add hidden option FOURN_PRODUCT_AVAILABILITY.
+- New: task #11123: Add best supplier price.
+- New: Enhancement in styles.
+- New: Can conciliate several lines in one operation.
+- New: task #11289 : Modify third party accountancy code generator aquarium.
+- New: task #10606 : more comprehensive message error.
+- New: task #11278 : Option into point of sale module to add services in list.
+- New: task #11261 : Add an entry into menu called "New shipment".
+- New: [ task #187 ] Gerer les evenement recurrents dans les imports ical
+- New: Make option MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT available by default.
+- New: Can build PDF in USLetter format or canada format (change paper size).
+- New: Can export into Excel 2007 format.
+- New: Add hidden option CASHDESK_FORCE_STOCK_ON_BILL
+- New: Can search on part of barcode into POS module.
+- New: Cheques into cheques receipts are ordered by operation date.
+- New: Add hidden option MAIN_DISABLE_PDF_AUTOUPDATE to avoid generating pdf each time data change.
+- New: Add hidden option PROJECT_HIDE_UNSELECTABLES to hide project you can't select into combo list.
+- New: Add option INVOICE_POSITIVE_CREDIT_NOTE.
+- New: Support zip/town autocompletion into warehouses.
+- New: Add box for last expired services.
+- New: Reduce seriously size of packages.
+- New: Can define country code for import.
+- New: When invoice was generated from order, order date is visible on PDF, after order ref.
+- New: [ task #181 ] Hide password of click2dial in user card
+- New: Chart are faster to build
+- New: Value of data into charts are visible on mouse hover.
+- New: Import wizard can import contacts.
+- New: Import wizard can import personalized fields.
+- New: Personalized fields support int type.
+- New: Install process is now two times faster.
+- New: Can sort files into backup tool.
+- New: Default output charset are utf8 into backup tool.
+- New: Add brazilian states.
+- New: Increase usability of module project.
+- New: [ task #285 ] Add search filter on project in tasks list.
+- New: Automatic list of documents in ECM module is ok for customers,
+       suppliers invoice, orders, customers orders, proposals and social contributions.
+- New: All professional id can contains up to 128 chars instead of 32. 
+- New: [ task #176 ] Allow to use ODT templates for proposals and orders like it's done for invoices
+- New: Add hidden option MAIN_ADD_PDF_BACKGROUND to add a PDF as background of invoice/order generated PDF.
+- New: Can convert a product/service into service/product.
+- New: Show delivery date into proposal template azur. 
+- New: Support tags into header and footer into ODT templates.
+- Fix: Can use POS module with several concurrent users.
+- Fix: Installer don't fails with Mysql version that added a ssl_cypher field.
+- Fix: Sanitize input parameters.
+- Fix: [ bug #368 ] Product list
+- Fix: [ bug #370 ] Filter in accountancy -> suppliers_bills
+- Fix: [ bug #399 ] Bad calculation of local taxes in update line products
+- Fix: [ bug #427 ] Bad links to wiki help in certains menus
+
+For developers:
+- New: Can add a left menu into an existing top menu or left menu.
+- New: Add webservice to get or create a product or service.
+- New: Add webservice to get a user.
+- New: Add more "hooks" (like hooks to change way of showing/editing lines into dictionnaries).
+- New: Log module outputs can be setup with "or" rule (not only "xor").
+- New: Add FirePHP output for logging module.
+- New: Add trigger ACTION_DELETE and ACTION_MODIFY.
+- New: Trigger now have a priority to define sort execution order.
+- New: Can define different requests according to database type into migration files.
+- New: Add "canvas" feature to overwrite page of thirdparty, contact, product with yours.
+- New: Removed artichow deprecated libraries.
+- New: A page can force reload of css style sheet
+- New: A module can add import description for import wizard, even for tables with foreign keys.
+- New: Can add tabs on statistics views.
+- New: Add CSS id/class into public payment pages.
+- Qual: Add a lot of more PHPUnit tests.
+- Qual: Data structure for supplier prices is simpler.
+- Qual: Removed no more used external libraries.
+- Qual: Cleaned a lot of dead code.
+- Qual: More OOP (usage of "abstract", "static", ...), uniformize constructors.
+- Qual: Fix a lot of checkstyle warnings.
+- Qual: task #216 : Move /lib into /core/lib directory
+- Qual: task #217 : Move core files into core directory (login, menus, triggers, boxes, modules)
+WARNING: To reduce technic debt, all functions dolibarr_xxx were renamed int dol_xxx.
+
+
+
+***** ChangeLog for 3.1.3 compared to 3.1.2 *****
+
+Fix: PgSQL - property must be set if success
+Fix: Provide a solution for backup when mysqldump is not available
+Fix: Bug #460 - Wrong entity assignment when creating a warehouse
+Fix: bug #405 - Late icon always displayed on comm/propal.php
+
+
+
+***** ChangeLog for 3.1.2 compared to 3.1.1 *****
+
+- Fix: Can clone a proposal
+- Fix: Add member ID in substitution method
+- Fix: Duplicate end tag and missing form parts
+- Fix: Support companies with no prof id.
+- Fix: Sanitize data
+- Fix: Bug #318
+- Fix: Bug #369
+- Fix: More bugs
+
+
+
+***** ChangeLog for 3.1.1 compared to 3.1.0 *****
+
+- New: Add option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS. With this option added, 
+       credit notes are not removed from total amount of invoice but are just 
+       payments used to reducs remain to pay.
+- New: Added hidden option MAIN_FIX_FOR_BUGGED_MTA to fix bugged MTA.       
+- Fix: Removed warnings during install.
+- Fix: State into address of paypal payments were lost.
+- Fix: Currency into paypal payments were always euros.
+- Fix: Removed Bare LF from emails sent with smtps method.
+- Fix: Can show report on selected period.
+- Fix: product removed from list after deleted into order.
+- Fix: [bug #270] PostgreSQL backend try to connect throught TCP socket for 
+- Fix: price was not without tax when using multiprice into POS module.
+- Fix: Can delete bank account.
+- Fix: [ bug #277 ] Year dropdown in table header of supplier invoices.
+- Fix: Some other very minor fixes.
+
+
+***** ChangeLog for 3.1 compared to 3.0 *****
+
+WARNING: IE6 browser is no more supported in this version.
+For users:
+- New: War against number of clicks:
+     - When adding a free bank transaction, form to add next one is still
+       visible (save one click).
+     - task #10969 : Add checkbox to close automatically invoice if
+       payment is complete (save 3 clicks).
+     - Reduce a step into supplier order workflow to save time. If user
+       has permission to approve, order is approved when order is validated.
+       (Save 2 clicks).
+     - In commercial main menu, left menu are already opened. This save one click
+       to open a proposal or order.
+     - Can add a discount for third party, during invoice edition (and we 
+       saved clicks again).
+     - When creating a contract, sales representative are preset to user. This save
+       4 clicks.
+     - Can edit several fields in bank transaction line page into one update.
+     - Creation of contacts from third party page go back to third party.
+     - Preselect model if there is only one. This save 2 clicks. 
+     - Can remove a project if project has tasks. No need to delete task one by one.
+- New: Enhance donation module. Add a status "canceled".
+- New: Add filters on all statistics report pages.
+- New: If a service contains subproducts, subpoducts are decrease when service
+       is decrease.
+- New: Add status for third parties to disable a third party.
+- New: Can send interventions cards by email.
+- New: Increase list of available notifications into module Notifications.
+- New: Add option MAIN_FIRST_TO_UPPER to force upper case of first 
+       letters for names and firstname.
+- New: Can filter of payment type in bank transaction list.
+- New: Status of users is visible into user list.
+- New: Support BSB code for bank account in Australia.
+- New: Can set date of payment for autocreate invoice/payment when 
+       creating a foundation subscription.
+- New: Can edit note of payment.
+- New: Option to make login not mandatory in member module.
+- New: Add box for last members for foundation module.
+- New: A specialized menu can now be used when using smartphones.
+- New: Can add information on current user on ODT generation.
+- New: Prefix on third party is not used by default. Hidden option
+       SOCIETE_USEPREFIX can restore old feature.
+- New: Standing orders module use bank account from banks module.
+- New: Ask password when creating a user from a contact.
+- New: task #10577: Use a numbering module for shipment and contract.
+- New: Can create manually order from proposal.
+- New: Add a first workflow module to create automatic action on some
+       events (create order on proposal closing).
+- New: Use autocompletion on invoice select when creating replacement 
+       or credit note invoice.
+- New: task #10885: Add a week view for calendar.
+- New: task #11018: Add a status "not applicable" on events.
+- New: Add subscriptions/country/region/town statistics for member module.
+- New: Can define a proxy for external web access.
+- New: task #11003: checkbox on checks for deposit.
+- New: Add status into export. Add third party default language into export.
+- New: Can filter on date and bank account when building check receipts.
+- New: task #10958 : Add link to cheque receipts into bank transaction 
+       line if exists
+- New: Can import external ical url into dolibarr agenda view.
+- New: Can add a logo on third parties card.
+- New: task #11194 : Can delete uploaded photos 
+- New: task #9744 : Add the barcode to select products on Point of Sale module
+- New: Subscription/Unsubscription to mailman mailing-list can be done on 
+       validate/resiliate in foundation module.
+- New: Can use extrafields on third parties.
+- New: Add chart to report counts by status on element home area pages.
+- New: Look: Usage of Jquery Notify to show result or error messages on action.
+- New: Look: Minor enhancements into agenda view.
+- New: Look: Nicer tooltips with transparency and shadow.
+- New: task #11004: Create invoice from intervention.
+- New: task #10501: Can use point of sale with different bank accounts.
+- Fix: Better Postgresql compatibility.
+- Fix: Numbering module for invoices use same number for invoice 
+       and credit note if mask is same.
+- Fix: Debug and clean withdraw module.
+- Fix: Allow access permission for point of sale module.
+- Fix: Permissions issues with suppliers.
+- Fix: Admin dict data is showing with active language 
+
+For developers:
+- New: External modules can add tabs on agenda views.
+- New: External modules can also remove default tabs.
+- New: External modules can force skin directory so force their own skins.
+- New: External modules can add their own menu manager.
+- New: External modules can force menu manager.
+- New: External modules can overwrite all default language files by
+       forcing priority on langs directories on its own lang directory.
+- New: External modules can show export list with an "enabled" condition.
+- New: Support a backtopage parameter on contact creation page.
+- New: Add id on div to show logo.
+- New: Install wizard can activate a module at end of install.
+- New: Dictionnary setup works with very large external dictionnaries (Add 
+       page navigation).
+- New: Add api to draw graphics with javascript (using Jquery Flot).
+- New: Can add user login into menu urls added by modules.
+
+For translators:
+- New: Add fa_IR language.
+- Fix: Move language ar_AR to ar_SA, sv_SV to sv_SE and da_Da to da_DK.
+
+
+
+***** ChangeLog for 3.0 compared to 2.9 *****
+
+For users:
+- New: Can edit date of cheque receipts.
+- New: Add Sales journal and Purchase journal report.
+- New: Can create supplier invoice from supplier order.
+- New: Support login by openid
+- New: Support "full day" event in calendar module.
+- New: Add a weather on dashboard.
+- New: Add a Paypal module.
+- New: Can choose third party to use in point of sale module during logon.
+- New: A lot of enhancements into ECM module:
+       Directories can contains special characters,
+       Speed enhancements,
+       Directories can be created outside of Dolibarr, refresh button will 
+       update database,
+       Can rename a file.
+- New: Reordering lines in invoice, orders, commercial proposal is faster (use Ajax
+       technology).      
+- New: Can import members using assistant.
+- New: Can exclude deposit, replacement or credit notes in script rebuild_merge_pdf.
+- New: task #10473 : Option MAIN_PROFIDx_IN_ADDRESS must no more be hidden.
+- New: Can generate business card for on particular member.
+- New: Task #10553 : Can attach files on members card.
+- New: Can filter on payment type and bank account in payment lists.
+- New: When sending supplier orders by mail, a text is predefined.
+- New: Upgrade process works with Postgresql.
+- New: Task #10538: Add filter on expiration date of subscription for
+       foundation module email selector.
+- New: Task #9643: Add 2 status (tosell/tobuy) on products instead of only
+       1 status for both selling and buying.       
+- New: Can input payment conditions on several lines.
+- New: Add hidden option MAIN_LOGOUT_GOTO_URL to set the exit url after
+       a logout.
+- New: For germany, we invert order of address.
+- New: Add hidden option MAIN_SERVICES_ARE_ECOMMERCE_200238EC.
+- New: Support NPR in customer product prices.
+- New: Add more volume units (ounce, gallon, inch, feet, ...)
+- New: Delivery date accepts hours and minutes.
+- New: Can add a comment on stock dispatching to be save into stock movements.
+- New: Can filter product list with too low stocks.
+- New: Add option to send all emails sent to a bulk carbon copy.
+- New: Preview of emails sent by member module is shown.
+- New: task #10100 : Add button to create invoice from a subscription
+- New: Reorganize tabs on third parties.
+- New: Option MAIN_INVERT_SENDER_RECIPIENT is available in einstein pdf template.
+- New: Easier way to define url for clicktodial module.
+- New: Add a fckeditor test area in fckeditor module setup.
+- New: Add property "Event on full day" on agenda
+- New: Enhancement and better compatibility (google, thunderbird) for agenda export.
+- New: Can use image editor on user photo.
+- New: Task #10796: Add Spain ProfId1 Verification
+- New: Page "supplier summary" is now available.
+- New: Task #10611: Add option to choose order of field in bank account info on PDF
+- New: If a transaction was reconciliated and should not, there was no way to reverse error.
+- New: Ubuntu package now works also on debian.
+- Perf: Avoid reading database to determine country code after each
+        page call.
+- Fix: Special chars are now supported in ECM module for filename (not yet for
+       directories).
+- Fix: Better Postgresql compatibility.
+- Fix: Box order is saved when moved.
+- Fix: Database name can contains "-" characters.
+- Fix: In coloring negative amounts.
+- Fix: Date input use date format of user and not dd/mm/yyyy format.
+- Fix: Fixed a very old bug making file attachment fails with some emails 
+       readers when using "mail php function".
+- Fix: When cloning commercial proposal, due date is creation date + delay
+       by default.
+- Fix: Can edit ordering methods.
+
+For translators:
+- New: Update and complete slovenian language sl_SL.
+- New: Add full manually translated files for de_AT en de_DE (thanks to eCleaner.at).
+- New: Create the language ja_JP.
+- New: Add el_GR language.
+
+For developers:
+- New: Add jquery by default.
+- New: Removed PWC libraries.
+- New: Removed Scriptaculous libraries.
+- New: Removed Prototype libraries.
+- New: Add first Selenium GUI tests.
+- New: Enhance a lot of internal function to build external modules
+       more easily.
+- New: Add a user field ref_ext in object tables to allow external
+       systems to store their id and make self-developed synchronizing
+       functions easier to build.        
+- New: Local user timezone is saved into session (not used yet).
+- New: Works with Mysql 5.5.
+- Qual: Menu system code is simpler.
+- Qual: Mutualize some duplicate code.
+- Qual: Renamed some fields into database to be more internationnal.
+- Qual: Removed deprecated code.
+
+
+***** ChangeLog for 2.9 compared to 2.8 *****
+
+For users:
+- New: POS module allow to choose which warehouse to use.
+- New: Support "Department/State" field on company setup, contact, 
+       bank account and members card.
+- New: Can reopen a refused/canceled supplier order.
+- New: Add Gant diagramm on project module.
+- New: Add a new mode for automatic stock increase: Can be increased
+       on dispatching of products from a supplier order receipt.
+- New: Can set a past delay to limit calendar export.
+- New: Can attach files on emailing campaigns.
+- New: Add statistics on trips and expenses module.
+- New: Can reopen a closed customer order.
+- New: Add module externalsite to add a web site/tools inside 
+       menu and a Dolibarr frame.
+- New: Can link trips and fees to a project.
+- New: Add civility title in foundation module.
+- New: Can set accountancy code for product (buy and sell).
+- New: Can filter third parties lists on categories.
+- New: Can filter products and services lists on categories.
+- New: task #10202 : Support categories for members.
+- New: Can build documents for third parties (Using ODT templates, need PHP 5.2+). 
+- New: Support new products properties: length and area.
+- New: Add the "payment due before" field in invoice exports.
+- New: Add feature to resize or crop image files (for products photos)
+- New: task #10113 : Show list of emailing on clicking on "number of mass emailing received"
+- New: Add default language for third parties and use it when multilang is enabled
+       to define default language for document generation.
+- New: Can reopen a closed supplier invoice.
+- New: Move permission "see hidden categories" into "see hidden products/services".
+- New: Can delete several files at once in FTP module.
+- New: Add box "last contracts".
+- New: Works even if Web hosting provider has disabled PHP "glob" function.
+- New: Can now send supplier orders by email.
+- New: task #10076 : Show content of message in notification module.
+- New: Bank name is shown on invoice.
+- New: IBAN value is called IFSC if country is India.
+- New: Add option to choose to show firstname then name or name then firstname on PDF.
+- New: Add company in fields exported by export of members tool.
+- New: Reorganise bank menus.
+- New: Bookmarks can be sorted on a particular order.
+- New: Support spanish RE and IRPF taxes on invoices.
+- New: Module category offers categories for foundation module.
+- New: Can filter on category on third parties, products and members listings.
+- New: A flag is visible before country labels.
+- New: When activating a new module, permissions for admin user are set. This save
+       time when configuring Dolibarr.
+- New: Dolibarr 2.9 is faster than 2.8.
+- New: A lot of more predefined VAT values, states, regions for 
+       miscelaneous contries.
+- New: Enhance skin engine to make themes easier.
+- New: Add images into menu "eldy".
+- New: Auguria theme is now more modern.
+- New: Update tools refers to www.dolibarr.org but also www.dolistore.com web site.
+- New: Postgresql experimental support seems to work completely. 
+- New: Changes in Dolibarr core to allow to use cache servers (see Memcached module on
+       dolistore.com).
+- New: Default choice for interactive confirm box is yes by default, and no only for
+       delete actions. This reduce number of clicks required to validate actions and 
+       is still safe to dangerous actions.
+- Fix: Durations are correctly shown for languages using PM/AM dates.
+- Fix: A lot of fixes in Point of Sale module.
+- Fix: Debug experimental module widthrawal.
+- Fix: Format number was wrong for ar_AR language.
+- Fix: Can change password if user has only permission "change password".
+- Fix: Project PDF document shows all tasks.
+- Fix: bug #29278 : SMTP fails with IP instead of hostname.
+- Fix: Default language on login page was wrong.
+- Fix: Complete support of euros sign (even in PDF).
+- Fix: Bad setup of phpMyAdmin for DoliWamp installer.
+- Fix: Tracking number should be available on sending sheets.
+- Fix: Stock value is not reset when product is transfered into other warehouse. 
+- Fix: A lot of not tracked bugs fixed.
+- Fix: Some fixes in barcode management.
+- Fix: Access to phpMyAdmin is now ok on new DoliWamp installation.
+
+For translators:
+- Fix: Major update of italian translation (it_IT).
+- Fix: A lot of translation fixes in all languages.
+- New: Added translations (sl_SL, is_IS).
+- New: Add translations for the DoliWamp installer.
+
+For developers:
+- More comments in code.
+- Uniformize some code. 
+- All arrays "lignes" were renamed into "lines".
+- Delete all useless pre.inc.php files (this also increase speed).
+- Fix W3C errors in page forging.
+- Qual: Mutualize code of menu managers.
+- Better isolation of modules files and dolibarr core files. 
+- Task #8682 : Remove functions unix_timestamp.
+- The makepack tool now make pack with UID 500.
+- More css class and div to output menu to allow more skins.
+- Generated documentation can be build from Eclipse using Doxygen plugin.
+- Snapshot is provided with PHPunit tests.
+
+WARNING: 
+- A lot of class files (*.class.php) has moved into subdirectories. So If you use
+  or develop non official modules that includes Dolibarr classes, you will have to rename
+  path to thoose classes into the include function.
+- Also, parameters of the "fetch()" method for class "User" has changed to reflect
+  other fetch methods.   
+- If you build a personalised themes, you must rename the style sheet into style.css.php.   
+- This version is also the last one to support PHP 4.*, Mysql 3.1, IE6.
+  Dolibarr 3.* will be supported with PHP 5+ and MySql 4.1+ only.
+
+
+***** ChangeLog for 2.8.1 compared to 2.8 *****
+For users:
+- Fix: Works on database with _ in name.
+- Fix: Broken feature in trips and expense module.
+- Fix: Can use $ in database and login/pass values.
+- Fix: No error on upgrade if there is orphelins tasks.
+- Fix: Failed to login when user agent string was longer than 128.
+- Fix: bug #29526 : Numérotation Proposition Incorrecte après duplication
+
+
+***** ChangeLog for 2.8 compared to 2.7 *****
+
+For users:
+- New: Support note on trips module
+- New: Can link contacts to projects
+- New: Can removed attached file on email form if attachment was wrong.
+- New: Add option to show your logo on top of left menu.
+- New: task #9935: Can edit accountancy code.
+- New: Add an option to make users email required.
+- New: Module notification can send email on order or proposal validation.
+- New: Can use any command line antivirus on file upload.
+- New: A customer can also be a prospect.
+- New: task #9802 : Can link an action to a project and use project to 
+       filter agenda.
+- New: Project can be set on contract creation.
+- New: Initial sold can be conciliated on bank module.
+- New: Add a default errors-to email for emailing module.
+- New: Can filter on user on stock movement list.
+- New: When creating a third party from a member, it is set as a new
+       customer.
+- New: Can use {tttt} in numbering mask setup. It will be replaced
+       with third party type.
+- New: VAT number is stored in one field. This is more "international".
+- New: task #9782 : Add possibility to delete a warehouse.
+- New: task #9640 : Add label for stock movements.
+- New: task #9916 : Add FREE text for interventions card.
+- New: Can define the new product ref when cloning.
+- New: Project module support status of project and end date.
+- New: Provide a ubuntu package.
+- New: Add link to check a SIREN for french users.
+- New: Add link "now" to fill date when creating invoices.
+- Fix: Import module works even if prefix is empty in source file.
+- Fix: bug #28055 : Unable to modify the date of a cloned command.
+- Fix: bug #27891.
+- Fix: Change of numbering module was not effective.
+- Fix: Change error management when adding already used supplier ref
+       for a product.
+- Fix: Running sending-email.php
+- Fix: Warning should not appears for invoice closed
+- Fix: Import for companies works even with prefix empty.
+- Fix: bug #28895 : Création d'utilisateur impossible.
+- Fix: Can change password if has only permission change password.
+
+For developers:
+- Qual: Reorganize /dev directory.
+- Qual: Change the way items are linked together.
+- Qual: The login page now use a template in /core/template/login.tpl.php.
+- New: Modules can add their own tab on projects cards.
+- New: Add management of triger FICHEINTER_VALIDATE
+
+
+***** ChangeLog for 2.7.1 compared to 2.7 *****
+
+For users:
+- Fix: Bad decimal management for it_IT and fr_BE languages.
+- Fix: A third party created from a member is created as a 
+       customer.
+- Fix: Change of numbering module was not effective.
+- Fix: Report of balance missing supplier invoices.
+- Fix: Running sendmaing-email.php script.
+- Fix: Detection of country for IBAN management.
+- Fix: Update member photo.
+
+
+***** ChangeLog for 2.7 compared to 2.6 *****
+
+For users:
+- New: Add a print icon to show a page to print without menus.
+- New: Can add a free text on bank cheque receipts.
+- New: Price level can be defined also for prospects.
+- New: Add a help and support center.
+- New: Can export commercial proposals.
+- New: Can use a cache for xcal exports.
+- New: Option for faster confirmation process with one ajax popup.
+- New: Complete theme bluelagoon and rodolphe
+- New: Can select third parties emails in emailing module for all
+       third parties with expired contract's lines.
+- New: Can add a field errors-to in emailing.
+- New: Can use inline images in emails.
+- New: Add predefined invoices (can be use for repeated invoices).
+- New: Add a confirmation when cloning products.
+- New: Add stock in product lists.
+- New: Can filter list of stock movement on date or product.
+- New: Added a link from product list to their stock movements.
+- New: Several speed enhancements after using the Google Page speed 
+  plugin for FireBug.
+- New: Add a confirmation on dangerous admin purge feature.
+- New: Add navigation on donation sheets.
+- New: Added estimated value for stocks.
+- New: Added module Gravatar to found photo of users or members
+       from their email on gravatar.com.
+- New: Include Dolibarr version in suggested dump filename.
+- New: Enhancement in project module.
+- New: Add log tab on emailing module.
+- New: Minor enhancements in look themes.
+- New: Add option to hide help in menu.
+- New: Added a "force LDAP synchronize" on member and contact cards.
+- New: Can split a discount into two smaller discount. This allows to use a
+       discount on an invoice even if invoice amount is lower than discount
+       credit available.
+- New: Can use variables into the free text on PDF (__TOTAL_TTC_, __TOTAL_VAT...)
+- New: Increase page loading speed (all changes reported by Google PageSpeed
+       tool has been added).
+- New: Add support of constant MAIN_ONLY_LOGIN_ALLOWED to allow to lock all
+       access to any users except the one defined in constant.
+- New: Add an admin page of PHP sessions with a way to lock new connections
+       for other users than yourself. Can also purge existing sessions.
+- New: Add point of sale module.
+- New: Better usage when using with smartphones.
+- New: Add module FTP client.
+- New: Can set first day of week.
+- New: Installer now create a .htaccess to protect documents directory.
+- New: Experimental support for Postgresql.
+- New: Full support of SMTPS (can works with Google SMTP).
+- Fix: "Now" link works when date popup is not used.
+- Fix: Debug seriously the email notification module.
+- Fix: Error Call to a member function trans when refusing a supplier order.
+- Fix: Fix payment conditions on commercial proposals.
+- Fix: Nb of orders to process was wrong.
+- Fix: Customer code was not correct on PDF it if contains special 
+       characters.
+- Fix: Can update price even with "NPR" VAT rates.
+- Fix: When product type is missing, description is not lost when adding 
+       new product lines.
+- Fix: CC and BCC in emails was not used if using SMTPS handler.
+- Fix: Last character was lost when text end with n or r.
+- Fix: LDAP synchronization is now more robust (transaction and 
+  use modify instead of delete/add).
+- Fix: Fix: Setup of member synchronization does not conflict 
+  with contact or user synchronization.
+
+For translators:
+- Update some language files.
+- Can accept right to left languages. Added an "automatic" arabe translation.
+
+For developers:
+- An external module can force the third party code to be required whatever
+  is the rule of third party code module.
+- Update fckeditor to 2.6.4.
+- Update Smarty to 2.6.26.
+- Removed some deprecated code and files.
+- Creation of directory in module descriptor is simpler.
+- Can use an alternate document_root directory to develop with 
+  sources on two repositories.
+- Removed useless code of old commercial module.
+- Move some modules into the CVS modules repository dolibarrmod. This reduces
+  amount of code in main branch.
+- Updated wiki documentation.
+- Better W3C standard.
+- Can add init data when enabling a module.
+- Can fix some corruptions in database by calling the update page 
+  /install/repair.ksh
+- Log files contains more information (PHP_SELD added and OS user used for 
+  log of command lines scripts) 
+- Can protect a module to not being enabled if javascript disabled.
+- If module numberwords is installed, code can use langs->getLabelFromNumber 
+  to get value of an amount in text.
+- A module can add subsitution keys in makesubsitutions() functions.
+- Add $conf->browser->phone defined to optimise code for smartphone browsers.
+- All external libs are now in same directory /includes.
+- All install files are now in same directory /install.
+
+
+***** ChangeLog for 2.6 compared to 2.5 *****
+
+For users:
+- New: Add filter on status in emailing selector for Dolibarr users.
+- New: Can add bookmarks on all pages.
+- New: Enhance bank transactions reporting.
+- New: When creating a contact from a third party, informations from third
+  party card are automatically suggested.
+- New: Sort list of languages in combo box.
+- New: EMails links are show with function dol_print_email
+- New: Add graph report on number of entities in product statistics page.
+- New: Can delete a supplier order whatever is its status.
+- New: No limit on free text on PDF generated documents.
+- New: Can force login value when creating a user from a member.
+- New: Can clone commercial proposals and orders.
+- New: Major enhancement of project module.
+- New: Added product label in invoice exports fields.
+- New: Add VAT number in export fields.
+- New: Upgrade FPDF to 1.6
+- New: Upgrade Scriptaculous to 1.8.2 and Prototype to 1.6.0.3
+- New: Added keywords in PDF.
+- New: Add hidden option MAIN_DISABLE_PDF_COMPRESSION.
+- New: Add attachments on intervention cards.
+- New: Can add personalized fields in emailing selectors.
+- New: Customer code and supplier code can be defined automatically.
+- New: Emailing feature can extract civility from contacts.
+- New: Can create a third party from a member of foundation module.
+- New: Can set a limit for stock alert to 0.
+- New: Support SMTPS.
+- New: Added a page /support to provide a help center service on Dolibarr.
+- New: Distinct status "running not expired" from "running expired" in lines 
+  contract status.
+- New: Add a first version of a module for Paybox.
+- New: Can add contact to suppliers orders.
+- New: Changes to support the external Bit Torrent module.
+- New: Can filter on social contribution type in list.
+- New: Upload of joined files need create/modify permissions to work.
+- New: For admin users, show the SQL request in export build.
+- New: Can modify proposal date if status is draft.
+- New: The help link on some pages now links directly to the wiki web page.
+- New: Enhancements in barcode module.
+- New: Can use decimal values in stocks.
+- Fix: Partial payment on social contributions not shown on main page.
+- Fix: Handle correctly the comment in status changing of supplier orders.
+- Fix: Author, title and topic are correctly encoded in PDF.
+- Fix: Now HTML output is always UTF8, this solve bad PDF encoding on old
+  users.
+- Fix: Save new model when changed on interventions.
+- Fix: Failed to go on the future view of bank transaction if there is no 
+  future bank transaction already wrote.  
+- Fix: Bad ref in supplier list.
+- Fix: Bad link in product statistics for supplier referrers.
+- Fix: Usage of reset of cursor in personalized numbering modules for a particular
+  month (@ option) was broken.
+- Can add contacts to a supplier invoice.
+- Fix: When an invoice is changed back to status draft, warehouse is increased 
+  back.
+- Fix: Category of a bank transaction was not saved.
+- Fix: Clicktodial plugin works correctly now
+- Fix: Multiprices features works correctly.
+- Fix: Project module and task creation.
+- Fix: Validation of order if a file was attached.
+- Fix: A lot of fixes in PDF generators.
+- Fix: Bad line/page break with long description of products on PDF.
+- Fix: Option force invoice date to validation date working correctly.
+- Fix: Creation of a member from the example public page works.
+
+For translators:
+- Added 10 more new language files.
+- Added autotranslator tool. A tool to build/update automatically
+  languages files using Google API for a new language. Wonderful to start a
+  new translation.
+  
+For developers:
+- Removed some deprecated files.
+- Removed treemenu library.
+- Renamed all function dolibarr_xxx into dol_xxx to have same prefix everywhere.
+- Rewrite clone feature for supplier invoice to work like other clone features.
+- First change to manage a future feature "stock PMP value".
+- A module can add a new tab in third party view tabs.
+- First change for future geoip module.
+
+
+***** ChangeLog for 2.5 compared to 2.4 *****
+
+For users:
+- Sessions timeout can be configured to overwrite PHP setup.
+- Can filter on date in services list.
+- Support bookmark add of product cards.
+- Enhancement in stock management (Automatic increase/decrease
+  from order or invoice is possible).
+- New filter options in prospect lists (category and level).
+- New view in ECM module.
+- Look enhancements for graphics (add transparency).
+- Added statistics report for supplier invoices.
+- Added average amount in invoices statistics reports.
+- Can move a contract line to another contract of same third party.
+- Add an export definition to export interventions.
+- Can set umask file permissions on Unix/Linux/BSD systems.
+- Miscelanous bug fixes.
+- A lot of other enhancements to increase productivity.
+- All phone numbers show the clicktodial link if module is enabled.
+- Can define hour and minutes in intervention cards.
+- Can edit a validated intervention.
+- Add filters on intervention list.
+- Add juridical status and number of employees in third party 
+  export definition.
+- A lot of enhancements and translation in withdraw module.
+- Full support of Mysql option mode=strict.
+- Added a new event from member module to agenda tracked events.
+- Can attach a file to suppliers orders.
+- Change to make Bank Account Number form more "internationnal".
+- Can clone an invoice.
+- Can clone an emailing.
+- Reduce memory usage (about 2%).
+- Add weight and size in sendings module.
+- Add a fast search form on left menu for member module.
+- Fix: Do not show export filter for disabled modules
+- Show greyed lines for not allowed export filters.
+- Add nature in product fields (manufactured product or not).
+- Add export filters for category module and trip and expenses module.
+- Can choose login of dolibarr account created when create from contact
+
+For translators:
+- The errors language file contains only error or warning messages with 
+  prefix Error or Warning.
+- HTML Output is by default in UTF8 and language files can be provided
+  in UTF8.
+
+For developers:
+- Update skeletons (some fixes and add function createFromClone).
+- Add an experimental Cash Desk module.
+- Added new triggers events in agenda module.
+- All submodules are moved in the includes directory.
+- Removed some deprecated files.
+- Menu managers now use same class name for their menu entry
+  and add a different value in an HTML id for each entry. This allows
+  to build skins that use different style for each menu entry.
+- All emails and url HTML output use same function.
+- Add more integrity check on database
+- Can disable modules on logon page. This make possible to
+  have several profiles of demo with only one demo. Also added a new
+  Dolibarr demo front page (in htdocs/public/demo).
+- Allow modules to add new tabs.
+
+   
+
+***** ChangeLog for 2.4 compared to 2.2 *****
+
+For users:
+- Add a calendar module (module agenda) with ical/vcal/rss export.
+- Look enhancement in graphics (thanks artichow).
+- Add tel and fax on delivery addresses.
+- Add a tool to edit personalized menu.
+- Add an ical and vcal export link in agenda and webcalendar module.
+- Reduce memory usage.
+- Now triggers are enabled/disabled according to module they refers to.
+- Fix infinite loop on popup calendar.
+- Change in tanslation to make Dolibarr easier to understand.
+- Add a warning when sending a mail from a user with no email defined.
+- Added clicktodial module.
+- Add a property private/public in contact. This allows to user Dolibarr
+  for a personnal address book.
+- French NAF code can accept 5 chars.
+- Supplier prices can be input with or without taxe.
+- New generic numbering modules to offer more solutions for generating
+  automatic id.
+- Add new predefined exports wizards (stocks, suppliers, taxes...).
+- Add feature to log security events (logon, change of users, passwords).
+- Can link all documents (included supplier invoices and orders) to a 
+  project.
+- Can attach several files to email when sending an invoice, order or
+  proposal by email.
+- Can choose accuracy (number of decimals) for prices.
+- Localization for decimal and thousand delimiter on number is fully
+  supported.
+- More informations reported in system information pages.
+- Add a budget report.
+- Added a security audit report.
+- Other minor changes (features, look, fixes)
+- Added compatibility with Firefox 3.
+- Changes for compatibility with PHP6/Mysql6.
+- Some bug fixes.
+
+For translators:
+- Added spanish es_ES translation.
+- Added en_AU translation.
+
+For developers:
+- Removed useless code:
+  Replaced phplot and phplot5 librairies by artichow.
+  Removed cryptograph library replaced by artichow.
+- Login functions are now externalised as modules.
+- Update code skeletons examples.
+- Several enhancements to make addon development easier.
+- Add a tool to generate PHP classes completely mapped to a table.
+- Added a check to enable external modules only if dolibarr version is
+  high enough.
+- Changes in wizard installer to allow building autoexe installer for
+  Windows with Apache and Mysql included.
+
+
+***** ChangeLog for 2.2 compared to 2.1 *****
+
+- Add more statistics on main page.
+- Add option to add message on login page.
+- Management of categories for third parties.
+- Add volume on products properties.
+- Support for LDAP authentication.
+- Full member synchronisation with LDAP database in
+  fundation module.
+- More LDAP fields supported for user synchronization.
+- Better logger for install.
+- First changes to support UTF8.
+- Add a "forget password" feature.
+- Setup process can run several migrate files if need
+  to jump several versions to upgrade.
+- Support for webcalendar 1.1 in webcalendar module.
+- Support for menu in database.
+- Better support for using Dolibarr on more WHP.
+- Removed some deprecated files and clean code.
+- New theme: Auguria
+- Removed PHP warnings.
+- Some bugs fixes.
+- Traduction more complete.
+- Better code comments for Doxygen documentation.
+- Better support of vcard export format.
+- A lot of security enhancements (no more password in log files,
+  crypted password in database, in config file...).
+- Themes are full CSS compliant.
+- A lot of other minor changes...
+- Option to scan uploaded document by an antivirus.
+- Transparency for picto files works with IE.
+- Can drag and drop boxes on main page.
+
+
+***** ChangeLog for 2.1 compared to 2.0.1 *****
+
+- Added a better installer.
+- Support user and groups permissions.
+- Translation in english and support for several languages.
+- New enhanced look and several new themes.
+- Small search boxes for each Dolibarr elements (invoices, contracts,
+  orders, proposals...)
+- Added an export assistant module to export main dolibarr data.
+- Added backup tool to backup database via mysqldump.
+- Added product categories management with a categorie tree.
+- Management of companies' discounts (relative or absolute).
+- Support credit note and discounts (relative and absolute) on
+  commercial proposal, orders and invoices.
+- Support multi-langual description for products.
+- Graphical enhancements (picto to describe all status).
+- Added more permissions (ie: can restrict access for a commercial user
+  to elements of its companies only).
+- Little enhancements to OSCommerce module.
+- Added a second OSCommerce module working through web services.
+- Added a Mantis module to have a Mantis application in Dolibarr menu.
+- Building a PDF document for invoices works like other modules. You
+  can change model just before generating the PDF.
+- Can generate documents (PDF) for customer orders. Can send them by mail.
+- Added FPDI and FPDI_Protection (ie: PDF with password-protection)
+- Can make one payment for several supplier invoices.
+- Rule to suggests passwords when creating a user are in modules
+  allowing to add easily other rules.
+- Option to encrypt passwords in database (MD5).
+- Add Dolibarr triggers support on users creation/change.
+- Add Dolibarr triggers support on payments.
+- Add Dolibarr triggers on supplier and customers orders.
+- Webcalendar triggers for actions on Member module.
+- Support optionnal new javascript popup selector for date fields.
+- Support for several RSS boxes in external RSS module. Setup easier.
+- Can attach documents on Action, Orders, Invoices, Commercial proposals.
+- Can attach contacts on proposals, orders, contracts, invoices.
+- Preview on results of PDF generator modules in setup pages.
+- Code cleaner. Remove unused or duplicate code.
+- Save and show last connexion date for users.
+- Enhancements on a lot of forms for better ergonomy.
+- Can add/remove company logo.
+- Added LDAP synchronisation for users, groups and/or contacts.
+- Can configure your own SMTP server/port for mail sendings.
+- Works even on "UTF8 by default" systems (Mysql, Linux...)
+- Better compatibility with different PHP version or setup.
+- Added mysqli driver.
+- Add a WISIWYG editor (FCKEditor) to edit note and comment areas.
+- Added AJAX features like a 'search product selector'.
+- Modules boxes on main page can be dragged and dropped (with firefox only).
+- Support for PHP5.
+- Experimental support for Postgresql (not working yet, but waiting feedbacks).
+- Removed obsolete files and documentation.
+- Added admin tools (backup and files purge).
+- Added a tool to build a lang package.
+- Added a tool to build a module package.
+- Added a tool to build a theme package.
+- Traduction more complete.
+- Added skeletons for code examples.
+- Lot of fixes after 2.0 release not fixed in 2.0.1.
+- Added more security option (ie: encrypted password in database)
+
+
+
+
+***** ChangeLog for 2.0.1 compared to 2.0 *****
+
+Minor bug fixes
+
+
+
+***** ChangeLog for 2.0 compared to 1.0 *****
+
+ChangeLog file size is so important, that it is not included inside Dolibarr
+package. You can find it at www.dolibarr.org

+ 6 - 0
dolicloudimages/dolibarr/src/INSTALL

@@ -0,0 +1,6 @@
+INSTALL
+-------
+
+English:     See file README.
+
+French:      Voir fichier README-FR.

+ 139 - 0
dolicloudimages/dolibarr/src/README

@@ -0,0 +1,139 @@
+README (english)
+--------------------------------
+Starter documentation
+--------------------------------
+
+1) Install Dolibarr
+2) Upgrade Dolibarr from an older version
+3) What's new in this version
+4) What Dolibarr can do
+5) What Dolibarr can't do yet, todo list
+
+
+I - DOLIBARR INSTALL
+--------------------
+
+If you have no technical knowledge, and you are looking for an autoinstaller
+to install Dolibarr ERP/CRM in few clicks, you must download DoliWamp (the 
+all-in-one package of Dolibarr for Windows), DoliDeb (the all-in-one package 
+of Dolibarr for Debian or Ubuntu) or DoliRpm (the all-in-one package of 
+Dolibarr for Fedora, Redhat, Mandriva, Opensue, Mageia).
+
+You can download this at:
+http://www.dolibarr.org/downloads/
+
+If you already have installed a Web server and a Mysql database, you can
+install the standard version like this:
+
+- Uncompress the downloaded archive.
+ 
+- Copy directory "dolibarr" and all its files inside your web server root,
+  or copy directory anywhere and set up your web server to use "dolibarr/htdocs"
+  as root for a new web server virtual host (second choice need to be web 
+  server administrator).
+  
+- Create an empty file "htdocs/conf/conf.php" and set permissions for your web
+  server user (write permissions will be removed once install is finished).
+  
+- From your browser, call the dolibarr "install/" page. Url depends on choice
+  made on first step:
+   http://localhost/dolibarr/htdocs/install/
+  or
+   http://yourdolibarrvirtualhost/install/
+   
+- Follow instructions provided by installer...
+
+
+
+II - DOLIBARR UPGRADE
+---------------------
+
+To upgrade Dolibarr from an old version to this one:
+
+- Overwrite all old files inside old 'dolibarr' directory by files
+  provided into new version package.
+  
+- If you came from version x.y.z to x.y.w (only third number differ),
+  there is no need to run any migrate process.
+  
+- If you came from a beta version or from any version x.y.z to any
+  other where x or y number differs, you must call the Dolibarr "install/"
+  page in your browser (this should be done automatically at first dolibarr
+  access).
+  This URL should looks like:
+   http://localhost/dolibarr/htdocs/install/
+  or
+   http://yourdolibarrhost/install/index.php
+
+  Then choose the "update" option according to your case.
+  Note: Migrate process can be ran safely several times.
+  
+
+III - WHAT'S NEW
+----------------
+
+See ChangeLog file found into package.
+
+
+
+IV - WHAT DOLIBARR CAN DO
+-------------------------
+
+Main modules/features:
+- Products and services catalog
+- Customers, Prospects or Suppliers directory
+- Address book
+- Stock management
+- Bank accounts management
+- Orders management with PDF export
+- Commercial proposals management with PDF export
+- Contracts management
+- Invoices management with PDF export
+- Payments management
+- Standing orders management
+- Shipping management
+- ECM (Electronic Content Management)
+- EMailings
+- Agenda with ical,vcal export for third tools integration
+- Management of foundation members
+- Donation management
+
+Other modules:
+- Bookmarks management
+- Can reports Dolibarr events inside Webcalendar or Phenix
+- Data export tools
+- LDAP connectivity
+- Third parties or products categories 
+- ClickToDial phone numbers
+- RSS
+
+Miscellanous:
+- Mutli-user, with several permissions levels for each feature.
+- Serveral menu managers (can be used by internal users, as a back-office,
+  with a particular menu, or by external users, as a front-office, with
+  another menu and permissions).
+- Very user friendly and easy to use.
+- Optional WYSIWYG forms, optional Ajax forms.
+- Several skins.
+- Code is highly customizable (a lot of use of modules and submodules).
+- Works with Mysql 4.1 or higher, or PostgreSql 8.14 or higher.
+- Works with PHP 5.0 or higher.
+- An easy to understand and maintain code (PHP with no heavy frameworks).
+- A trigger architecture to allow you to make Dolibarr business events run
+  PHP code to update your own information system.
+- "NPR VAT Rate" (French particularity for managing VAT in DOM-TOM 
+  called "Non Perçue Récupérable").
+
+
+
+V - WHAT DOLIBARR CAN'T DO YET (TODO LIST)
+------------------------------------------
+This is features that Dolibarr does not support completely yet:
+- No accountancy (only bank management).
+- Dolibarr manage one currency at once (mono-currency).
+- Dolibarr manage one company/foundation (mono-company). If you want to manage several companies or foundations, you must install several time the software (on same server or not). Another solution is to extend Dolibarr with the addon Module MultiCompany that allows to manage several companies in one Dolibarr instance (one database but with a logical isolation of datas).
+- Does not support double VAT (Federal / provincial) for Canada.
+- Dolibarr does not contains Payroll module.
+- Tasks on module project can't have dependencies between each other.
+- Dolibarr does not include any Webmail.
+- Dolibarr can't do coffee (not yet). 

+ 130 - 0
dolicloudimages/dolibarr/src/README-FR

@@ -0,0 +1,130 @@
+README (french)
+--------------------------------
+Documentation démarrage rapide
+--------------------------------
+
+1) Installer Dolibarr
+2) Mettre à jour Dolibarr depuis une ancienne version
+3) Ce qui est nouveau dans cette version
+4) Ce que peux faire Dolibarr
+5) Ce que ne peux pas faire Dolibarr (pas encore)
+
+
+I - INSTALLER DOLIBARR
+----------------------
+
+Si vous n'avez pas de connaissances techniques, et que vous recherchez
+un programme d'installation qui install Dolibarr ERP/CRM en quelques clics,
+vous devez vous réorienter vers DoliWamp (la version tout-en-un
+de Dolibarr pour Windows), DoliDeb (la version tout-en-un pour Debian ou
+Ubuntu) ou DoliRpm (la version tout-en-un de Dolibarr pour Fedora, Redhat,
+OpenSuse, Mandriva ou Mageia).
+Vous pouvez les télécharger à l'adresse: 
+http://www.dolibarr.org/downloads/
+
+Si vous avez déjà installé un serveur Web avec PHP et une base de donnée (Mysql),
+vous pouvez installer Dolibarr avec cette version de la manière suivante:
+
+- Copier le répertoire "dolibarr" et son contenu dans la racine de votre serveur
+  web, ou bien copier le répertoire sur le serveur et configurer ce serveur pour
+  utiliser "dolibarr/htdocs" comme racine d'un nouveau virtual host (ce second 
+  choix requiert des compétences et habilitations en administration du serveur
+  web).
+  
+- Créer un fichier vide "htdocs/conf/conf.php" et attribuer les permissions
+  en lecture et écriture pour le user du serveur web (les permissions en 
+  écriture seront supprimées une fois l'installation terminée).
+
+- Depuis votre navigateur, appeler la page "install/" de dolibarr. L'url dépend 
+  du choix fait à la première etape:
+   http://localhost/dolibarr/htdocs/install/
+  ou
+   http://yourdolibarrvirtualhost/install/
+   
+- Suivez les instructions fournies par l'installeur...
+
+
+
+II - METTRE A JOUR DOLIBARR
+---------------------------
+
+Pour mettre a jour Dolibarr depuis une vieille version vers celle ci:
+- Ecraser les vieux fichiers dans le vieux repertoire 'dolibarr' par les fichiers
+  fournis dans ce nouveau package.
+  
+- Si vous venez d'une version x.y.z vers x.y.w (seul le 3eme chiffre varie),
+  il n'y a pas besoin de migration de données.
+  
+- Si vous venez d'une beta ou d'un version x.y.z vers une autre ou les numeros x
+  ou y varient, vous devez appelez la page "install/" de migration dans votre 
+  navigateur (ceci doit se faire automatiquement au premier accès de l'application).
+  Ce sera une URL du genre:
+   http://localhost/dolibarr/htdocs/install/index.php
+  ou
+   http://yourdolibarrhost/install/index.php
+
+  Ensuite, choisir l'option de "mise a jour" en rapport avec votre cas.
+  Note: Le processus de migration peut etre lance plusieurs fois sans risque.
+  
+
+III - CE QUI EST NOUVEAU
+------------------------
+
+Voir fichier ChangeLog.
+
+
+
+IV - CE QUE DOLIBARR PEUT FAIRE
+-------------------------------
+
+Modules principaux:
+- Gestion de catalogue de produits et services
+- Gestion de stock
+- Gestion des comptes bancaires
+- Annuaires des prospects et/ou client et/ou fournisseurs
+- Annuaires des contacts
+- Gestion des actions/taches avec un agenda intégré (ou lien avec webcalendar)
+- Gestion des commandes
+- Gestion des propositions commerciales
+- Gestion de contrats de services
+- Gestion des factures clients et fournisseurs
+- Gestion des paiements
+- Gestion des virements bancaires
+- Gestion des expéditions
+
+Autres modules:
+- Gestion de la TVA NPR (non perçue récupérable - pour les utilisateurs français des DOM-TOM)
+- Gestion des adhérents d'association
+- Gestion des dons
+- Gestion de marque-pages
+- Agenda
+- Point de vente/Caisse enregistreuse
+- Fonctions d'EMailing de masses vers les clients, prospect ou utilisateurs Dolibarr
+- Rapports
+- Fonctions d'exports
+- Connectivité LDAP
+- Export PDF de tous les éléments (factures, propositions commerciales, commandes, bons expéditions, etc...)
+- De nombreuses autres fonctionnalités issues de modules officiels ou non (AWStats, Bittorrent, Gravatar, Google, Webcalendar...) 
+
+Miscellanous:
+- Application multi-utilisateurs avec différents niveaux de permissions par module.
+- Plusieurs gestionnaires de menus (possibilité de différencier les menus pour les utilisateurs internes ou externes comme les clients ou fournisseurs).
+- Application simple à utiliser.
+- Plusieurs thèmes visuels.
+- Code simple et facilement personnalisable.
+- Fonctionne avec MySQL 4.1+ ou PostgreSql 8.1.4+.
+- Fonctionne avec PHP 5.0+.
+- Compatible avec toutes les offres Cloud du marché respectant les prérequis MySQL et PHP. 
+
+
+V - CE QUE DOLIBARR NE PEUT PAS FAIRE (TACHES A FAIRE)
+------------------------------------------------------
+Voici un liste de fonctionnalites pas encore gérées par Dolibarr:
+- Pas de compta analytique (uniquement gestion de trésorerie).
+- Dolibarr ne gère qu'une seule monnaie à la fois (mono-devise).
+- Dolibarr ne gère en standard qu'une société/institution/association (mono-société). Pour en gérer plusieurs (comme vos filiales), il faut, soit faire plusieurs installations de Dolibarr, soit installer le module MutliCompany qui permet de gérer n société/institutions/associations dans une seule instance par une isolation logique des données.
+- Ne gère pas la double tva (Fédérale / provinciale) du canada.
+- Dolibarr ne contient pas de module de Gestion de la paie.
+- Les taches du module de gestion de projets n'ont pas de dépendance entre elle.
+- Dolibarr ne contient pas de Webmail.
+- Dolibarr ne fait pas le café (pas encore). 

+ 2 - 0
dolicloudimages/dolibarr/src/documents/.htaccess

@@ -0,0 +1,2 @@
+Order allow,deny
+Deny from all

BIN
dolicloudimages/dolibarr/src/documents/doctemplates/invoices/template_invoice.odt


BIN
dolicloudimages/dolibarr/src/documents/doctemplates/orders/template_order.odt


BIN
dolicloudimages/dolibarr/src/documents/doctemplates/proposals/template_proposal.odt


BIN
dolicloudimages/dolibarr/src/documents/doctemplates/thirdparties/template_thirdparty.odt


+ 2 - 0
dolicloudimages/dolibarr/src/documents/install.lock

@@ -0,0 +1,2 @@
+File install.lock. Added during installation.
+Delete this file to allow usage of /install pages.

+ 96 - 0
dolicloudimages/dolibarr/src/htdocs/accountancy/class/accountancyaccount.class.php

@@ -0,0 +1,96 @@
+<?php
+/* Copyright (C) 2006-2009 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/accountancy/class/accountancyaccount.class.php
+ * 	\ingroup    accounting
+ * 	\brief      Fichier de la classe des comptes comptables
+ */
+
+
+/**
+ * \class 		AccountancyAccount
+ * \brief 		Classe permettant la gestion des comptes
+ */
+class AccountancyAccount
+{
+    var $db;
+    var $error;
+
+    var $rowid;
+    var $fk_pcg_version;
+    var $pcg_type;
+    var $pcg_subtype;
+    var $label;
+    var $account_number;
+    var $account_parent;
+
+
+    /**
+     *  Constructor
+     *
+     *  @param		DoliDB		$DB		Database handler
+     */
+    function AccountancyAccount($DB)
+    {
+        $this->db = $DB;
+    }
+
+
+    /**
+     *    Insert account into database
+     *
+     *    @param  	User	$user 	User making add
+     *    @return	int				<0 if KO, Id line added if OK
+     */
+    function create($user)
+    {
+    	$now=dol_now();
+    	
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingaccount";
+        $sql.= " (date_creation, fk_user_author, numero,intitule)";
+        $sql.= " VALUES (".$this->db->idate($now).",".$user->id.",'".$this->numero."','".$this->intitule."')";
+
+        $resql = $this->db->query($sql);
+        if ($resql)
+        {
+            $id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingaccount");
+
+            if ($id > 0)
+            {
+                $this->id = $id;
+                $result = $this->id;
+            }
+            else
+            {
+                $result = -2;
+                $this->error="AccountancyAccount::Create Erreur $result";
+                dol_syslog($this->error, LOG_ERR);
+            }
+        }
+        else
+        {
+            $result = -1;
+            $this->error="AccountancyAccount::Create Erreur $result";
+            dol_syslog($this->error, LOG_ERR);
+        }
+
+        return $result;
+    }
+
+}
+?>

+ 93 - 0
dolicloudimages/dolibarr/src/htdocs/accountancy/class/accountancysystem.class.php

@@ -0,0 +1,93 @@
+<?php
+/* Copyright (C) 2006-2009 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/accountancy/class/accountancysystem.class.php
+ * 	\ingroup    accounting
+ * 	\brief      File of class to manage accountancy systems
+ */
+
+
+/**	\class 		AccountancySystem
+ *	\brief 		Classe to manage accountancy systems
+ */
+class AccountancySystem
+{
+	var $db;
+	var $error;
+
+	var $rowid;
+	var $fk_pcg_version;
+	var $pcg_type;
+	var $pcg_subtype;
+	var $label;
+	var $account_number;
+	var $account_parent;
+
+
+	/**
+	 *	Constructor
+	 *
+	 *  @param		DoliDB		$DB      Database handler
+	 */
+	function AccountancySystem($DB)
+	{
+		$this->db = $DB;
+	}
+
+
+	/**
+	 *  Insert accountancy system name into database
+	 *
+	 *  @param  	User	$user 	User making insert
+	 *  @return		int				<0 if KO, Id of line if OK
+	 */
+	function create($user)
+	{
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."accountingsystem";
+		$sql.= " (date_creation, fk_user_author, numero,intitule)";
+		$sql.= " VALUES (".$this->db->idate(mktime()).",".$user->id.",'".$this->numero."','".$this->intitule."')";
+
+		$resql = $this->db->query($sql);
+		if ($resql)
+		{
+			$id = $this->db->last_insert_id(MAIN_DB_PREFIX."accountingsystem");
+
+			if ($id > 0)
+			{
+				$this->id = $id;
+				$result = $this->id;
+			}
+			else
+			{
+				$result = -2;
+				$this->error="AccountancySystem::Create Erreur $result";
+				dol_syslog($this->error, LOG_ERR);
+			}
+		}
+		else
+		{
+			$result = -1;
+			$this->error="AccountancySystem::Create Erreur $result";
+			dol_syslog($this->error, LOG_ERR);
+		}
+
+		return $result;
+	}
+
+}
+?>

+ 1 - 0
dolicloudimages/dolibarr/src/htdocs/accountancy/index.php

@@ -0,0 +1 @@
+Url not available

+ 274 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/admin/adherent.php

@@ -0,0 +1,274 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/adherents/admin/adherent.php
+ *		\ingroup    member
+ *		\brief      Page to setup the module Foundation
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+
+$langs->load("admin");
+$langs->load("members");
+
+if (! $user->admin) accessforbidden();
+
+
+$type=array('yesno','texte','chaine');
+
+$action = GETPOST('action','alpha');
+
+
+/*
+ * Actions
+ */
+
+// Action mise a jour ou ajout d'une constante
+if ($action == 'update' || $action == 'add')
+{
+	$constname=GETPOST('constname','alpha');
+	$constvalue=(GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue'));
+
+	if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE') && $constvalue == -1) $constvalue='';
+	if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
+	{
+		if ($constvalue) $constvalue=0;
+		else $constvalue=1;
+	}
+
+	$consttype=GETPOST('consttype','alpha');
+	$constnote=GETPOST('constnote');
+	$res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
+
+	if (! $res > 0) $error++;
+
+	if (! $error)
+	{
+		$mesg = '<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+	}
+	else
+	{
+		$mesg = '<div class="error">'.$langs->trans("Error").'</div>';
+	}
+}
+
+// Action activation d'un sous module du module adherent
+if ($action == 'set')
+{
+    $result=dolibarr_set_const($db, GETPOST('name','alpha'),GETPOST('value'),'',0,'',$conf->entity);
+    if ($result < 0)
+    {
+        print $db->error();
+    }
+}
+
+// Action desactivation d'un sous module du module adherent
+if ($action == 'unset')
+{
+    $result=dolibarr_del_const($db,GETPOST('name','alpha'),$conf->entity);
+    if ($result < 0)
+    {
+        print $db->error();
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+
+llxHeader('',$langs->trans("MembersSetup"),$help_url);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MembersSetup"),$linkback,'setup');
+
+
+$head = member_admin_prepare_head($adh);
+
+dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
+
+
+dol_htmloutput_mesg($mesg);
+
+
+print_fiche_titre($langs->trans("MemberMainOptions"),'','');
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print '<td align="center">'.$langs->trans("Action").'</td>';
+print "</tr>\n";
+$var=true;
+$form = new Form($db);
+
+// Login/Pass required for members
+if ($conf->global->MAIN_FEATURES_LEVEL > 0)
+{
+    $var=!$var;
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+    print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+    print '<input type="hidden" name="constname" value="ADHERENT_LOGIN_NOT_REQUIRED">';
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("AdherentLoginRequired").'</td><td>';
+    print $form->selectyesno('constvalue',!$conf->global->ADHERENT_LOGIN_NOT_REQUIRED,1);
+    print '</td><td align="center" width="80">';
+    print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
+    print "</td></tr>\n";
+    print '</form>';
+}
+
+// Mail required for members
+$var=!$var;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="update">';
+print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+print '<input type="hidden" name="constname" value="ADHERENT_MAIL_REQUIRED">';
+print '<tr '.$bc[$var].'><td>'.$langs->trans("AdherentMailRequired").'</td><td>';
+print $form->selectyesno('constvalue',$conf->global->ADHERENT_MAIL_REQUIRED,1);
+print '</td><td align="center" width="80">';
+print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
+print "</td></tr>\n";
+print '</form>';
+
+// Send mail information is on by default
+$var=!$var;
+print '<form action="adherent.php" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="update">';
+print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+print '<input type="hidden" name="constname" value="ADHERENT_DEFAULT_SENDINFOBYMAIL">';
+print '<tr '.$bc[$var].'><td>'.$langs->trans("MemberSendInformationByMailByDefault").'</td><td>';
+print $form->selectyesno('constvalue',$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL,1);
+print '</td><td align="center" width="80">';
+print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
+print "</td></tr>\n";
+print '</form>';
+
+// Insertion cotisations dans compte financier
+$var=!$var;
+print '<form action="adherent.php" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="update">';
+print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+print '<input type="hidden" name="constname" value="ADHERENT_BANK_USE">';
+print '<tr '.$bc[$var].'><td>'.$langs->trans("AddSubscriptionIntoAccount").'</td>';
+if ($conf->banque->enabled)
+{
+    print '<td>';
+    print $form->selectyesno('constvalue',$conf->global->ADHERENT_BANK_USE,1);
+    print '</td><td align="center" width="80">';
+    print '<input type="submit" class="button" value="'.$langs->trans("Update").'" name="Button">';
+    print '</td>';
+}
+else
+{
+    print '<td align="right" colspan="2">';
+    print $langs->trans("WarningModuleNotActive",$langs->transnoentities("Module85Name")).' '.img_warning("","");
+    print '</td>';
+}
+print "</tr>\n";
+print '</form>';
+print '</table>';
+print '<br>';
+
+
+/*
+ * Edition info modele document
+ */
+$constantes=array(
+		'ADHERENT_CARD_TYPE',
+//		'ADHERENT_CARD_BACKGROUND',
+		'ADHERENT_CARD_HEADER_TEXT',
+		'ADHERENT_CARD_TEXT',
+		'ADHERENT_CARD_TEXT_RIGHT',
+		'ADHERENT_CARD_FOOTER_TEXT'
+		);
+
+print_fiche_titre($langs->trans("MembersCards"),'','');
+
+form_constantes($constantes);
+
+print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%, ';
+print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%, ';
+print '%YEAR%, %MONTH%, %DAY%';
+//print '%INFOS%'; Deprecated
+print '<br>';
+
+print '<br>';
+
+
+/*
+ * Edition info modele document
+ */
+$constantes=array('ADHERENT_ETIQUETTE_TYPE');
+
+print_fiche_titre($langs->trans("MembersTickets"),'','');
+
+form_constantes($constantes);
+
+print '<br>';
+
+
+/*
+ * Edition des variables globales non rattache a un theme specifique
+ */
+$constantes=array(
+		'ADHERENT_AUTOREGISTER_MAIL_SUBJECT',
+		'ADHERENT_AUTOREGISTER_MAIL',
+		'ADHERENT_MAIL_VALID_SUBJECT',
+		'ADHERENT_MAIL_VALID',
+		'ADHERENT_MAIL_COTIS_SUBJECT',
+		'ADHERENT_MAIL_COTIS',
+		'ADHERENT_MAIL_RESIL_SUBJECT',
+		'ADHERENT_MAIL_RESIL',
+		'ADHERENT_MAIL_FROM',
+		);
+
+print_fiche_titre($langs->trans("Other"),'','');
+
+form_constantes($constantes);
+
+print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+print '%DOL_MAIN_URL_ROOT%, %ID%, %PRENOM%, %NOM%, %LOGIN%, %PASSWORD%,';
+print '%SOCIETE%, %ADRESSE%, %CP%, %VILLE%, %PAYS%, %EMAIL%, %NAISS%, %PHOTO%, %TYPE%';
+//print '%YEAR%, %MONTH%, %DAY%';	// Not supported
+//print '%INFOS%'; Deprecated
+print '<br>';
+
+dol_fiche_end();
+
+
+llxFooter();
+
+$db->close();
+?>

+ 214 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/admin/adherent_extrafields.php

@@ -0,0 +1,214 @@
+<?php
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/admin/adherent_extrafields.php
+ *		\ingroup    member
+ *		\brief      Page to setup extra fields of members
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
+
+$langs->load("members");
+$langs->load("admin");
+
+$extrafields = new ExtraFields($db);
+$form = new Form($db);
+
+// List of supported format
+$type2label=array(
+'varchar'=>$langs->trans('String'),
+'text'=>$langs->trans('Text'),
+'int'=>$langs->trans('Int'),
+'date'=>$langs->trans('Date'),
+'datetime'=>$langs->trans('DateAndTime')
+);
+
+$action=GETPOST("action");
+$elementtype='member';
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+require(DOL_DOCUMENT_ROOT."/core/admin_extrafields.inc.php");
+
+
+
+/*
+ * View
+ */
+
+$textobject=$langs->transnoentitiesnoconv("Members");
+
+$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+llxHeader('',$langs->trans("MembersSetup"),$help_url);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MembersSetup"),$linkback,'setup');
+
+
+$head = member_admin_prepare_head($adh);
+
+dol_fiche_head($head, 'attributes', $langs->trans("Member"), 0, 'user');
+
+
+print $langs->trans("DefineHereComplementaryAttributes",$textobject).'<br>'."\n";
+print '<br>';
+
+dol_htmloutput_errors($mesg);
+
+// Load attribute_label
+$extrafields->fetch_name_optionals_label($elementtype);
+
+print "<table summary=\"listofattributes\" class=\"noborder\" width=\"100%\">";
+
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Label").'</td>';
+print '<td>'.$langs->trans("AttributeCode").'</td>';
+print '<td>'.$langs->trans("Type").'</td>';
+print '<td align="right">'.$langs->trans("Size").'</td>';
+print '<td width="80">&nbsp;</td>';
+print "</tr>\n";
+
+$var=True;
+foreach($extrafields->attribute_type as $key => $value)
+{
+	$var=!$var;
+	print "<tr ".$bc[$var].">";
+    print "<td>".$extrafields->attribute_label[$key]."</td>\n";
+	print "<td>".$key."</td>\n";
+	print "<td>".$type2label[$extrafields->attribute_type[$key]]."</td>\n";
+	print '<td align="right">'.$extrafields->attribute_size[$key]."</td>\n";
+	print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&attrname='.$key.'">'.img_edit().'</a>';
+	print "&nbsp; <a href=\"".$_SERVER["PHP_SELF"]."?action=delete&attrname=".$key."\">".img_delete()."</a></td>\n";
+	print "</tr>";
+	//      $i++;
+}
+
+print "</table>";
+
+dol_fiche_end();
+
+/*
+ * Barre d'actions
+ *
+ */
+if ($action != 'create' && $action != 'edit')
+{
+	print '<div class="tabsAction">';
+	print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create\">".$langs->trans("NewAttribute")."</a>";
+	print "</div>";
+}
+
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Creation d'un champ optionnel
+ /*                                                                            */
+/* ************************************************************************** */
+
+if ($action == 'create')
+{
+	print "<br>";
+	print_titre($langs->trans('NewAttribute'));
+
+	print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<table summary="listofattributes" class="border" width="100%">';
+
+	print '<input type="hidden" name="action" value="add">';
+
+	// Label
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("Label").'</td><td class="valeur"><input type="text" name="label" size="40" value="'.GETPOST('label').'"></td></tr>';
+	// Code
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("AttributeCode").' ('.$langs->trans("AlphaNumOnlyCharsAndNoSpace").')</td><td class="valeur"><input type="text" name="attrname" size="10" value="'.GETPOST('attrname').'"></td></tr>';
+	// Type
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("Type").'</td><td class="valeur">';
+    print $form->selectarray('type',$type2label,GETPOST('type'));
+	print '</td></tr>';
+	// Size
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td><input type="text" name="size" size="5" value="'.(GETPOST('size')?GETPOST('size'):'255').'"></td></tr>';
+
+    print '</table>';
+
+    print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> &nbsp; ';
+    print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
+
+    print "</form>\n";
+}
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Edition d'un champ optionnel                                               */
+/*                                                                            */
+/* ************************************************************************** */
+if ($_GET["attrname"] && $action == 'edit')
+{
+	print "<br>";
+	print_titre($langs->trans("FieldEdition",$_GET["attrname"]));
+
+	/*
+	 * formulaire d'edition
+	 */
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?attrname='.$_GET["attrname"].'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="attrname" value="'.$_GET["attrname"].'">';
+	print '<input type="hidden" name="action" value="update">';
+	print '<table summary="listofattributes" class="border" width="100%">';
+
+    // Label
+    print '<tr>';
+    print '<td class="fieldrequired" required>'.$langs->trans("Label").'</td><td class="valeur"><input type="text" name="label" size="40" value="'.$extrafields->attribute_label[$_GET["attrname"]].'"></td>';
+    print '</tr>';
+	// Code
+	print '<tr>';
+	print '<td class="fieldrequired" required>'.$langs->trans("AttributeCode").'</td>';
+	print '<td class="valeur">'.$_GET["attrname"].'&nbsp;</td>';
+	print '</tr>';
+	// Type
+	$type=$extrafields->attribute_type[$_GET["attrname"]];
+	$size=$extrafields->attribute_size[$_GET["attrname"]];
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("Type").'</td>';
+	print '<td class="valeur">';
+	print $type2label[$type];
+	print '<input type="hidden" name="type" value="'.$type.'">';
+	print '</td></tr>';
+    // Size
+	print '<tr><td class="fieldrequired" required>'.$langs->trans("Size").'</td><td class="valeur"><input type="text" name="size" size="5" value="'.$size.'"></td></tr>';
+
+	print '</table>';
+
+	print '<center><br><input type="submit" name="button" class="button" value="'.$langs->trans("Save").'"> &nbsp; ';
+    print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
+
+	print "</form>";
+
+}
+
+$db->close();
+
+llxFooter();
+?>

+ 175 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/admin/mailman.php

@@ -0,0 +1,175 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/adherents/admin/adherent.php
+ *		\ingroup    member
+ *		\brief      Page to setup the module Foundation
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/mailmanspip.lib.php");
+
+$langs->load("admin");
+$langs->load("members");
+
+if (! $user->admin) accessforbidden();
+
+
+$type=array('yesno','texte','chaine');
+
+$action = GETPOST("action");
+
+
+/*
+ * Actions
+ */
+
+// Action mise a jour ou ajout d'une constante
+if ($action == 'update' || $action == 'add')
+{
+	$constname=GETPOST("constname");
+	$constvalue=GETPOST("constvalue");
+
+	if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE') && $constvalue == -1) $constvalue='';
+	if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
+	{
+		if ($constvalue) $constvalue=0;
+		else $constvalue=1;
+	}
+
+	if (in_array($constname,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $constvalue=$_POST["constvalue".$constname];
+	$consttype=$_POST["consttype"];
+	$constnote=GETPOST("constnote");
+	$res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
+
+	if (! $res > 0) $error++;
+
+	if (! $error)
+	{
+		$mesg = '<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+	}
+	else
+	{
+		$mesg = '<div class="error">'.$langs->trans("Error").'</div>';
+	}
+}
+
+// Action activation d'un sous module du module adherent
+if ($action == 'set')
+{
+    $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity);
+    if ($result < 0)
+    {
+        dol_print_error($db);
+    }
+}
+
+// Action desactivation d'un sous module du module adherent
+if ($action == 'unset')
+{
+    $result=dolibarr_del_const($db,$_GET["name"],$conf->entity);
+    if ($result < 0)
+    {
+        dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+$help_url='';
+
+llxHeader('',$langs->trans("MailmanSpipSetup"),$help_url);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'setup');
+
+
+$head = mailmanspip_admin_prepare_head($adh);
+
+dol_fiche_head($head, 'mailman', $langs->trans("Setup"), 0, 'user');
+
+
+dol_htmloutput_mesg($mesg);
+
+
+/*
+ * Mailman
+ */
+$var=!$var;
+if ($conf->global->ADHERENT_USE_MAILMAN)
+{
+    $lien=img_picto($langs->trans("Active"),'tick').' ';
+    $lien.='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_MAILMAN">'.$langs->trans("Disable").'</a>';
+    // Edition des varibales globales
+    $constantes=array(
+        'ADHERENT_MAILMAN_ADMINPW',
+        'ADHERENT_MAILMAN_URL',
+        'ADHERENT_MAILMAN_UNSUB_URL',
+        'ADHERENT_MAILMAN_LISTS'
+    );
+
+    print_fiche_titre($langs->trans('MailmanTitle'),$lien,'');
+
+    // JQuery activity
+    print '<script type="text/javascript">
+    var i1=0;
+    var i2=0;
+    jQuery(document).ready(function(){
+        jQuery("#exampleclick1").click(function(event){
+            if (i1 == 0) { jQuery("#example1").show(); i1=1; }
+            else if (i1 == 1)  { jQuery("#example1").hide(); i1=0; }
+            });
+        jQuery("#exampleclick2").click(function(){
+            if (i2 == 0) { jQuery("#example2").show(); i2=1; }
+            else if (i2 == 1)  { jQuery("#example2").hide(); i2=0; }
+            });
+    });
+    </script>';
+
+    form_constantes($constantes);
+
+    print '*'.$langs->trans("FollowingConstantsWillBeSubstituted").'<br>';
+    print '%LISTE%, %MAILMAN_ADMINPW%, %EMAIL% <br>';
+
+    print '<br>';
+}
+else
+{
+    $lien='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_MAILMAN">'.$langs->trans("Activate").'</a>';
+    print_fiche_titre("Mailman mailing list system",$lien,'');
+    print "<hr>\n";
+}
+
+dol_fiche_end();
+
+llxFooter();
+
+$db->close();
+?>

+ 198 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/admin/public.php

@@ -0,0 +1,198 @@
+<?php
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *     	\file       htdocs/adherents/admin/public.php
+ *		\ingroup    member
+ *		\brief      File of main public page for member module
+ *		\author	    Laurent Destailleur
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+
+$langs->load("members");
+$langs->load("admin");
+
+$action=GETPOST('action');
+
+if (! $user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update')
+{
+    $res=dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC",$_POST["MEMBER_ENABLE_PUBLIC"],'chaine',0,'',$conf->entity);
+    $res=dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT",$_POST["MEMBER_NEWFORM_AMOUNT"],'chaine',0,'',$conf->entity);
+    $res=dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT",$_POST["MEMBER_NEWFORM_EDITAMOUNT"],'chaine',0,'',$conf->entity);
+    $res=dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE",$_POST["MEMBER_NEWFORM_PAYONLINE"],'chaine',0,'',$conf->entity);
+
+    if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+llxHeader('',$langs->trans("MembersSetup"),$help_url);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MembersSetup"),$linkback,'setup');
+
+$head = member_admin_prepare_head($adh);
+
+dol_fiche_head($head, 'public', $langs->trans("Member"), 0, 'user');
+
+dol_htmloutput_mesg($mesg);
+
+if ($conf->use_javascript_ajax)
+{
+    print "\n".'<script type="text/javascript" language="javascript">';
+    print 'jQuery(document).ready(function () {
+                function initfields()
+                {
+                    if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'0\')
+                    {
+                        jQuery(".drag").hide();
+                    }
+                    if (jQuery("#MEMBER_ENABLE_PUBLIC").val()==\'1\')
+                    {
+                        jQuery(".drag").show();
+                    }
+                }
+                initfields();
+                jQuery("#MEMBER_ENABLE_PUBLIC").change(function() {
+                    initfields();
+                });
+           })';
+    print '</script>'."\n";
+}
+
+
+print $langs->trans("BlankSubscriptionFormDesc").'<br><br>';
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="action" value="update">';
+
+print '<table class="noborder" width="100%">';
+
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print "</tr>\n";
+$var=true;
+
+// Allow public form
+$var=! $var;
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("EnablePublicSubscriptionForm");
+print '</td><td width="60" align="right">';
+print $form->selectyesno("MEMBER_ENABLE_PUBLIC",$conf->global->MEMBER_ENABLE_PUBLIC,1);
+print "</td></tr>\n";
+
+// Type
+/*$var=! $var;
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<tr '.$bcdd[$var].'><td>';
+print $langs->trans("EnablePublicSubscriptionForm");
+print '</td><td width="60" align="center">';
+print $form->selectyesno("forcedate",$conf->global->MEMBER_NEWFORM_FORCETYPE,1);
+print "</td></tr>\n"; */
+
+// Amount
+$var=! $var;
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<tr '.$bcdd[$var].'><td>';
+print $langs->trans("DefaultAmount");
+print '</td><td width="60" align="right">';
+print '<input type="text" id="MEMBER_NEWFORM_AMOUNT" name="MEMBER_NEWFORM_AMOUNT" size="5" value="'.$conf->global->MEMBER_NEWFORM_AMOUNT.'">';;
+print "</td></tr>\n";
+
+// Can edit
+$var=! $var;
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<tr '.$bcdd[$var].'><td>';
+print $langs->trans("CanEditAmount");
+print '</td><td width="60" align="right">';
+print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT",$conf->global->MEMBER_NEWFORM_EDITAMOUNT,1);
+print "</td></tr>\n";
+
+if ($conf->paybox->enabled || $conf->paypal->enabled)
+{
+    // Jump to an online payment page
+    $var=! $var;
+    print '<tr '.$bcdd[$var].'><td>';
+    print $langs->trans("MEMBER_NEWFORM_PAYONLINE");
+    print '</td><td width="60" align="right">';
+    $listofval=array();
+    if ($conf->paybox->enabled) $listofval['paybox']='Paybox';
+    if ($conf->paypal->enabled) $listofval['paypal']='PayPal';
+    print $form->selectarray("MEMBER_NEWFORM_PAYONLINE",$listofval,$conf->global->MEMBER_NEWFORM_PAYONLINE,1);
+    print "</td></tr>\n";
+}
+
+print '</table>';
+
+print '<center>';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print '</center>';
+
+print '</form>';
+
+dol_fiche_end();
+
+
+print '<br>';
+//print $langs->trans('FollowingLinksArePublic').'<br>';
+print img_picto('','object_globe.png').' '.$langs->trans('BlankSubscriptionForm').':<br>';
+print '<a target="_blank" href="'.DOL_URL_ROOT.'/public/members/new.php">'.DOL_MAIN_URL_ROOT.'/public/members/new.php</a>';
+
+/*
+print '<table class="border" cellspacing="0" cellpadding="3">';
+print '<tr class="liste_titre"><td>'.$langs->trans("Description").'</td><td>'.$langs->trans("URL").'</td></tr>';
+print '<tr><td>'.$langs->trans("BlankSubscriptionForm").'</td><td>'..'</td></tr>';
+print '<tr><td>'.$langs->trans("PublicMemberList").'</td><td>'.img_picto('','object_globe.png').' '.'<a target="_blank" href="'.DOL_URL_ROOT.'/public/members/public_list.php'.'">'.DOL_MAIN_URL_ROOT.'/public/members/public_list.php'.'</a></td></tr>';
+print '<tr><td>'.$langs->trans("PublicMemberCard").'</td><td>'.img_picto('','object_globe.png').' '.DOL_MAIN_URL_ROOT.'/public/members/public_card.php?id=xxx'.'</td></tr>';
+print '</table>';
+*/
+
+llxFooter();
+
+$db->close();
+?>

+ 154 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/admin/spip.php

@@ -0,0 +1,154 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/adherents/admin/adherent.php
+ *		\ingroup    member
+ *		\brief      Page to setup the module Foundation
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/mailmanspip.lib.php");
+
+$langs->load("admin");
+$langs->load("members");
+
+if (! $user->admin) accessforbidden();
+
+
+$type=array('yesno','texte','chaine');
+
+$action = GETPOST("action");
+
+
+/*
+ * Actions
+ */
+
+// Action mise a jour ou ajout d'une constante
+if ($action == 'update' || $action == 'add')
+{
+	$constname=GETPOST("constname");
+	$constvalue=GETPOST("constvalue");
+
+	if (($constname=='ADHERENT_CARD_TYPE' || $constname=='ADHERENT_ETIQUETTE_TYPE') && $constvalue == -1) $constvalue='';
+	if ($constname=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
+	{
+		if ($constvalue) $constvalue=0;
+		else $constvalue=1;
+	}
+
+	if (in_array($constname,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $constvalue=$_POST["constvalue".$constname];
+	$consttype=$_POST["consttype"];
+	$constnote=GETPOST("constnote");
+	$res=dolibarr_set_const($db,$constname,$constvalue,$type[$consttype],0,$constnote,$conf->entity);
+
+	if (! $res > 0) $error++;
+
+	if (! $error)
+	{
+		$mesg = '<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+	}
+	else
+	{
+		$mesg = '<div class="error">'.$langs->trans("Error").'</div>';
+	}
+}
+
+// Action activation d'un sous module du module adherent
+if ($action == 'set')
+{
+    $result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity);
+    if ($result < 0)
+    {
+        dol_print_error($db);
+    }
+}
+
+// Action desactivation d'un sous module du module adherent
+if ($action == 'unset')
+{
+    $result=dolibarr_del_const($db,$_GET["name"],$conf->entity);
+    if ($result < 0)
+    {
+        dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+$help_url='';
+
+llxHeader('',$langs->trans("MailmanSpipSetup"),$help_url);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MailmanSpipSetup"),$linkback,'setup');
+
+
+$head = mailmanspip_admin_prepare_head($adh);
+
+dol_fiche_head($head, 'spip', $langs->trans("Setup"), 0, 'user');
+
+
+dol_htmloutput_mesg($mesg);
+
+/*
+ * Spip
+ */
+$var=!$var;
+if ($conf->global->ADHERENT_USE_SPIP)
+{
+    $lien=img_picto($langs->trans("Active"),'tick').' ';
+    $lien.='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name=ADHERENT_USE_SPIP">'.$langs->trans("Disable").'</a>';
+    // Edition des varibales globales
+    $constantes=array(
+    	'ADHERENT_SPIP_SERVEUR',
+    	'ADHERENT_SPIP_DB',
+    	'ADHERENT_SPIP_USER',
+    	'ADHERENT_SPIP_PASS'
+	);
+
+    print_fiche_titre("SPIP CMS",$lien,'');
+    form_constantes($constantes);
+    print '<br>';
+}
+else
+{
+    $lien='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name=ADHERENT_USE_SPIP">'.$langs->trans("Activate").'</a>';
+    print_fiche_titre("SPIP - CMS",$lien,'');
+    print "<hr>\n";
+}
+
+
+dol_fiche_end();
+
+llxFooter();
+
+$db->close();
+?>

+ 166 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/agenda.php

@@ -0,0 +1,166 @@
+<?php
+/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2005      Brice Davoleau       <brice.davoleau@gmail.com>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2007      Patrick Raguin  		<patrick.raguin@gmail.com>
+ * Copyright (C) 2010      Juanjo Menent        <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       htdocs/adherents/agenda.php
+ *  \ingroup    member
+ *  \brief      Page of members events
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("companies");
+$langs->load("members");
+
+$mesg=isset($_GET["mesg"])?'<div class="ok">'.$_GET["mesg"].'</div>':'';
+
+$id = GETPOST('id','int');
+
+// Security check
+$result=restrictedArea($user,'adherent',$id);
+
+$object = new Adherent($db);
+$result=$object->fetch($id);
+if ($result > 0)
+{
+    $adht = new AdherentType($db);
+    $result=$adht->fetch($object->typeid);
+}
+
+
+/*
+ *	Actions
+ */
+
+// None
+
+
+
+/*
+ *	View
+ */
+
+$contactstatic = new Contact($db);
+
+$form = new Form($db);
+
+/*
+ * Fiche categorie de client et/ou fournisseur
+ */
+if ($id)
+{
+	require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
+	require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+
+	$langs->load("companies");
+
+	llxHeader("",$langs->trans("Agenda"),'');
+
+	if ($conf->notification->enabled) $langs->load("mails");
+	$head = member_prepare_head($object);
+
+	dol_fiche_head($head, 'agenda', $langs->trans("Member"),0,'user');
+
+	print '<table class="border" width="100%">';
+
+	// Reference
+	print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
+	print '<td colspan="3">';
+	print $form->showrefnav($object,'id');
+	print '</td>';
+	print '</tr>';
+
+	// Login
+	if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+	{
+	    print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
+	}
+
+	// Morphy
+	print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
+	/*print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
+	 print $form->showphoto('memberphoto',$member);
+	print '</td>';*/
+	print '</tr>';
+
+	// Type
+	print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
+
+	// Company
+	print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
+
+	// Civility
+	print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
+	print '</tr>';
+
+	// Lastname
+	print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur" colspan="3">'.$object->lastname.'&nbsp;</td>';
+	print '</tr>';
+
+	// Firstname
+	print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" colspan="3">'.$object->firstname.'&nbsp;</td></tr>';
+
+	// Status
+	print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
+
+	print '</table>';
+
+	print '</div>';
+
+
+	dol_htmloutput_mesg($mesg);
+
+
+    /*
+     * Barre d'action
+     */
+
+    print '<div class="tabsAction">';
+
+    if ($conf->agenda->enabled)
+    {
+        print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&socid='.$socid.'">'.$langs->trans("AddAction").'</a>';
+    }
+
+    print '</div>';
+
+    print '<br>';
+
+    print load_fiche_titre($langs->trans("ActionsOnMember"),'','');
+
+    // List of todo actions
+    show_actions_todo($conf,$langs,$db,$object);
+
+    // List of done actions
+    show_actions_done($conf,$langs,$db,$object);
+}
+
+
+
+llxFooter();
+
+$db->close();
+?>

+ 1019 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/card_subscriptions.php

@@ -0,0 +1,1019 @@
+<?php
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2012 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/adherents/card_subscriptions.php
+ *       \ingroup    member
+ *       \brief      Onglet d'ajout, edition, suppression des adhesions d'un adherent
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
+
+$langs->load("companies");
+$langs->load("bills");
+$langs->load("members");
+$langs->load("users");
+$langs->load("mails");
+
+
+$action=GETPOST('action','alpha');
+$rowid=GETPOST('rowid','int');
+$typeid=GETPOST('typeid','int');
+
+// Security check
+$result=restrictedArea($user,'adherent',$rowid);
+
+$object = new Adherent($db);
+$extrafields = new ExtraFields($db);
+$adht = new AdherentType($db);
+$errmsg='';
+
+$defaultdelay=1;
+$defaultdelayunit='y';
+
+if ($rowid)
+{
+    // Load member
+    $result = $object->fetch($rowid);
+
+    // Define variables to know what current user can do on users
+    $canadduser=($user->admin || $user->rights->user->user->creer);
+    // Define variables to know what current user can do on properties of user linked to edited member
+    if ($object->user_id)
+    {
+        // $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite
+        $caneditfielduser=( (($user->id == $object->user_id) && $user->rights->user->self->creer)
+        || (($user->id != $object->user_id) && $user->rights->user->user->creer) );
+        $caneditpassworduser=( (($user->id == $object->user_id) && $user->rights->user->self->password)
+        || (($user->id != $object->user_id) && $user->rights->user->user->password) );
+    }
+}
+
+// Define variables to know what current user can do on members
+$canaddmember=$user->rights->adherent->creer;
+// Define variables to know what current user can do on properties of a member
+if ($rowid)
+{
+    $caneditfieldmember=$user->rights->adherent->creer;
+}
+
+
+
+/*
+ * 	Actions
+ */
+
+// Create third party from a member
+if ($action == 'confirm_create_thirdparty' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)
+{
+	if ($result > 0)
+	{
+		// Creation user
+		$company = new Societe($db);
+		$result=$company->create_from_member($object,$_POST["companyname"]);
+
+		if ($result < 0)
+		{
+			$langs->load("errors");
+			$errmsg=$langs->trans($company->error);
+			$errmsgs=$company->errors;
+		}
+		else
+		{
+			$action='addsubscription';
+		}
+	}
+	else
+	{
+		$errmsg=$object->error;
+	}
+}
+
+if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
+{
+    $error=0;
+    if (empty($user->rights->user->user->creer))    // If can edit only itself user, we can link to itself only
+    {
+        if ($_POST["userid"] != $user->id && $_POST["userid"] != $object->user_id)
+        {
+            $error++;
+            $mesg='<div class="error">'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'</div>';
+        }
+    }
+
+    if (! $error)
+    {
+        if ($_POST["userid"] != $object->user_id)  // If link differs from currently in database
+        {
+            $result=$object->setUserId($_POST["userid"]);
+            if ($result < 0) dol_print_error($object->db,$object->error);
+            $_POST['action']='';
+            $action='';
+        }
+    }
+}
+
+if ($action == 'setsocid')
+{
+    $error=0;
+    if (! $error)
+    {
+        if (GETPOST('socid','int') != $object->fk_soc)    // If link differs from currently in database
+        {
+            $sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+            $sql.=" WHERE fk_soc = '".GETPOST('socid','int')."'";
+            $resql = $db->query($sql);
+            if ($resql)
+            {
+                $obj = $db->fetch_object($resql);
+                if ($obj && $obj->rowid > 0)
+                {
+                    $othermember=new Adherent($db);
+                    $othermember->fetch($obj->rowid);
+                    $thirdparty=new Societe($db);
+                    $thirdparty->fetch(GETPOST('socid','int'));
+                    $error++;
+                    $mesg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>';
+                }
+            }
+
+            if (! $error)
+            {
+                $result=$object->setThirdPartyId(GETPOST('socid','int'));
+                if ($result < 0) dol_print_error($object->db,$object->error);
+                $_POST['action']='';
+                $action='';
+            }
+        }
+    }
+}
+
+if ($user->rights->adherent->cotisation->creer && $action == 'cotisation' && ! $_POST["cancel"])
+{
+    $error=0;
+
+    $langs->load("banks");
+
+    $result=$object->fetch($rowid);
+    $result=$adht->fetch($object->typeid);
+
+    // Subscription informations
+    $datecotisation=0;
+    $datesubend=0;
+    $paymentdate=0;
+    if ($_POST["reyear"] && $_POST["remonth"] && $_POST["reday"])
+    {
+        $datecotisation=dol_mktime(0, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+    }
+    if ($_POST["endyear"] && $_POST["endmonth"] && $_POST["endday"])
+    {
+        $datesubend=dol_mktime(0, 0, 0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]);
+    }
+    if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
+    {
+        $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
+    }
+    $cotisation=$_POST["cotisation"];	// Amount of subscription
+    $label=$_POST["label"];
+
+    // Payment informations
+    $accountid=$_POST["accountid"];
+    $operation=$_POST["operation"]; // Payment mode
+    $num_chq=$_POST["num_chq"];
+    $emetteur_nom=$_POST["chqemetteur"];
+    $emetteur_banque=$_POST["chqbank"];
+    $option=$_POST["paymentsave"];
+    if (empty($option)) $option='none';
+
+    // Check parameters
+    if (! $datecotisation)
+    {
+        $error++;
+        $langs->load("errors");
+        $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateSubscription"));
+        $action='addsubscription';
+    }
+    if (GETPOST('end') && ! $datesubend)
+    {
+        $error++;
+        $langs->load("errors");
+        $errmsg=$langs->trans("ErrorBadDateFormat",$langs->transnoentitiesnoconv("DateEndSubscription"));
+        $action='addsubscription';
+    }
+    if (! $datesubend)
+    {
+        $datesubend=dol_time_plus_duree(dol_time_plus_duree($datecotisation,$defaultdelay,$defaultdelayunit),-1,'d');
+    }
+    if (($option == 'bankviainvoice' || $option == 'bankdirect') && ! $paymentdate)
+    {
+        $error++;
+        $errmsg=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DatePayment"));
+        $action='addsubscription';
+    }
+
+    // Check if a payment is mandatory or not
+    if (! $error && $adht->cotisation)	// Type adherent soumis a cotisation
+    {
+        if (! is_numeric($_POST["cotisation"]))
+        {
+            // If field is '' or not a numeric value
+            $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Amount"));
+            $error++;
+            $action='addsubscription';
+        }
+        else
+        {
+            if ($conf->banque->enabled && $_POST["paymentsave"] != 'none')
+            {
+                if ($_POST["cotisation"])
+                {
+                    if (! $_POST["label"])     $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
+                    if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["operation"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
+                    if ($_POST["paymentsave"] != 'invoiceonly' && ! $_POST["accountid"]) $errmsg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("FinancialAccount"));
+                }
+                else
+                {
+                    if ($_POST["accountid"])   $errmsg=$langs->trans("ErrorDoNotProvideAccountsIfNullAmount");
+                }
+                if ($errmsg) $action='addsubscription';
+            }
+        }
+    }
+
+    if (! $error && $action=='cotisation')
+    {
+        $db->begin();
+
+        // Create subscription
+        $crowid=$object->cotisation($datecotisation, $cotisation, $accountid, $operation, $label, $num_chq, $emetteur_nom, $emetteur_banque, $datesubend, $option);
+        if ($crowid <= 0)
+        {
+            $error++;
+            $errmsg=$object->error;
+            $errmsgs=$object->errors;
+        }
+
+        if (! $error)
+        {
+            // Insert into bank account directlty (if option choosed for) + link to llx_cotisation if option is 'bankdirect'
+            if ($option == 'bankdirect' && $accountid)
+            {
+                require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
+
+                $acct=new Account($db);
+                $result=$acct->fetch($accountid);
+
+                $dateop=$paymentdate;
+
+                $insertid=$acct->addline($dateop, $operation, $label, $cotisation, $num_chq, '', $user, $emetteur_nom, $emetteur_banque);
+                if ($insertid > 0)
+                {
+                    $inserturlid=$acct->add_url_line($insertid, $object->id, DOL_URL_ROOT.'/adherents/fiche.php?rowid=', $object->getFullname($langs), 'member');
+                    if ($inserturlid > 0)
+                    {
+                        // Met a jour la table cotisation
+                        $sql ="UPDATE ".MAIN_DB_PREFIX."cotisation SET fk_bank=".$insertid;
+                        $sql.=" WHERE rowid=".$crowid;
+
+                        dol_syslog("card_subscriptions::cotisation sql=".$sql);
+                        $resql = $db->query($sql);
+                        if (! $resql)
+                        {
+                            $error++;
+                            $errmsg=$db->lasterror();
+                        }
+                    }
+                    else
+                    {
+                        $error++;
+                        $errmsg=$acct->error;
+                    }
+                }
+                else
+                {
+                    $error++;
+                    $errmsg=$acct->error;
+                }
+            }
+
+            // If option choosed, we create invoice
+            if (($option == 'bankviainvoice' && $accountid) || $option == 'invoiceonly')
+            {
+                require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
+                require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/paymentterm.class.php");
+
+                $invoice=new Facture($db);
+                $customer=new Societe($db);
+                $result=$customer->fetch($object->fk_soc);
+                if ($result <= 0)
+                {
+                    $errmsg=$customer->error;
+                    $error++;
+                }
+
+                // Create draft invoice
+                $invoice->type=0;
+                $invoice->cond_reglement_id=$customer->cond_reglement_id;
+                if (empty($invoice->cond_reglement_id))
+                {
+                    $paymenttermstatic=new PaymentTerm($db);
+                    $invoice->cond_reglement_id=$paymenttermstatic->getDefaultId();
+                    if (empty($invoice->cond_reglement_id))
+                    {
+                        $error++;
+                        $errmsg='ErrorNoPaymentTermRECEPFound';
+                    }
+                }
+                $invoice->socid=$object->fk_soc;
+                $invoice->date=$datecotisation;
+
+                $result=$invoice->create($user);
+                if ($result <= 0)
+                {
+                    $errmsg=$invoice->error;
+                    $error++;
+                }
+
+                // Add line to draft invoice
+                $idprodsubscription=0;
+                $vattouse=get_default_tva($mysoc, $customer, $idprodsubscription);
+                //print xx".$vattouse." - ".$mysoc." - ".$customer;exit;
+                $result=$invoice->addline($invoice->id,$label,0,1,$vattouse,0,0,$idprodsubscription,0,$datecotisation,$datesubend,0,0,'','TTC',$cotisation,1);
+                if ($result <= 0)
+                {
+                    $errmsg=$invoice->error;
+                    $error++;
+                }
+
+                // Validate invoice
+                $result=$invoice->validate($user);
+
+                // Add payment onto invoice
+                if ($option == 'bankviainvoice' && $accountid)
+                {
+                    require_once(DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php');
+                    require_once(DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php');
+                    require_once(DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php');
+
+                    // Creation de la ligne paiement
+                    $amounts[$invoice->id] = price2num($cotisation);
+                    $paiement = new Paiement($db);
+                    $paiement->datepaye     = $paymentdate;
+                    $paiement->amounts      = $amounts;
+                    $paiement->paiementid   = dol_getIdFromCode($db,$operation,'c_paiement');
+                    $paiement->num_paiement = $num_chq;
+                    $paiement->note         = $label;
+
+                    if (! $error)
+                    {
+                        $paiement_id = $paiement->create($user);
+                        if (! $paiement_id > 0)
+                        {
+                            $errmsg=$paiement->error;
+                            $error++;
+                        }
+                    }
+
+                    if (! $error)
+                    {
+                        $bank_line_id=$paiement->addPaymentToBank($user,'payment','(SubscriptionPayment)',$accountid,$emetteur_nom,$emetteur_banque);
+                        if (! ($bank_line_id > 0))
+                        {
+                            $errmsg=$paiement->error;
+                            $errmsgs=$paiement->errors;
+                            $error++;
+                        }
+                    }
+
+                    if (! $error)
+                    {
+                        // Update fk_bank for subscriptions
+                        $sql = 'UPDATE '.MAIN_DB_PREFIX.'cotisation SET fk_bank='.$bank_line_id;
+                        $sql.= ' WHERE rowid='.$crowid;
+                        dol_syslog('sql='.$sql);
+                        $result = $db->query($sql);
+                        if (! $result)
+                        {
+                            $error++;
+                        }
+                    }
+                }
+            }
+        }
+
+        if (! $error)
+        {
+            $db->commit();
+        }
+        else
+        {
+            $db->rollback();
+            $action = 'addsubscription';
+        }
+
+        // Send email
+        if (! $error)
+        {
+            // Send confirmation Email
+            if ($object->email && $_POST["sendmail"])
+            {
+                $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
+                $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
+
+                $result=$object->send_an_email($texttosend,$subjecttosend,array(),array(),array(),"","",0,-1);
+                if ($result < 0) $errmsg=$object->error;
+            }
+
+            $_POST["cotisation"]='';
+            $_POST["accountid"]='';
+            $_POST["operation"]='';
+            $_POST["label"]='';
+            $_POST["num_chq"]='';
+        }
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+
+$now=dol_now();
+
+llxHeader('',$langs->trans("Subscriptions"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+if ($rowid)
+{
+    $res=$object->fetch($rowid,$ref);
+    if ($res < 0) { dol_print_error($db,$object->error); exit; }
+    //$res=$object->fetch_optionals($object->id,$extralabels);
+    //if ($res < 0) { dol_print_error($db); exit; }
+
+    $adht->fetch($object->typeid);
+
+    $head = member_prepare_head($object);
+
+    dol_fiche_head($head, 'subscription', $langs->trans("Member"), 0, 'user');
+
+    $rowspan=9;
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1;
+    if ($conf->societe->enabled) $rowspan++;
+
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="rowid" value="'.$object->id.'">';
+    print '<table class="border" width="100%">';
+
+    // Ref
+    print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
+    print '<td class="valeur" colspan="2">';
+    print $form->showrefnav($object,'rowid');
+    print '</td></tr>';
+
+    $showphoto='<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">'.$form->showphoto('memberphoto',$object).'</td>';
+
+    // Login
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td>';
+        print $showphoto; $showphoto='';
+        print '</tr>';
+    }
+
+    // Morphy
+    print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
+    print $showphoto; $showphoto='';
+    print '</tr>';
+
+    // Type
+    print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
+
+    // Company
+    print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
+
+    // Civility
+    print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
+    print '</tr>';
+
+    // Name
+    print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->lastname.'&nbsp;</td>';
+    print '</tr>';
+
+    // Firstname
+    print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$object->firstname.'&nbsp;</td>';
+    print '</tr>';
+
+    // Status
+    print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
+
+    // Date end subscription
+    print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
+    if ($object->datefin)
+    {
+        print dol_print_date($object->datefin,'day');
+        if ($object->datefin < ($now -  $conf->adherent->cotisation->warning_delay) && $object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
+    }
+    else
+    {
+        print $langs->trans("SubscriptionNotReceived");
+        if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // Affiche picto retard uniquement si non brouillon et non resilie
+    }
+    print '</td></tr>';
+
+    // Third party Dolibarr
+    if ($conf->societe->enabled)
+    {
+        print '<tr><td>';
+        print '<table class="nobordernopadding" width="100%"><tr><td>';
+        print $langs->trans("LinkedToDolibarrThirdParty");
+        print '</td>';
+        if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
+        print '</tr></table>';
+        print '</td><td class="valeur">';
+        if ($_GET['action'] == 'editthirdparty')
+        {
+            $htmlname='socid';
+            print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
+            print '<input type="hidden" name="rowid" value="'.$object->id.'">';
+            print '<input type="hidden" name="action" value="set'.$htmlname.'">';
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+            print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
+            print '<tr><td>';
+            print $form->select_company($object->fk_soc,'socid','',1);
+            print '</td>';
+            print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+            print '</tr></table></form>';
+        }
+        else
+        {
+            if ($object->fk_soc)
+            {
+                $company=new Societe($db);
+                $result=$company->fetch($object->fk_soc);
+                print $company->getNomUrl(1);
+            }
+            else
+            {
+                print $langs->trans("NoThirdPartyAssociatedToMember");
+            }
+        }
+        print '</td></tr>';
+    }
+
+    // Login Dolibarr
+    print '<tr><td>';
+    print '<table class="nobordernopadding" width="100%"><tr><td>';
+    print $langs->trans("LinkedToDolibarrUser");
+    print '</td>';
+    if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a></td>';
+    print '</tr></table>';
+    print '</td><td class="valeur">';
+    if ($_GET['action'] == 'editlogin')
+    {
+        /*$include=array();
+         if (empty($user->rights->user->user->creer))    // If can edit only itself user, we can link to itself only
+         {
+         $include=array($object->user_id,$user->id);
+         }*/
+        print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
+    }
+    else
+    {
+        if ($object->user_id)
+        {
+            print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+        }
+        else print $langs->trans("NoDolibarrAccess");
+    }
+    print '</td></tr>';
+
+    print "</table>\n";
+    print '</form>';
+
+    dol_fiche_end();
+
+
+    dol_htmloutput_errors($errmsg,$errmsgs);
+
+
+    /*
+     * Barre d'actions
+     */
+
+    // Lien nouvelle cotisation si non brouillon et non resilie
+    if ($user->rights->adherent->cotisation->creer)
+    {
+        if ($action != 'addsubscription' && $action != 'create_thirdparty')
+        {
+            print '<div class="tabsAction">';
+
+            if ($object->statut > 0) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a>";
+            else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a>';
+
+            print "<br>\n";
+
+            print '</div>';
+            print '<br>';
+        }
+    }
+
+
+    /*
+     * List of subscriptions
+     */
+    if ($action != 'addsubscription' && $action != 'create_thirdparty')
+    {
+        $sql = "SELECT d.rowid, d.prenom, d.nom, d.societe,";
+        $sql.= " c.rowid as crowid, c.cotisation,";
+        $sql.= " c.dateadh,";
+        $sql.= " c.datef,";
+        $sql.= " c.fk_bank,";
+        $sql.= " b.rowid as bid,";
+        $sql.= " ba.rowid as baid, ba.label, ba.bank";
+        $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
+        $sql.= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
+
+        $result = $db->query($sql);
+        if ($result)
+        {
+            $cotisationstatic=new Cotisation($db);
+            $accountstatic=new Account($db);
+
+            $num = $db->num_rows($result);
+            $i = 0;
+
+            print "<table class=\"noborder\" width=\"100%\">\n";
+
+            print '<tr class="liste_titre">';
+            print '<td>'.$langs->trans("Ref").'</td>';
+            print '<td align="center">'.$langs->trans("DateSubscription").'</td>';
+            print '<td align="center">'.$langs->trans("DateEnd").'</td>';
+            print '<td align="right">'.$langs->trans("Amount").'</td>';
+            if ($conf->banque->enabled)
+            {
+                print '<td align="right">'.$langs->trans("Account").'</td>';
+            }
+            print "</tr>\n";
+
+            $var=True;
+            while ($i < $num)
+            {
+                $objp = $db->fetch_object($result);
+                $var=!$var;
+                print "<tr $bc[$var]>";
+                $cotisationstatic->ref=$objp->crowid;
+                $cotisationstatic->id=$objp->crowid;
+                print '<td>'.$cotisationstatic->getNomUrl(1).'</td>';
+                print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
+                print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
+                print '<td align="right">'.price($objp->cotisation).'</td>';
+                if ($conf->banque->enabled)
+                {
+                    print '<td align="right">';
+                    if ($objp->bid)
+                    {
+                        $accountstatic->label=$objp->label;
+                        $accountstatic->id=$objp->baid;
+                        print $accountstatic->getNomUrl(1);
+                    }
+                    else
+                    {
+                        print '&nbsp;';
+                    }
+                    print '</td>';
+                }
+                print "</tr>";
+                $i++;
+            }
+            print "</table>";
+        }
+        else
+        {
+            dol_print_error($db);
+        }
+
+
+        // Link for paypal payment
+        if ($conf->paypal->enabled)
+        {
+            include_once(DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php');
+            print showPaypalPaymentUrl('membersubscription',$object->ref);
+        }
+
+    }
+
+    /*
+     * Add new subscription form
+     */
+    if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer)
+    {
+        print '<br>';
+
+        print_fiche_titre($langs->trans("NewCotisation"));
+
+        $bankdirect=0;        // Option to write to bank is on by default
+        $bankviainvoice=0;    // Option to write via invoice is on by default
+        $invoiceonly=0;
+        if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE && (empty($_POST['paymentsave']) || $_POST["paymentsave"] == 'bankdirect')) $bankdirect=1;
+        if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled && $object->fk_soc) $bankviainvoice=1;
+
+        print "\n\n<!-- Form add subscription -->\n";
+
+        if ($conf->use_javascript_ajax)
+        {
+            print "\n".'<script type="text/javascript" language="javascript">';
+            print 'jQuery(document).ready(function () {
+                        jQuery(".bankswitchclass").'.($bankdirect||$bankviainvoice||in_array(GETPOST('paymentsave'),array('bankdirect','bankviainvoice'))?'show()':'hide()').';
+                        jQuery(".bankswitchclass2").'.($bankdirect||$bankviainvoice||in_array(GETPOST('paymentsave'),array('bankdirect','bankviainvoice'))?'show()':'hide()').';
+                        jQuery("#none").click(function() {
+                            jQuery(".bankswitchclass").hide();
+                            jQuery(".bankswitchclass2").hide();
+                        });
+                        jQuery("#bankdirect").click(function() {
+                            jQuery(".bankswitchclass").show();
+                            jQuery(".bankswitchclass2").show();
+                        });
+                        jQuery("#bankviainvoice").click(function() {
+                            jQuery(".bankswitchclass").show();
+                            jQuery(".bankswitchclass2").show();
+                        });
+    	                jQuery("#invoiceonly").click(function() {
+                            jQuery(".bankswitchclass").hide();
+                            jQuery(".bankswitchclass2").hide();
+                        });
+                        jQuery("#selectoperation").change(function() {
+                            code=jQuery("#selectoperation option:selected").val();
+                            if (code == \'CHQ\')
+                            {
+                                jQuery(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
+                            	if (jQuery(\'#fieldchqemetteur\').val() == \'\')
+                            	{
+                                	jQuery(\'#fieldchqemetteur\').val(jQuery(\'#memberlabel\').val());
+                            	}
+                            }
+                            else
+                            {
+                                jQuery(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
+                            }
+                        });
+                        ';
+            if (GETPOST('paymentsave')) print 'jQuery("#'.GETPOST('paymentsave').'").attr(\'checked\',true);';
+    	    print '});';
+            print '</script>'."\n";
+        }
+
+
+		// Confirm create third party
+		if ($_GET["action"] == 'create_thirdparty')
+		{
+			$name = $object->getFullName($langs);
+			if (! empty($name))
+			{
+				if ($object->societe) $name.=' ('.$object->societe.')';
+			}
+			else
+			{
+				$name=$object->societe;
+			}
+
+			// Create a form array
+			$formquestion=array(			array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
+
+			$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
+			if ($ret == 'html') print '<br>';
+		}
+
+
+        print '<form name="cotisation" method="post" action="'.$_SERVER["PHP_SELF"].'">';
+        print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+        print '<input type="hidden" name="action" value="cotisation">';
+        print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+        print '<input type="hidden" name="memberlabel" id="memberlabel" value="'.dol_escape_htmltag($object->getFullName($langs)).'">';
+        print '<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($company->name).'">';
+        print "<table class=\"border\" width=\"100%\">\n";
+
+        $today=mktime();
+        $datefrom=0;
+        $dateto=0;
+        $paymentdate=-1;
+
+        // Date payment
+        if ($_POST["paymentyear"] && $_POST["paymentmonth"] && $_POST["paymentday"])
+        {
+            $paymentdate=dol_mktime(0, 0, 0, $_POST["paymentmonth"], $_POST["paymentday"], $_POST["paymentyear"]);
+        }
+
+        // Date start subscription
+        print '<tr><td width="30%" class="fieldrequired">'.$langs->trans("DateSubscription").'</td><td>';
+        if ($_POST["reday"])
+        {
+            $datefrom=dol_mktime(0,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
+        }
+        if (! $datefrom)
+        {
+            if ($object->datefin > 0)
+            {
+                $datefrom=dol_time_plus_duree($object->datefin,1,'d');
+            }
+            else
+            {
+                $datefrom=mktime();
+            }
+        }
+        $form->select_date($datefrom,'','','','',"cotisation");
+        print "</td></tr>";
+
+        // Date end subscription
+        if ($_POST["endday"])
+        {
+            $dateto=dol_mktime(0,0,0,$_POST["endmonth"],$_POST["endday"],$_POST["endyear"]);
+        }
+        if (! $dateto)
+        {
+            $dateto=-1;		// By default, no date is suggested
+        }
+        print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td>';
+        $form->select_date($dateto,'end','','','',"cotisation");
+        print "</td></tr>";
+
+        if ($adht->cotisation)
+        {
+            // Amount
+            print '<tr><td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="cotisation" size="6" value="'.$_POST["cotisation"].'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
+
+            // Label
+            print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td>';
+            print '<td><input name="label" type="text" size="32" value="'.$langs->trans("Subscription").' ';
+            print dol_print_date(($datefrom?$datefrom:time()),"%Y").'" ></td></tr>';
+
+            // Complementary action
+            if ($conf->banque->enabled || $conf->facture->enabled)
+            {
+                $company=new Societe($db);
+                if ($object->fk_soc)
+                {
+                    $result=$company->fetch($object->fk_soc);
+                }
+
+                // Title payments
+                //print '<tr><td colspan="2"><b>'.$langs->trans("Payment").'</b></td></tr>';
+
+                // Define a way to write payment
+                print '<tr><td valign="top" class="fieldrequired">'.$langs->trans('MoreActions');
+                print '</td>';
+                print '<td>';
+                print '<input type="radio" class="moreaction" id="none" name="paymentsave" value="none"'.(!$bankdirect&&!$bankviainvoice?' checked="checked"':'').'> '.$langs->trans("None").'<br>';
+                if ($conf->banque->enabled)
+                {
+                    print '<input type="radio" class="moreaction" id="bankdirect" name="paymentsave" value="bankdirect"'.($bankdirect?' checked="checked"':'');
+                    print '> '.$langs->trans("MoreActionBankDirect").'<br>';
+                }
+                if ($conf->societe->enabled && $conf->facture->enabled)
+                {
+                    print '<input type="radio" class="moreaction" id="invoiceonly" name="paymentsave" value="invoiceonly"'.($invoiceonly?' checked="checked"':'');
+                    if (empty($object->fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"';
+                    print '> '.$langs->trans("MoreActionInvoiceOnly");
+                    if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
+                    else
+                    {
+                    	print ' ('.$langs->trans("NoThirdPartyAssociatedToMember");
+                    	print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
+                    	print $langs->trans("CreateDolibarrThirdParty");
+                    	print '</a>)';
+                    }
+                    print '<br>';
+                }
+                if ($conf->banque->enabled && $conf->societe->enabled && $conf->facture->enabled)
+                {
+                    print '<input type="radio" class="moreaction" id="bankviainvoice" name="paymentsave" value="bankviainvoice"'.($bankviainvoice?' checked="checked"':'');
+                    if (empty($object->fk_soc) || empty($bankviainvoice)) print ' disabled="disabled"';
+                    print '> '.$langs->trans("MoreActionBankViaInvoice");
+                    if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
+                    else
+                    {
+                    	print ' ('.$langs->trans("NoThirdPartyAssociatedToMember");
+                    	print ' - <a href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">';
+                    	print $langs->trans("CreateDolibarrThirdParty");
+                    	print '</a>)';
+                    }
+                    print '<br>';
+                }
+                print '</td></tr>';
+
+                // Bank account
+                print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
+                $form->select_comptes($_POST["accountid"],'accountid',0,'',1);
+                print "</td></tr>\n";
+
+                // Payment mode
+                print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
+                $form->select_types_paiements($_POST["operation"],'operation','',2);
+                print "</td></tr>\n";
+
+                // Date of payment
+                print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
+                $form->select_date($paymentdate?$paymentdate:-1,'payment',0,0,1,'cotisation',1,1);
+                print "</td></tr>\n";
+
+                print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
+                print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
+                print '</td>';
+                print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(empty($_POST['num_chq'])?'':$_POST['num_chq']).'"></td></tr>';
+
+                print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
+                print ' <em>('.$langs->trans("ChequeMaker").')</em>';
+                print '</td>';
+                print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(empty($_POST['chqemetteur'])?$facture->client->name:$_POST['chqemetteur']).'"></td></tr>';
+
+                print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
+                print ' <em>('.$langs->trans("ChequeBank").')</em>';
+                print '</td>';
+                print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(empty($_POST['chqbank'])?'':$_POST['chqbank']).'"></td></tr>';
+            }
+        }
+
+        print '<tr><td colspan="2">&nbsp;</td>';
+
+        print '<tr><td width="30%">'.$langs->trans("SendAcknowledgementByMail").'</td>';
+        print '<td>';
+        if (! $object->email)
+        {
+            print $langs->trans("NoEMail");
+        }
+        else
+        {
+            $adht = new AdherentType($db);
+            $adht->fetch($object->typeid);
+
+            $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT);
+            $texttosend=$object->makeSubstitution($adht->getMailOnSubscription());
+
+            $tmp='<input name="sendmail" type="checkbox"'.((isset($_POST["sendmail"])?$_POST["sendmail"]:$conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL)?' checked="checked"':'').'>';
+            $helpcontent='';
+            $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
+            $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
+            $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
+            $helpcontent.=$subjecttosend."\n";
+            $helpcontent.="<br>";
+            $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
+            $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
+
+            print $form->textwithpicto($tmp,$helpcontent,1,'help');
+        }
+        print '</td></tr>';
+        print '</table>';
+        print '<br>';
+
+        print '<center>';
+        print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
+        print ' &nbsp; &nbsp; ';
+        print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+        print '</center>';
+
+        print '</form>';
+
+        print "\n<!-- End form subscription -->\n\n";
+    }
+
+    //print '</td></tr>';
+    //print '</table>';
+}
+else
+{
+    $langs->load("errors");
+    print $langs->trans("ErrorRecordNotFound");
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 224 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/cartes/carte.php

@@ -0,0 +1,224 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file 		htdocs/adherents/cartes/carte.php
+ *	\ingroup    member
+ *	\brief      Page to output members business cards
+ */
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/modules/member/cards/modules_cards.php");
+require_once(DOL_DOCUMENT_ROOT."/core/modules/member/labels/modules_labels.php");
+
+$langs->load("members");
+$langs->load("errors");
+
+// Choix de l'annee d'impression ou annee courante.
+$now = dol_now();
+$year=dol_print_date($now,'%Y');
+$month=dol_print_date($now,'%m');
+$day=dol_print_date($now,'%d');
+$foruserid=GETPOST('foruserid');
+$foruserlogin=GETPOST('foruserlogin');
+$mode=GETPOST('mode');
+
+$mesg='';
+
+
+/*
+ * View
+ */
+
+if ($mode == 'cardlogin' && empty($foruserlogin))
+{
+    $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Login"));
+}
+
+if ((! empty($foruserid) || ! empty($foruserlogin) || ! empty($mode)) && ! $mesg)
+{
+    $arrayofmembers=array();
+
+    // requete en prenant que les adherents a jour de cotisation
+    $sql = "SELECT d.rowid, d.prenom as firstname, d.nom as lastname, d.login, d.societe, d.datefin,";
+    $sql.= " d.adresse, d.cp, d.ville, d.naiss, d.email, d.photo,";
+    $sql.= " t.libelle as type,";
+    $sql.= " p.libelle as pays";
+    $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
+    $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
+    $sql.= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
+    if (is_numeric($foruserid)) $sql.=" AND d.rowid=".$foruserid;
+    if ($foruserlogin) $sql.=" AND d.login='".$db->escape($foruserlogin)."'";
+    $sql.= " ORDER BY d.rowid ASC";
+
+    $result = $db->query($sql);
+    if ($result)
+    {
+    	$num = $db->num_rows($result);
+    	$i = 0;
+    	while ($i < $num)
+    	{
+    		$objp = $db->fetch_object($result);
+
+    		if ($objp->pays == '-') $objp->pays='';
+
+    		// List of values to scan for a replacement
+            $substitutionarray = array (
+            '%PRENOM%'=>$objp->firstname,
+            '%NOM%'=>$objp->lastname,
+            '%LOGIN%'=>$objp->login,
+            '%SERVEUR%'=>"http://".$_SERVER["SERVER_NAME"]."/",
+            '%SOCIETE%'=>$objp->societe,
+            '%ADRESSE%'=>$objp->adresse,
+            '%CP%'=>$objp->cp,
+            '%VILLE%'=>$objp->ville,
+            '%PAYS%'=>$objp->pays,
+            '%EMAIL%'=>$objp->email,
+            '%NAISS%'=>dol_print_date($objp->naiss,'day'),
+            '%TYPE%'=>$objp->type,
+            '%ID%'=>$objp->rowid,
+            '%ANNEE%'=>$year,    // For backward compatibility
+            '%YEAR%'=>$year,
+            '%MONTH%'=>$month,
+            '%DAY%'=>$day
+            );
+            complete_substitutions_array($substitutionarray, $langs);
+
+            // For business cards
+            if (empty($mode) || $mode=='card' || $mode=='cardlogin')
+            {
+                $textleft=make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
+                $textheader=make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
+                $textfooter=make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
+                $textright=make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
+
+                if (is_numeric($foruserid) || $foruserlogin)
+                {
+                    for($j=0;$j<100;$j++)
+                    {
+                        $arrayofmembers[]=array('textleft'=>$textleft,
+                                        'textheader'=>$textheader,
+                                        'textfooter'=>$textfooter,
+                                        'textright'=>$textright,
+                                        'id'=>$objp->rowid,
+                                        'photo'=>$objp->photo);
+                    }
+                }
+                else
+                {
+                    $arrayofmembers[]=array('textleft'=>$textleft,
+                                        'textheader'=>$textheader,
+                                        'textfooter'=>$textfooter,
+                                        'textright'=>$textright,
+                                        'id'=>$objp->rowid,
+                                        'photo'=>$objp->photo);
+                }
+            }
+
+            // For labels
+            if ($mode == 'label')
+            {
+                $conf->global->ADHERENT_ETIQUETTE_TEXT="%PRENOM% %NOM%\n%ADRESSE%\n%CP% %VILLE%\n%PAYS%";
+                $textleft=make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
+                $textheader='';
+                $textfooter='';
+                $textright='';
+
+                $arrayofmembers[]=array('textleft'=>$textleft,
+                                        'textheader'=>$textheader,
+                                        'textfooter'=>$textfooter,
+                                        'textright'=>$textright,
+                                        'id'=>$objp->rowid,
+                                        'photo'=>$objp->photo);
+            }
+
+            $i++;
+    	}
+
+    	// Build and output PDF
+        if (empty($mode) || $mode=='card' || $mode=='cardlogin')
+        {
+            if (! count($arrayofmembers))
+            {
+                $mesg=$langs->trans("ErrorRecordNotFound");
+            }
+
+            if (! $mesg) $result=members_card_pdf_create($db, $arrayofmembers, '', $outputlangs);
+
+        }
+        elseif ($mode == 'label')
+        {
+            $result=members_label_pdf_create($db, $arrayofmembers, '', $outputlangs);
+        }
+
+    	if ($result <= 0)
+    	{
+    		dol_print_error('',$result);
+    	}
+    }
+    else
+    {
+    	dol_print_error($db);
+    }
+
+    if (! $mesg) exit;
+}
+
+
+
+
+
+llxHeader('',$langs->trans("MembersCards"));
+
+print_fiche_titre($langs->trans("LinkToGeneratedPages"));
+print '<br>';
+
+print $langs->trans("LinkToGeneratedPagesDesc").'<br>';
+print '<br>';
+
+dol_htmloutput_errors($mesg);
+
+print $langs->trans("DocForAllMembersCards",($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' ';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="foruserid" value="all">';
+print '<input type="hidden" name="mode" value="card">';
+print ' <input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
+print '</form>';
+print '<br>';
+
+print $langs->trans("DocForOneMemberCards",($conf->global->ADHERENT_CARD_TYPE?$conf->global->ADHERENT_CARD_TYPE:$langs->transnoentitiesnoconv("None"))).' ';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="mode" value="cardlogin">';
+print $langs->trans("Login").': <input size="10" type="text" name="foruserlogin" value="'.GETPOST('foruserlogin').'">';
+print ' <input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
+print '</form>';
+print '<br>';
+
+print $langs->trans("DocForLabels",$conf->global->ADHERENT_ETIQUETTE_TYPE).' ';
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="mode" value="label">';
+print ' <input class="button" type="submit" value="'.$langs->trans("BuildDoc").'">';
+print '</form>';
+print '<br>';
+
+llxFooter();
+
+$db->close();
+?>

+ 1 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/cartes/index.php

@@ -0,0 +1 @@
+Url not available

+ 2137 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/class/adherent.class.php

@@ -0,0 +1,2137 @@
+<?php
+/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2009      Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/adherents/class/adherent.class.php
+ *	\ingroup    member
+ *	\brief      File of class to manage members of a foundation
+ */
+
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
+
+
+/**
+ *      \class      Adherent
+ *		\brief      Class to manage members of a foundation
+ */
+class Adherent extends CommonObject
+{
+    public $element='member';
+    public $table_element='adherent';
+    protected $ismultientitymanaged = 1;  // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
+
+    var $id;
+    var $ref;
+    var $civilite_id;
+    var $firstname;
+    var $prenom;                // deprecated
+    var $lastname;
+    var $nom;                   // deprecated
+    var $login;
+    var $pass;
+    var $societe;
+    var $adresse;
+    var $address;
+    var $cp;
+    var $zip;
+    var $ville;
+    var $town;
+
+    var $state_id;              // Id of department
+    var $state_code;            // Code of department
+    var $state;                 // Label of department
+    var $fk_departement;		// deprecated
+    var $departement_code;		// deprecated
+    var $departement;			// deprecated
+
+    var $country_id;
+    var $country_code;
+    var $country;
+    var $pays_id;              // deprecated
+    var $pays_code;            // deprecated
+    var $pays;                 // deprecated
+
+    var $email;
+    var $phone;
+    var $phone_perso;
+    var $phone_mobile;
+
+    var $morphy;
+    var $public;
+    var $note;				// Private note
+    var $statut;			// -1:brouillon, 0:resilie, >=1:valide,paye
+    var $photo;
+
+    var $datec;
+    var $datem;
+    var $datefin;
+    var $datevalid;
+    var $naiss;
+
+    var $typeid;			// Id type adherent
+    var $type;				// Libelle type adherent
+    var $need_subscription;
+
+    var $user_id;
+    var $user_login;
+
+    var $fk_soc;
+
+    // Fields loaded by fetch_subscriptions()
+    var $first_subscription_date;
+    var $first_subscription_amount;
+    var $last_subscription_date;
+    var $last_subscription_amount;
+    var $subscriptions=array();
+
+    //  var $public;
+    var $array_options;
+
+    var $oldcopy;		// To contains a clone of this when we need to save old properties of object
+
+
+    /**
+	 *	Constructor
+	 *
+	 *	@param 		DoliDB		$db		Database handler
+     */
+    function Adherent($db)
+    {
+        $this->db = $db;
+        $this->statut = -1;
+        // l'adherent n'est pas public par defaut
+        $this->public = 0;
+        // les champs optionnels sont vides
+        $this->array_options=array();
+    }
+
+
+    /**
+     *  Fonction envoyant un email a l'adherent avec le texte fourni en parametre.
+     *
+     *  @param	string	$text				Content of message (not html entities encoded)
+     *  @param	string	$subject			Subject of message
+     *  @param 	array	$filename_list      Array of attached files
+     *  @param 	array	$mimetype_list      Array of mime types of attached files
+     *  @param 	array	$mimefilename_list  Array of public names of attached files
+     *  @param 	string	$addr_cc            Email cc
+     *  @param 	string	$addr_bcc           Email bcc
+     *  @param 	int		$deliveryreceipt	Ask a delivery receipt
+     *  @param	int		$msgishtml			1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection
+     *  @param	string	$errors_to			erros to
+     *  @return	int							<0 if KO, >0 if OK
+     */
+    function send_an_email($text, $subject, $filename_list=array(), $mimetype_list=array(), $mimefilename_list=array(), $addr_cc="", $addr_bcc="", $deliveryreceipt=0, $msgishtml=-1, $errors_to='')
+    {
+        global $conf,$langs;
+
+        // Detect if message is HTML
+        if ($msgishtml == -1)
+        {
+            $msgishtml = 0;
+            if (dol_textishtml($text,1)) $msgishtml = 1;
+        }
+
+        $texttosend=$this->makeSubstitution($text);
+        $subjecttosend=$this->makeSubstitution($subject);
+        if ($msgishtml) $texttosend=dol_htmlentitiesbr($texttosend);
+
+        // Envoi mail confirmation
+        $from=$conf->email_from;
+        if ($conf->global->ADHERENT_MAIL_FROM) $from=$conf->global->ADHERENT_MAIL_FROM;
+
+        include_once(DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
+        $mailfile = new CMailFile($subjecttosend, $this->email, $from, $texttosend, $filename_list, $mimetype_list, $mimefilename_list, $addr_cc, $addr_bcc, $deliveryreceipt, $msgishtml);
+        if ($mailfile->sendfile())
+        {
+            return 1;
+        }
+        else
+        {
+            $this->error=$langs->trans("ErrorFailedToSendMail",$from,$this->email).'. '.$mailfile->error;
+            return -1;
+        }
+    }
+
+
+    /**
+     * Make substitution
+     *
+     * @param	string	$text       Text to make substitution to
+     * @return  string      		Value of input text string with substitutions done
+     */
+	function makeSubstitution($text)
+	{
+		global $conf,$langs;
+
+		$birthday = dol_print_date($this->naiss,'day');
+
+		$msgishtml = 0;
+		if (dol_textishtml($text,1)) $msgishtml = 1;
+
+		$infos='';
+		if ($this->civilite_id) $infos.= $langs->transnoentities("UserTitle").": ".$this->getCivilityLabel(1)."\n";
+		$infos.= $langs->transnoentities("id").": ".$this->id."\n";
+		$infos.= $langs->transnoentities("Lastname").": ".$this->lastname."\n";
+		$infos.= $langs->transnoentities("Firstname").": ".$this->firstname."\n";
+		$infos.= $langs->transnoentities("Company").": ".$this->societe."\n";
+		$infos.= $langs->transnoentities("Address").": ".$this->address."\n";
+		$infos.= $langs->transnoentities("Zip").": ".$this->zip."\n";
+		$infos.= $langs->transnoentities("Town").": ".$this->town."\n";
+		$infos.= $langs->transnoentities("Country").": ".$this->country."\n";
+		$infos.= $langs->transnoentities("EMail").": ".$this->email."\n";
+		if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+		{
+		    $infos.= $langs->transnoentities("Login").": ".$this->login."\n";
+		    $infos.= $langs->transnoentities("Password").": ".$this->pass."\n";
+		}
+		$infos.= $langs->transnoentities("Birthday").": ".$birthday."\n";
+		$infos.= $langs->transnoentities("Photo").": ".$this->photo."\n";
+		$infos.= $langs->transnoentities("Public").": ".yn($this->public);
+
+		// Substitutions
+		$substitutionarray=array(
+				'%DOL_MAIN_URL_ROOT%'=>DOL_MAIN_URL_ROOT,
+				'%ID%'=>$msgishtml?dol_htmlentitiesbr($this->id):$this->id,
+				'%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos,
+				'%CIVILITE%'=>$this->getCivilityLabel($msgishtml?0:1),
+				'%PRENOM%'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname,
+				'%NOM%'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname,
+				'%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe,
+				'%ADRESSE%'=>$msgishtml?dol_htmlentitiesbr($this->address):$this->address,
+				'%CP%'=>$msgishtml?dol_htmlentitiesbr($this->zip):$this->zip,
+				'%VILLE%'=>$msgishtml?dol_htmlentitiesbr($this->town):$this->town,
+				'%PAYS%'=>$msgishtml?dol_htmlentitiesbr($this->country):$this->country,
+				'%EMAIL%'=>$msgishtml?dol_htmlentitiesbr($this->email):$this->email,
+				'%NAISS%'=>$msgishtml?dol_htmlentitiesbr($birthday):$birthday,
+				'%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo,
+				'%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login,
+				'%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass
+		);
+
+		complete_substitutions_array($substitutionarray, $langs);
+
+		return make_substitutions($text,$substitutionarray);
+	}
+
+
+    /**
+     *	Renvoie le libelle traduit de la nature d'un adherent (physique ou morale)
+     *
+     *	@param	string		$morphy		Nature physique ou morale de l'adherent
+     *	@return	string					Label
+     */
+    function getmorphylib($morphy='')
+    {
+        global $langs;
+        if (! $morphy) { $morphy=$this->morphy; }
+        if ($morphy == 'phy') { return $langs->trans("Physical"); }
+        if ($morphy == 'mor') { return $langs->trans("Moral"); }
+        return $morphy;
+    }
+
+    /**
+     *	Create a member into database
+     *
+     *	@param	User	$user        	Objet user qui demande la creation
+     *	@param  int		$notrigger		1 ne declenche pas les triggers, 0 sinon
+     *	@return	int						<0 if KO, >0 if OK
+     */
+    function create($user,$notrigger=0)
+    {
+        global $conf,$langs;
+
+		$error=0;
+
+        $now=dol_now();
+
+        // Check parameters
+        if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
+        {
+            $langs->load("errors");
+            $this->error = $langs->trans("ErrorBadEMail",$this->email);
+            return -1;
+        }
+        if (! $this->datec) $this->datec=$now;
+        if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+        {
+            if (empty($this->login))
+            {
+                $this->error = $langs->trans("ErrorWrongValueForParameterX","Login");
+                return -1;
+            }
+        }
+
+        $this->db->begin();
+
+        // Insert member
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent";
+        $sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type,entity)";
+        $sql.= " VALUES (";
+        $sql.= " '".$this->db->idate($this->datec)."'";
+        $sql.= ", ".($this->login?"'".$this->db->escape($this->login)."'":"null");
+        $sql.= ", ".($user->id>0?$user->id:"null");	// Can be null because member can be createb by a guest or a script
+        $sql.= ", null, null, '".$this->morphy."'";
+        $sql.= ", '".$this->typeid."'";
+        $sql.= ", ".$conf->entity;
+        $sql.= ")";
+
+        dol_syslog(get_class($this)."::create sql=".$sql);
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent");
+            if ($id > 0)
+            {
+                $this->id=$id;
+                $this->ref=$id;
+
+                // Update minor fields
+                $result=$this->update($user,1,1); // nosync is 1 to avoid update data of user
+                if ($result < 0)
+                {
+                    $this->db->rollback();
+                    return -1;
+                }
+
+                // Add link to user
+                if ($this->user_id)
+                {
+                    // Add link to user
+                    $sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
+                    $sql.= " fk_member = '".$this->id."'";
+                    $sql.= " WHERE rowid = ".$this->user_id;
+                    dol_syslog(get_class($this)."::create sql=".$sql);
+                    $resql = $this->db->query($sql);
+                    if (! $resql)
+                    {
+                        $this->error='Failed to update user to make link with member';
+                        $this->db->rollback();
+                        return -4;
+                    }
+                }
+
+                if (! $notrigger)
+                {
+                    // Appel des triggers
+                    include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+                    $interface=new Interfaces($this->db);
+                    $result=$interface->run_triggers('MEMBER_CREATE',$this,$user,$langs,$conf);
+                    if ($result < 0) { $error++; $this->errors=$interface->errors; }
+                    // Fin appel triggers
+                }
+
+                if (count($this->errors))
+                {
+                    dol_syslog(get_class($this)."::create ".join(',',$this->errors), LOG_ERR);
+                    $this->db->rollback();
+                    return -3;
+                }
+                else
+                {
+                    $this->db->commit();
+                    return $this->id;
+                }
+            }
+            else
+            {
+                $this->error='Failed to get last insert id';
+                dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+                $this->db->rollback();
+                return -2;
+            }
+        }
+        else
+        {
+            $this->error=$this->db->error();
+            dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+
+    /**
+     *	Update a member in database (standard information and password)
+     *
+     *	@param	User	$user				User making update
+     *	@param	int		$notrigger			1=disable trigger UPDATE (when called by create)
+     *	@param	int		$nosyncuser			0=Synchronize linked user (standard info), 1=Do not synchronize linked user
+     *	@param	int		$nosyncuserpass		0=Synchronize linked user (password), 1=Do not synchronize linked user
+     *	@param	int		$nosyncthirdparty	0=Synchronize linked thirdparty (standard info), 1=Do not synchronize linked thirdparty
+     * 	@return	int							<0 if KO, >0 if OK
+     */
+    function update($user,$notrigger=0,$nosyncuser=0,$nosyncuserpass=0,$nosyncthirdparty=0)
+    {
+        global $conf, $langs;
+
+        $nbrowsaffected=0;
+        $error=0;
+
+        dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email);
+
+        // Clean parameters
+		$this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->nom);
+		$this->firstname=trim($this->firstname)?trim($this->firstname):trim($this->prenom);
+		$this->address=($this->address?$this->address:$this->adresse);
+		$this->zip=($this->zip?$this->zip:$this->cp);
+		$this->town=($this->town?$this->town:$this->ville);
+		$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
+		$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
+		if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname));
+        if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname));
+
+        // Check parameters
+        if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
+        {
+            $langs->load("errors");
+            $this->error = $langs->trans("ErrorBadEMail",$this->email);
+            return -1;
+        }
+
+        $this->db->begin();
+
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+        $sql.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null");
+        $sql.= ", prenom = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
+        $sql.= ", nom="     .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
+        $sql.= ", login="   .($this->login?"'".$this->db->escape($this->login)."'":"null");
+        $sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
+        $sql.= ", fk_soc="  .($this->fk_soc > 0?"'".$this->fk_soc."'":"null");
+        $sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
+        $sql.= ", cp="      .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
+        $sql.= ", ville="   .($this->town?"'".$this->db->escape($this->town)."'":"null");
+        $sql.= ", pays="          .($this->country_id>0?"'".$this->country_id."'":"null");
+        $sql.= ", fk_departement=".($this->state_id>0?"'".$this->state_id."'":"null");
+        $sql.= ", email='".$this->email."'";
+        $sql.= ", phone="   .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
+        $sql.= ", phone_perso="  .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
+        $sql.= ", phone_mobile=" .($this->phone_mobile?"'".$this->db->escape($this->phone_mobile)."'":"null");
+        $sql.= ", note="    .($this->note?"'".$this->db->escape($this->note)."'":"null");
+        $sql.= ", photo="   .($this->photo?"'".$this->photo."'":"null");
+        $sql.= ", public='".$this->public."'";
+        $sql.= ", statut="  .$this->statut;
+        $sql.= ", fk_adherent_type=".$this->typeid;
+        $sql.= ", morphy='".$this->morphy."'";
+        $sql.= ", naiss="   .($this->naiss?"'".$this->db->idate($this->naiss)."'":"null");
+        if ($this->datefin)   $sql.= ", datefin='".$this->db->idate($this->datefin)."'";		// Ne doit etre modifie que par effacement cotisation
+        if ($this->datevalid) $sql.= ", datevalid='".$this->db->idate($this->datevalid)."'";	// Ne doit etre modifie que par validation adherent
+        $sql.= ", fk_user_mod=".($user->id>0?$user->id:'null');	// Can be null because member can be create by a guest
+        $sql.= " WHERE rowid = ".$this->id;
+
+        dol_syslog(get_class($this)."::update update member sql=".$sql);
+        $resql = $this->db->query($sql);
+        if ($resql)
+        {
+		    unset($this->country_code);
+		    unset($this->country);
+		    unset($this->state_code);
+		    unset($this->state);
+
+		    $nbrowsaffected+=$this->db->affected_rows($resql);
+
+            // Actions on extra fields (by external module)
+            include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+            $hookmanager=new HookManager($this->db);
+            $hookmanager->initHooks(array('memberdao'));
+            $parameters=array('id'=>$this->id);
+            $action='';
+            $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action);    // Note that $action and $object may have been modified by some hooks
+            if (empty($reshook))
+            {
+                $result=$this->insertExtraFields();
+                if ($result < 0)
+                {
+                    $error++;
+                }
+            }
+            else if ($reshook < 0) $error++;
+
+            // Update password
+            if (! $error && $this->pass)
+            {
+                dol_syslog(get_class($this)."::update update password");
+                if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted)
+                {
+                    // Si mot de passe saisi et different de celui en base
+                    $result=$this->setPassword($user,$this->pass,0,$notrigger,$nosyncuserpass);
+                    if (! $nbrowsaffected) $nbrowsaffected++;
+                }
+            }
+
+            // Remove links to user and replace with new one
+            if (! $error)
+            {
+                dol_syslog(get_class($this)."::update update link to user");
+                $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
+                dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
+                $resql = $this->db->query($sql);
+                if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
+                // If there is a user linked to this member
+                if ($this->user_id > 0)
+                {
+                    $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id." WHERE rowid = ".$this->user_id;
+                    dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
+                    $resql = $this->db->query($sql);
+                    if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -5; }
+                }
+            }
+
+            if (! $error && $nbrowsaffected)	// If something has change in main data
+            {
+                // Update information on linked user if it is an update
+                if ($this->user_id > 0 && ! $nosyncuser)
+                {
+                    require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
+
+                    dol_syslog(get_class($this)."::update update linked user");
+
+                    $luser=new User($this->db);
+                    $result=$luser->fetch($this->user_id);
+
+                    if ($result >= 0)
+                    {
+                        $luser->civilite_id=$this->civilite_id;
+                        $luser->firstname=$this->firstname;
+                        $luser->lastname=$this->lastname;
+                        $luser->prenom=$this->firstname;    // deprecated
+                        $luser->nom=$this->lastname;        // deprecated
+                        $luser->login=$this->user_login;
+                        $luser->pass=$this->pass;
+                        $luser->societe_id=$this->societe;
+
+                        $luser->email=$this->email;
+                        $luser->office_phone=$this->phone;
+                        $luser->user_mobile=$this->phone_mobile;
+
+                        $luser->note=$this->note;
+
+                        $luser->fk_member=$this->id;
+
+                        $result=$luser->update($user,0,1,1);	// Use nosync to 1 to avoid cyclic updates
+                        if ($result < 0)
+                        {
+                            $this->error=$luser->error;
+                            dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR);
+                            $error++;
+                        }
+                    }
+                    else
+                    {
+                        $this->error=$luser->error;
+                        $error++;
+                    }
+                }
+
+                // Update information on linked thirdparty if it is an update
+                if ($this->fk_soc > 0 && ! $nosyncthirdparty)
+                {
+                    require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
+
+                    dol_syslog(get_class($this)."::update update linked thirdparty");
+
+                    // This member is linked with a thirdparty, so we also update thirdparty informations
+                    // if this is an update.
+                    $lthirdparty=new Societe($this->db);
+                    $result=$lthirdparty->fetch($this->fk_soc);
+
+                    if ($result >= 0)
+                    {
+                        $lthirdparty->address=$this->address;
+                        $lthirdparty->zip=$this->zip;
+                        $lthirdparty->town=$this->town;
+                        $lthirdparty->email=$this->email;
+                        $lthirdparty->tel=$this->phone;
+                        $lthirdparty->state_id=$this->state_id;
+                        $lthirdparty->country_id=$this->country_id;
+                        $lthirdparty->pays_id=$this->country_id;
+                        //$lthirdparty->phone_mobile=$this->phone_mobile;
+
+                        $result=$lthirdparty->update($this->fk_soc,$user,0,1,1,'update');	// Use sync to 0 to avoid cyclic updates
+                        if ($result < 0)
+                        {
+                            $this->error=$lthirdparty->error;
+                            dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR);
+                            $error++;
+                        }
+                    }
+                    else
+                    {
+                        $this->error=$lthirdparty->error;
+                        $error++;
+                    }
+                }
+
+                if (! $error && ! $notrigger)
+                {
+                    // Appel des triggers
+                    include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+                    $interface=new Interfaces($this->db);
+                    $result=$interface->run_triggers('MEMBER_MODIFY',$this,$user,$langs,$conf);
+                    if ($result < 0) { $error++; $this->errors=$interface->errors; }
+                    // Fin appel triggers
+                }
+            }
+
+            if (! $error)
+            {
+                $this->db->commit();
+                return $nbrowsaffected;
+            }
+            else
+            {
+                $this->db->rollback();
+                return -1;
+            }
+        }
+        else
+        {
+            $this->db->rollback();
+            $this->error=$this->db->lasterror();
+            dol_syslog(get_class($this)."::Update ".$this->error,LOG_ERR);
+            return -2;
+        }
+    }
+
+
+    /**
+     *	Update denormalized last subscription date.
+     * 	This function is called when we delete a subscription for example.
+     *
+     *	@param	User	$user			User making change
+     *	@return	int						<0 if KO, >0 if OK
+     */
+    function update_end_date($user)
+    {
+        global $conf, $langs;
+
+        $error=0;
+
+        $this->db->begin();
+
+        // Search for last subscription id and end date
+        $sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
+        $sql.= " FROM ".MAIN_DB_PREFIX."cotisation";
+        $sql.= " WHERE fk_adherent='".$this->id."'";
+        $sql.= " ORDER by dateadh DESC";	// Sort by start subscription date
+
+        dol_syslog(get_class($this)."::update_end_date sql=".$sql);
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            $obj=$this->db->fetch_object($resql);
+            $dateop=$this->db->jdate($obj->dateop);
+            $datedeb=$this->db->jdate($obj->datedeb);
+            $datefin=$this->db->jdate($obj->datefin);
+
+            $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+            $sql.= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null");
+            $sql.= " WHERE rowid = ".$this->id;
+
+            dol_syslog(get_class($this)."::update_end_date sql=".$sql);
+            $resql=$this->db->query($sql);
+            if ($resql)
+            {
+                $this->last_subscription_date=$dateop;
+                $this->last_subscription_date_start=$datedeb;
+                $this->last_subscription_date_end=$datefin;
+                $this->datefin=$datefin;
+                $this->db->commit();
+                return 1;
+            }
+            else
+            {
+                $this->db->rollback();
+                return -1;
+            }
+        }
+        else
+        {
+            $this->error=$this->db->lasterror();
+            dol_syslog(get_class($this)."::update_end_date ".$this->error, LOG_ERR);
+            $this->db->rollback();
+            return -1;
+        }
+
+    }
+
+    /**
+     *  Fonction qui supprime l'adherent et les donnees associees
+     *
+     *  @param	int		$rowid		Id of member to delete
+     *  @return	int					<0 if KO, 0=nothing to do, >0 if OK
+     */
+    function delete($rowid)
+    {
+        global $conf, $langs, $user;
+
+        $result = 0;
+		$error=0;
+
+        $this->db->begin();
+
+        // Suppression options
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_extrafields WHERE fk_object = ".$rowid;
+
+        dol_syslog(get_class($this)."::delete sql=".$sql);
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
+            dol_syslog(get_class($this)."::delete sql=".$sql);
+            $resql=$this->db->query($sql);
+
+            $sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE fk_adherent = ".$rowid;
+            dol_syslog(get_class($this)."::delete sql=".$sql);
+            $resql=$this->db->query($sql);
+            if ($resql)
+            {
+            	// Remove linked user
+            	$ret=$this->setUserId(0);
+            	if ($ret > 0)
+            	{
+            		$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent WHERE rowid = ".$rowid;
+            		dol_syslog(get_class($this)."::delete sql=".$sql);
+            		$resql=$this->db->query($sql);
+            		if ($resql)
+            		{
+            			if ($this->db->affected_rows($resql))
+            			{
+            				// Appel des triggers
+            				include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+            				$interface=new Interfaces($this->db);
+            				$result=$interface->run_triggers('MEMBER_DELETE',$this,$user,$langs,$conf);
+            				if ($result < 0) {
+            					$error++; $this->errors=$interface->errors;
+            				}
+            				// Fin appel triggers
+
+            				$this->db->commit();
+            				return 1;
+            			}
+            			else
+            			{
+            				// Rien a effacer
+            				$this->db->rollback();
+            				return 0;
+            			}
+            		}
+            		else
+            		{
+            			$this->error=$this->db->error();
+            			$this->db->rollback();
+            			return -3;
+            		}
+            	}
+            }
+            else
+            {
+                $this->error=$this->db->error();
+                $this->db->rollback();
+                return -2;
+            }
+        }
+        else
+        {
+            $this->error=$this->db->error();
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+
+    /**
+     *    Change password of a user
+     *
+     *    @param	User	$user           Object user de l'utilisateur qui fait la modification
+     *    @param 	string	$password       New password (to generate if empty)
+     *    @param    int		$isencrypted    0 ou 1 si il faut crypter le mot de passe en base (0 par defaut)
+     *	  @param	int		$notrigger		1=Ne declenche pas les triggers
+     *    @param	int		$nosyncuser		Do not synchronize linked user
+     *    @return   string           		If OK return clear password, 0 if no change, < 0 if error
+     */
+    function setPassword($user, $password='', $isencrypted=0, $notrigger=0, $nosyncuser=0)
+    {
+        global $conf, $langs;
+
+        $error=0;
+
+        dol_syslog(get_class($this)."::setPassword user=".$user->id." password=".preg_replace('/./i','*',$password)." isencrypted=".$isencrypted);
+
+        // If new password not provided, we generate one
+        if (! $password)
+        {
+            require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
+            $password=getRandomPassword('');
+        }
+
+        // Cryptage mot de passe
+        if ($isencrypted)
+        {
+            // Encryption
+            $password_indatabase = dol_hash($password);
+        }
+        else
+        {
+            $password_indatabase = $password;
+        }
+
+        // Mise a jour
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET pass = '".$this->db->escape($password_indatabase)."'";
+        $sql.= " WHERE rowid = ".$this->id;
+
+        //dol_syslog("Adherent::Password sql=hidden");
+        dol_syslog(get_class($this)."::setPassword sql=".$sql);
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            $nbaffectedrows=$this->db->affected_rows($result);
+
+            if ($nbaffectedrows)
+            {
+                $this->pass=$password;
+                $this->pass_indatabase=$password_indatabase;
+
+                if ($this->user_id && ! $nosyncuser)
+                {
+                    require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
+
+                    // This member is linked with a user, so we also update users informations
+                    // if this is an update.
+                    $luser=new User($this->db);
+                    $result=$luser->fetch($this->user_id);
+
+                    if ($result >= 0)
+                    {
+                        $result=$luser->setPassword($user,$this->pass,0,0,1);
+                        if ($result < 0)
+                        {
+                            $this->error=$luser->error;
+                            dol_syslog(get_class($this)."::setPassword ".$this->error,LOG_ERR);
+                            $error++;
+                        }
+                    }
+                    else
+                    {
+                        $this->error=$luser->error;
+                        $error++;
+                    }
+                }
+
+                if (! $error && ! $notrigger)
+                {
+                    // Appel des triggers
+                    include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+                    $interface=new Interfaces($this->db);
+                    $result=$interface->run_triggers('MEMBER_NEW_PASSWORD',$this,$user,$langs,$conf);
+                    if ($result < 0) { $error++; $this->errors=$interface->errors; }
+                    // Fin appel triggers
+                }
+
+                return $this->pass;
+            }
+            else
+            {
+                return 0;
+            }
+        }
+        else
+        {
+            dol_print_error($this->db);
+            return -1;
+        }
+    }
+
+
+    /**
+     *    Set link to a user
+     *
+     *    @param     int	$userid        	Id of user to link to
+     *    @return    int					1=OK, -1=KO
+     */
+    function setUserId($userid)
+    {
+        global $conf, $langs;
+
+        $this->db->begin();
+
+        // If user is linked to this member, remove old link to this member
+        $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
+        dol_syslog(get_class($this)."::setUserId sql=".$sql, LOG_DEBUG);
+        $resql = $this->db->query($sql);
+        if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -1; }
+
+        // Set link to user
+        if ($userid > 0)
+        {
+            $sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = ".$this->id;
+            $sql.= " WHERE rowid = ".$userid;
+            dol_syslog(get_class($this)."::setUserId sql=".$sql, LOG_DEBUG);
+            $resql = $this->db->query($sql);
+            if (! $resql) { $this->error=$this->db->error(); $this->db->rollback(); return -2; }
+        }
+
+        $this->db->commit();
+
+        return 1;
+    }
+
+
+    /**
+     *    Set link to a third party
+     *
+     *    @param     int	$thirdpartyid		Id of user to link to
+     *    @return    int						1=OK, -1=KO
+     */
+    function setThirdPartyId($thirdpartyid)
+    {
+        global $conf, $langs;
+
+        $this->db->begin();
+
+        // Update link to third party
+        if ($thirdpartyid > 0)
+        {
+            $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = null";
+            $sql.= " WHERE fk_soc = '".$thirdpartyid."'";
+            $sql.= " AND entity = ".$conf->entity;
+            dol_syslog(get_class($this)."::setThirdPartyId sql=".$sql);
+            $resql = $this->db->query($sql);
+        }
+
+        // Update link to third party
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = ".($thirdpartyid>0 ? $thirdpartyid : 'null');
+        $sql.= " WHERE rowid = ".$this->id;
+
+        dol_syslog(get_class($this)."::setThirdPartyId sql=".$sql);
+        $resql = $this->db->query($sql);
+        if ($resql)
+        {
+            $this->db->commit();
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->error();
+            dol_syslog(get_class($this)."::setThirdPartyId ".$this->error, LOG_ERR);
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+
+    /**
+     *	Method to load member from its login
+     *
+     *	@param	string	$login		login of member
+     *	@return	void
+     */
+    function fetch_login($login)
+    {
+        global $conf;
+
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+        $sql.= " WHERE login='".$this->db->escape($login)."'";
+        $sql.= " AND entity = ".$conf->entity;
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->num_rows($resql))
+            {
+                $obj = $this->db->fetch_object($resql);
+                $this->fetch($obj->rowid);
+            }
+        }
+        else
+        {
+            dol_print_error($this->db);
+        }
+    }
+
+
+    /**
+     *	Load member from database
+     *
+     *	@param	int		$rowid      Id of object to load
+     * 	@param	string	$ref		To load member from its ref
+     * 	@param	int		$fk_soc		To load member from its link to third party
+     *	@return int         		>0 if OK, 0 if not found, <0 if KO
+     */
+    function fetch($rowid,$ref='',$fk_soc='')
+    {
+        global $langs;
+
+        $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,";
+        $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
+        $sql.= " d.photo, d.fk_adherent_type, d.morphy,";
+        $sql.= " d.datec as datec,";
+        $sql.= " d.tms as datem,";
+        $sql.= " d.datefin as datefin,";
+        $sql.= " d.naiss as datenaiss,";
+        $sql.= " d.datevalid as datev,";
+        $sql.= " d.pays,";
+        $sql.= " d.fk_departement,";
+        $sql.= " p.rowid as country_id, p.code as country_code, p.libelle as country,";
+        $sql.= " dep.nom as state, dep.code_departement as state_code,";
+        $sql.= " t.libelle as type, t.cotisation as cotisation,";
+        $sql.= " u.rowid as user_id, u.login as user_login";
+        $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as dep ON d.fk_departement = dep.rowid";
+        $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON d.rowid = u.fk_member";
+        $sql.= " WHERE d.fk_adherent_type = t.rowid";
+        if ($rowid) $sql.= " AND d.rowid=".$rowid;
+        elseif ($ref || $fk_soc) {
+        	$sql.= " AND d.entity IN (".getEntity().")";
+        	if ($ref) $sql.= " AND d.rowid='".$ref."'";
+        	elseif ($fk_soc) $sql.= " AND d.fk_soc='".$fk_soc."'";
+        }
+
+        dol_syslog(get_class($this)."::fetch sql=".$sql);
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->num_rows($resql))
+            {
+                $obj = $this->db->fetch_object($resql);
+
+                $this->ref            = $obj->rowid;
+                $this->id             = $obj->rowid;
+                $this->civilite_id    = $obj->civilite;
+                $this->prenom         = $obj->firstname;   // deprecated
+                $this->firstname      = $obj->firstname;
+                $this->nom            = $obj->lastname;    // deprecated
+                $this->lastname       = $obj->lastname;
+                $this->login          = $obj->login;
+                $this->pass           = $obj->pass;
+                $this->societe        = $obj->societe;
+                $this->fk_soc         = $obj->fk_soc;
+                $this->adresse        = $obj->address;	// deprecated
+                $this->address        = $obj->address;
+                $this->cp             = $obj->zip;		// deprecated
+                $this->zip            = $obj->zip;
+                $this->ville          = $obj->town;	    // deprecated
+                $this->town           = $obj->town;
+
+                $this->state_id       = $obj->fk_departement;
+                $this->state_code     = $obj->fk_departement?$obj->state_code:'';
+                $this->state          = $obj->fk_departement?$obj->state:'';
+                $this->fk_departement   = $obj->fk_departement;                        // deprecated
+                $this->departement_code = $obj->fk_departement?$obj->state_code:'';    // deprecated
+                $this->departement	    = $obj->fk_departement?$obj->state:'';         // deprecated
+
+                $this->country_id     = $obj->country_id;
+                $this->country_code   = $obj->country_code;
+                if ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code) $this->country = $langs->transnoentitiesnoconv("Country".$obj->country_code);
+                else $this->country=$obj->country;
+                $this->pays_id        = $obj->country_id;      // deprecated
+                $this->pays_code      = $obj->country_code;    // deprecated
+                $this->pays           = $this->country;        // deprecated
+
+                $this->phone          = $obj->phone;
+                $this->phone_perso    = $obj->phone_perso;
+                $this->phone_mobile   = $obj->phone_mobile;
+                $this->email          = $obj->email;
+
+                $this->photo          = $obj->photo;
+                $this->statut         = $obj->statut;
+                $this->public         = $obj->public;
+
+                $this->datec          = $this->db->jdate($obj->datec);
+                $this->datem          = $this->db->jdate($obj->datem);
+                $this->datefin        = $this->db->jdate($obj->datefin);
+                $this->datevalid      = $this->db->jdate($obj->datev);
+                $this->naiss          = $this->db->jdate($obj->datenaiss);
+
+                $this->note           = $obj->note;
+                $this->morphy         = $obj->morphy;
+
+                $this->typeid         = $obj->fk_adherent_type;
+                $this->type           = $obj->type;
+                $this->need_subscription = ($obj->cotisation=='yes'?1:0);
+
+                $this->user_id        = $obj->user_id;
+                $this->user_login     = $obj->user_login;
+
+                // Load other properties
+                $result=$this->fetch_subscriptions();
+
+                return $result;
+            }
+            else
+            {
+                return 0;
+            }
+        }
+        else
+        {
+            $this->error=$this->db->lasterror();
+            dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
+            return -1;
+        }
+    }
+
+
+    /**
+     *	Fonction qui recupere pour un adherent les parametres
+     *				first_subscription_date
+     *				first_subscription_amount
+     *				last_subscription_date
+     *				last_subscription_amount
+     *
+     *	@return		int			<0 si KO, >0 si OK
+     */
+    function fetch_subscriptions()
+    {
+        global $langs;
+
+        $sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,";
+        $sql.= " c.tms as datem,";
+        $sql.= " c.datec as datec,";
+        $sql.= " c.dateadh as dateadh,";
+        $sql.= " c.datef as datef";
+        $sql.= " FROM ".MAIN_DB_PREFIX."cotisation as c";
+        $sql.= " WHERE c.fk_adherent = ".$this->id;
+        $sql.= " ORDER BY c.dateadh";
+        dol_syslog(get_class($this)."::fetch_subscriptions sql=".$sql);
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            $this->subscriptions=array();
+
+            $i=0;
+            while ($obj = $this->db->fetch_object($resql))
+            {
+                if ($i==0)
+                {
+                    $this->first_subscription_date=$obj->dateadh;
+                    $this->first_subscription_amount=$obj->cotisation;
+                }
+                $this->last_subscription_date=$obj->dateadh;
+                $this->last_subscription_amount=$obj->cotisation;
+
+                $subscription=new Cotisation($this->db);
+                $subscription->id=$obj->rowid;
+                $subscription->fk_adherent=$obj->fk_adherent;
+                $subscription->amount=$obj->cotisation;
+                $subscription->note=$obj->note;
+                $subscription->fk_bank=$obj->fk_bank;
+                $subscription->datem=$this->db->jdate($obj->datem);
+                $subscription->datec=$this->db->jdate($obj->datec);
+                $subscription->dateadh=$this->db->jdate($obj->dateadh);
+                $subscription->datef=$this->db->jdate($obj->datef);
+
+                $this->subscriptions[]=$subscription;
+
+                $i++;
+            }
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->error().' sql='.$sql;
+            return -1;
+        }
+    }
+
+
+    /**
+     *	Insert subscription into database and eventually add links to banks, mailman, etc...
+     *
+     *	@param	timestamp	$date        		Date d'effet de la cotisation
+     *	@param	amount		$montant     		Montant cotisation (accepte 0 pour les adherents non soumis e cotisation)
+     *	@param	int			$accountid			Id compte bancaire
+     *	@param	string		$operation			Type operation (si Id compte bancaire fourni)
+     *	@param	string		$label				Label operation (si Id compte bancaire fourni)
+     *	@param	string		$num_chq			Numero cheque (si Id compte bancaire fourni)
+     *	@param	string		$emetteur_nom		Nom emetteur cheque
+     *	@param	string		$emetteur_banque	Nom banque emetteur cheque
+     *	@param	timestamp	$datesubend			Date fin adhesion
+     *	@return int         					rowid of record added, <0 if KO
+     */
+    function cotisation($date, $montant, $accountid=0, $operation='', $label='', $num_chq='', $emetteur_nom='', $emetteur_banque='', $datesubend=0)
+    {
+        global $conf,$langs,$user;
+
+		$error=0;
+
+        // Clean parameters
+        if (! $montant) $montant=0;
+
+        $this->db->begin();
+
+        if ($datesubend)
+        {
+            $datefin=$datesubend;
+        }
+        else
+        {
+            // If no end date, end date = date + 1 year - 1 day
+            $datefin = dol_time_plus_duree($date,1,'y');
+            $datefin = dol_time_plus_duree($datefin,-1,'d');
+        }
+
+        // Create subscription
+        $cotisation=new Cotisation($this->db);
+        $cotisation->fk_adherent=$this->id;
+        $cotisation->dateh=$date;		// Date of new subscription
+        $cotisation->datef=$datefin;	// End data of new subscription
+        $cotisation->amount=$montant;
+        $cotisation->note=$label;
+
+        $rowid=$cotisation->create($user);
+        if ($rowid > 0)
+        {
+            // Update denormalized subscription end date (read database subscription to find values)
+            // This will also update this->datefin
+            $result=$this->update_end_date($user);
+            if ($result > 0)
+            {
+                // Change properties of object (used by triggers)
+                $this->last_subscription_date=dol_now();
+                $this->last_subscription_amount=$montant;
+                $this->last_subscription_date_start=$date;
+                $this->last_subscription_date_end=$datefin;
+
+                // Appel des triggers
+                include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+                $interface=new Interfaces($this->db);
+                $result=$interface->run_triggers('MEMBER_SUBSCRIPTION',$this,$user,$langs,$conf);
+                if ($result < 0) { $error++; $this->errors=$interface->errors; }
+                // Fin appel triggers
+            }
+
+            if (! $error)
+            {
+                $this->db->commit();
+                return $rowid;
+            }
+            else
+            {
+                $this->db->rollback();
+                return -2;
+            }
+        }
+        else
+        {
+            $this->error=$cotisation->error;
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+    /**
+     *		Function that validate a member
+     *
+     *		@param	User	$user		user adherent qui valide
+     *		@return	int					<0 if KO, 0 if nothing done, >0 if OK
+     */
+    function validate($user)
+    {
+        global $langs,$conf;
+
+		$error=0;
+
+		// Check parameters
+        if ($this->statut == 1)
+        {
+            dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING);
+            return 0;
+        }
+
+        $this->db->begin();
+
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+        $sql.= " statut = 1";
+        $sql.= ", datevalid = ".$this->db->idate(mktime());
+        $sql.= ", fk_user_valid=".$user->id;
+        $sql.= " WHERE rowid = ".$this->id;
+
+        dol_syslog(get_class($this)."::validate sql=".$sql);
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            $this->statut=1;
+
+            // Appel des triggers
+            include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+            $interface=new Interfaces($this->db);
+            $result=$interface->run_triggers('MEMBER_VALIDATE',$this,$user,$langs,$conf);
+            if ($result < 0) { $error++; $this->errors=$interface->errors; }
+            // Fin appel triggers
+
+            $this->db->commit();
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->error();
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+
+    /**
+     *		Fonction qui resilie un adherent
+     *
+     *		@param	User	$user		User making change
+     *		@return	int					<0 if KO, >0 if OK
+     */
+    function resiliate($user)
+    {
+        global $langs,$conf;
+
+		$error=0;
+
+		// Check paramaters
+        if ($this->statut == 0)
+        {
+            dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING);
+            return 0;
+        }
+
+        $this->db->begin();
+
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
+        $sql.= " statut = 0";
+        $sql.= ", fk_user_valid=".$user->id;
+        $sql.= " WHERE rowid = ".$this->id;
+
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            $this->statut=0;
+
+            // Appel des triggers
+            include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+            $interface=new Interfaces($this->db);
+            $result=$interface->run_triggers('MEMBER_RESILIATE',$this,$user,$langs,$conf);
+            if ($result < 0) { $error++; $this->errors=$interface->errors; }
+            // Fin appel triggers
+
+            $this->db->commit();
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->error();
+            $this->db->rollback();
+            return -1;
+        }
+    }
+
+
+    /**
+     *  Fonction qui ajoute l'adherent au abonnements automatiques
+     *  mailing-list, spip, etc.
+     *
+     *  @return		int		<0 if KO, >0 if OK
+     */
+    function add_to_abo()
+    {
+        global $conf;
+
+        $err=0;
+
+        // mailman
+        if (! empty($conf->global->ADHERENT_USE_MAILMAN))
+        {
+            $result=$this->add_to_mailman();
+            if ($result < 0)
+            {
+                $err+=1;
+            }
+        }
+
+        // spip
+        if ($conf->global->ADHERENT_USE_SPIP && $conf->mailmanspip->enabled)
+        {
+            $result=$this->add_to_spip();
+            if ($result < 0)
+            {
+                $err+=1;
+            }
+        }
+        if ($err)
+        {
+            // error
+            return -$err;
+        }
+        else
+        {
+            return 1;
+        }
+    }
+
+
+    /**
+     *  Fonction qui supprime l'adherent des abonnements automatiques
+     *  mailing-list, spip, etc.
+     *
+     *  @return     int     <0 if KO, >0 if OK
+     */
+    function del_to_abo()
+    {
+        global $conf;
+
+        $err=0;
+        // mailman
+        if (! empty($conf->global->ADHERENT_USE_MAILMAN))
+        {
+            $result=$this->del_to_mailman();
+            if ($result < 0)
+            {
+                $err+=1;
+            }
+        }
+
+        if ($conf->global->ADHERENT_USE_SPIP && $conf->mailmanspip->enabled)
+        {
+            $result=$this->del_to_spip();
+            if ($result < 0)
+            {
+                $err+=1;
+            }
+        }
+        if ($err)
+        {
+            // error
+            return -$err;
+        }
+        else
+        {
+            return 1;
+        }
+    }
+
+
+    /**
+     *  Fonction qui donne les droits redacteurs dans spip
+     *
+     *  @return		int		=0 if KO, >0 if OK
+     */
+    function add_to_spip()
+    {
+        dol_syslog(get_class($this)."::add_to_spip");
+
+        if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 &&
+        defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' &&
+        defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' &&
+        defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' &&
+        defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != ''
+        )
+        {
+            require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
+            $mdpass=dol_hash($this->pass);
+            $htpass=crypt($this->pass,makesalt());
+            $query = "INSERT INTO spip_auteurs (nom, email, login, pass, htpass, alea_futur, statut) VALUES(\"".$this->firstname." ".$this->lastname."\",\"".$this->email."\",\"".$this->login."\",\"$mdpass\",\"$htpass\",FLOOR(32000*RAND()),\"1comite\")";
+
+            $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT);
+
+            if (! $mydb->ok)
+            {
+                $this->error=$mydb->lasterror();
+                return 0;
+            }
+
+            $result = $mydb->query($query);
+            if ($result)
+            {
+                $mydb->close();
+                return 1;
+            }
+            else
+            {
+                $this->error=$mydb->lasterror();
+                return 0;
+            }
+        }
+    }
+
+    /**
+     *  Fonction qui enleve les droits redacteurs dans spip
+     *
+     *  @return		int		=0 if KO, >0 if OK
+     */
+    function del_to_spip()
+    {
+        if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 &&
+        defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' &&
+        defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' &&
+        defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' &&
+        defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != ''
+        )
+        {
+            $query = "DELETE FROM spip_auteurs WHERE login='".$this->login."'";
+
+            $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT);
+
+            $result = $mydb->query($query);
+            if ($result)
+            {
+                $mydb->close();
+                return 1;
+            }
+            else
+            {
+                $this->error=$mydb->error();
+                return 0;
+            }
+        }
+    }
+
+    /**
+     *  Fonction qui dit si cet utilisateur est un redacteur existant dans spip
+     *
+     *  @return     int     1=exists, 0=does not exists, -1=error
+     */
+    function is_in_spip()
+    {
+        if (defined("ADHERENT_USE_SPIP") && ADHERENT_USE_SPIP ==1 &&
+        defined('ADHERENT_SPIP_SERVEUR') && ADHERENT_SPIP_SERVEUR != '' &&
+        defined('ADHERENT_SPIP_USER') && ADHERENT_SPIP_USER != '' &&
+        defined('ADHERENT_SPIP_PASS') && ADHERENT_SPIP_PASS != '' &&
+        defined('ADHERENT_SPIP_DB') && ADHERENT_SPIP_DB != '')
+        {
+            $query = "SELECT login FROM spip_auteurs WHERE login='".$this->login."'";
+
+            $mydb=getDoliDBInstance('mysql',ADHERENT_SPIP_SERVEUR,ADHERENT_SPIP_USER,ADHERENT_SPIP_PASS,ADHERENT_SPIP_DB,ADHERENT_SPIP_PORT);
+
+            if ($mydb->ok)
+            {
+                $result = $mydb->query($query);
+
+                if ($result)
+                {
+                    if ($mydb->num_rows($result))
+                    {
+                        // nous avons au moins une reponse
+                        $mydb->close($result);
+                        return 1;
+                    }
+                    else
+                    {
+                        // nous n'avons pas de reponse => n'existe pas
+                        $mydb->close($result);
+                        return 0;
+                    }
+                }
+                else
+                {
+                    $this->error=$mydb->error();
+                    return -1;
+                }
+            }
+            else
+            {
+                $this->error="Echec de connexion avec les identifiants ".ADHERENT_SPIP_SERVEUR." ".ADHERENT_SPIP_USER." ".ADHERENT_SPIP_PASS." ".ADHERENT_SPIP_DB;
+                return -1;
+            }
+        }
+    }
+
+    /**
+     *  Subscribe an email to all mailing-lists
+     *
+     *  @param	array	$listes    	To force mailing-list (string separated with ,)
+     *  @return	int		  			<=0 if KO, >0 if OK
+     */
+    function add_to_mailman($listes='')
+    {
+        global $conf,$langs,$user;
+
+        dol_syslog(get_class($this)."::add_to_mailman");
+
+        if (! function_exists("curl_init"))
+        {
+            $langs->load("errors");
+            $this->error=$langs->trans("ErrorFunctionNotAvailableInPHP","curl_init");
+            return -1;
+        }
+
+        if (! empty($conf->global->ADHERENT_MAILMAN_URL))
+        {
+            if ($listes == '' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS))
+            {
+                $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
+            }
+            else
+            {
+                $lists=explode(',',$listes);
+            }
+            foreach ($lists as $list)
+            {
+                // on remplace dans l'url le nom de la liste ainsi
+                // que l'email et le mot de passe
+                $patterns = array (
+				'/%LISTE%/',
+				'/%EMAIL%/',
+				'/%PASSWORD%/',
+				'/%MAILMAN_ADMINPW%/'
+				);
+				$replace = array (
+				$list,
+				$this->email,
+				$this->pass,
+				$conf->global->ADHERENT_MAILMAN_ADMINPW
+				);
+				$curl_url = preg_replace($patterns, $replace, $conf->global->ADHERENT_MAILMAN_URL);
+
+                dol_syslog("Call URL to subscribe : ".$curl_url);
+				$ch = curl_init();
+				curl_setopt($ch, CURLOPT_URL,"$curl_url");
+				//curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/");
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+				curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+				@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+				curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+				//curl_setopt($ch, CURLOPT_POST, 0);
+				//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
+				//--- Start buffering
+				$result=curl_exec($ch);
+				dol_syslog($result);
+				//--- End buffering and clean output
+				if (curl_error($ch) > 0)
+				{
+				    // error
+				    return -2;
+				}
+				curl_close($ch);
+
+            }
+            return 1;
+        }
+        else
+        {
+            $this->error="ADHERENT_MAILMAN_URL not defined";
+            return -1;
+        }
+    }
+
+    /**
+     *  Unsubscribe an email from all mailing-lists
+     *  Used when a user is resiliated
+     *
+     *  @param	array	$listes     To force mailing-list (string separated with ,)
+     *  @return int         		<=0 if KO, >0 if OK
+     */
+    function del_to_mailman($listes='')
+    {
+        global $conf,$langs,$user;
+
+        if (! empty($conf->global->ADHERENT_MAILMAN_UNSUB_URL))
+        {
+            if ($listes=='' && ! empty($conf->global->ADHERENT_MAILMAN_LISTS))
+            {
+                $lists=explode(',',$conf->global->ADHERENT_MAILMAN_LISTS);
+            }
+            else
+            {
+                $lists=explode(',',$listes);
+            }
+            foreach ($lists as $list)
+            {
+                // on remplace dans l'url le nom de la liste ainsi
+                // que l'email et le mot de passe
+                $patterns = array (
+				'/%LISTE%/',
+				'/%EMAIL%/',
+				'/%PASSWORD%/',
+				'/%MAILMAN_ADMINPW%/'
+				);
+				$replace = array (
+				trim($list),
+				$this->email,
+				$this->pass,
+				$conf->global->ADHERENT_MAILMAN_ADMINPW
+				);
+				$curl_url = preg_replace($patterns, $replace, $conf->global->ADHERENT_MAILMAN_UNSUB_URL);
+
+                dol_syslog("Call URL to unsubscribe : ".$curl_url);
+				$ch = curl_init();
+				curl_setopt($ch, CURLOPT_URL,"$curl_url");
+				//curl_setopt($ch, CURLOPT_URL,"http://www.j1b.org/");
+				curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
+				curl_setopt($ch, CURLOPT_FAILONERROR, 1);
+				@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+				curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+				//curl_setopt($ch, CURLOPT_POST, 0);
+				//curl_setopt($ch, CURLOPT_POSTFIELDS, "a=3&b=5");
+				//--- Start buffering
+				$result=curl_exec($ch);
+				dol_syslog($result);
+				//--- End buffering and clean output
+				$rescode=curl_error($ch);
+				if ($rescode > 0)
+				{
+				    dol_syslog("Error using CURL : ".$rescode, LOG_ERR);
+				    // error
+				    return -2;
+				}
+				curl_close($ch);
+
+            }
+            return 1;
+        }
+        else
+        {
+            $this->error="ADHERENT_MAILMAN_UNSUB_URL not defined";
+            return -1;
+        }
+    }
+
+    /**
+     *    Return label of a civility of a contact
+     *
+     *    @param	int		$nohtmlentities     0=Encode with htmlentities for HTML output, 1=No htmlentities for memory translation
+     *    @return   string              		Name translated of civility
+     */
+    function getCivilityLabel($nohtmlentities=0)
+    {
+        global $langs;
+        $langs->load("dict");
+
+        $code=$this->civilite_id;
+        if ($nohtmlentities) return $langs->transnoentities("Civility".$code)!="Civility".$code ? $langs->transnoentities("Civility".$code) : $code;
+        else return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : $code;
+    }
+
+    /**
+     *    	Renvoie nom clicable (avec eventuellement le picto)
+     *
+     *		@param	int		$withpicto		0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+     *		@param	int		$maxlen			length max libelle
+     *		@param	string	$option			Page lien
+     *		@return	string					Chaine avec URL
+     */
+    function getNomUrl($withpicto=0,$maxlen=0,$option='card')
+    {
+        global $langs;
+
+        $result='';
+
+        if ($option == 'card')
+        {
+            $lien = '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$this->id.'">';
+            $lienfin='</a>';
+        }
+        if ($option == 'subscription')
+        {
+            $lien = '<a href="'.DOL_URL_ROOT.'/adherents/card_subscriptions.php?rowid='.$this->id.'">';
+            $lienfin='</a>';
+        }
+
+        $picto='user';
+        $label=$langs->trans("ShowMember");
+
+        if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+        if ($withpicto && $withpicto != 2) $result.=' ';
+        $result.=$lien.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$lienfin;
+        return $result;
+    }
+
+
+    /**
+     * 	Return full address of member
+     *
+     * 	@param		int			$withcountry		1=Add country into address string
+     *  @param		string		$sep				Separator to use to build string
+     *	@return		string							Full address string
+     */
+    function getFullAddress($withcountry=0,$sep="\n")
+    {
+        $ret='';
+        if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
+        {
+            require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
+            $tmparray=getCountry($this->country_id,'all');
+            $this->country_code=$tmparray['code'];
+            $this->country     =$tmparray['label'];
+        }
+
+        if (in_array($this->country_code,array('US')))
+        {
+	        $ret.=($this->address?$this->address.$sep:'');
+	        $ret.=trim($this->zip.' '.$this->town);
+	        if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
+        }
+        else
+        {
+	        $ret.=($this->address?$this->address.$sep:'');
+	        $ret.=trim($this->zip.' '.$this->town);
+	        if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
+        }
+        return trim($ret);
+    }
+
+    /**
+     *    	Retourne le libelle du statut d'un adherent (brouillon, valide, resilie)
+     *
+     *    	@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
+     */
+    function getLibStatut($mode=0)
+    {
+        return $this->LibStatut($this->statut,$this->need_subscription,$this->datefin,$mode);
+    }
+
+    /**
+     *    	Renvoi le libelle d'un statut donne
+     *
+     *    	@param	int			$statut      			Id statut
+     *		@param	int			$need_subscription		1 si type adherent avec cotisation, 0 sinon
+     *		@param	timestamp	$date_end_subscription	Date fin adhesion
+     *    	@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
+     */
+    function LibStatut($statut,$need_subscription,$date_end_subscription,$mode=0)
+    {
+        global $langs;
+        $langs->load("members");
+        if ($mode == 0)
+        {
+            if ($statut == -1) return $langs->trans("MemberStatusDraft");
+            if ($statut >= 1)
+            {
+                if (! $date_end_subscription)            return $langs->trans("MemberStatusActive");
+                elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate");
+                else                                     return $langs->trans("MemberStatusPaid");
+            }
+            if ($statut == 0)  return $langs->trans("MemberStatusResiliated");
+        }
+        if ($mode == 1)
+        {
+            if ($statut == -1) return $langs->trans("MemberStatusDraftShort");
+            if ($statut >= 1)
+            {
+                if (! $date_end_subscription)            return $langs->trans("MemberStatusActiveShort");
+                elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLateShort");
+                else                                     return $langs->trans("MemberStatusPaidShort");
+            }
+            if ($statut == 0)  return $langs->trans("MemberStatusResiliatedShort");
+        }
+        if ($mode == 2)
+        {
+            if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0').' '.$langs->trans("MemberStatusDraftShort");
+            if ($statut >= 1)
+            {
+                if (! $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");
+            }
+            if ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliatedShort");
+        }
+        if ($mode == 3)
+        {
+            if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0');
+            if ($statut >= 1)
+            {
+                if (! $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');
+            }
+            if ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'),'statut5');
+        }
+        if ($mode == 4)
+        {
+            if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'),'statut0').' '.$langs->trans("MemberStatusDraft");
+            if ($statut >= 1)
+            {
+                if (! $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");
+            }
+            if ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'),'statut5').' '.$langs->trans("MemberStatusResiliated");
+        }
+        if ($mode == 5)
+        {
+            if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'),'statut0');
+            if ($statut >= 1)
+            {
+                if (! $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');
+        }
+    }
+
+
+    /**
+     *      Charge indicateurs this->nb de tableau de bord
+     *
+     *      @return     int         <0 if KO, >0 if OK
+     */
+    function load_state_board()
+    {
+        global $conf;
+
+        $this->nb=array();
+
+        $sql = "SELECT count(a.rowid) as nb";
+        $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
+        $sql.= " WHERE a.statut > 0";
+        $sql.= " AND a.entity = ".$conf->entity;
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            while ($obj=$this->db->fetch_object($resql))
+            {
+                $this->nb["members"]=$obj->nb;
+            }
+            return 1;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            $this->error=$this->db->error();
+            return -1;
+        }
+
+    }
+
+    /**
+     *      Load indicators for dashboard (this->nbtodo and this->nbtodolate)
+     *
+     *      @param	User	$user   	Objet user
+     *      @return int     			<0 if KO, >0 if OK
+     */
+    function load_board($user)
+    {
+        global $conf;
+
+        $now=dol_now();
+
+        if ($user->societe_id) return -1;   // protection pour eviter appel par utilisateur externe
+
+        $this->nbtodo=$this->nbtodolate=0;
+
+        $sql = "SELECT a.rowid, a.datefin";
+        $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a";
+        $sql.= " WHERE a.statut = 1";
+        $sql.= " AND a.entity = ".$conf->entity;
+        $sql.= " AND (a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."')";
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            while ($obj=$this->db->fetch_object($resql))
+            {
+                $this->nbtodo++;
+                if ($this->db->jdate($obj->datefin) < ($now - $conf->adherent->cotisation->warning_delay)) $this->nbtodolate++;
+            }
+            return 1;
+        }
+        else
+        {
+            dol_print_error($this->db);
+            $this->error=$this->db->error();
+            return -1;
+        }
+    }
+
+
+    /**
+     *  Initialise an instance with random values.
+     *  Used to build previews or test instances.
+     *	id must be 0 if object instance is a specimen.
+     *
+     *  @return	void
+     */
+    function initAsSpecimen()
+    {
+        global $user,$langs;
+
+        // Initialise parametres
+        $this->id=0;
+        $this->specimen=1;
+        $this->civilite_id = 0;
+        $this->lastname = 'DOLIBARR';
+        $this->firstname = 'SPECIMEN';
+        $this->login='dolibspec';
+        $this->pass='dolibspec';
+        $this->societe = 'Societe ABC';
+        $this->address = '61 jump street';
+        $this->zip = '75000';
+        $this->town = 'Paris';
+        $this->country_id = 1;
+        $this->country_code = 'FR';
+        $this->country = 'France';
+        $this->morphy = 1;
+        $this->email = 'specimen@specimen.com';
+        $this->phone        = '0999999999';
+        $this->phone_perso  = '0999999998';
+        $this->phone_mobile = '0999999997';
+        $this->note='No comment';
+        $this->naiss=time();
+        $this->photo='';
+        $this->public=1;
+        $this->statut=0;
+
+        $this->datefin=time();
+        $this->datevalid=time();
+
+        $this->typeid=1;				// Id type adherent
+        $this->type='Type adherent';	// Libelle type adherent
+        $this->need_subscription=0;
+
+        $this->first_subscription_date=time();
+        $this->first_subscription_amount=10;
+        $this->last_subscription_date=time();
+        $this->last_subscription_amount=10;
+    }
+
+
+    /**
+     *	Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
+     *
+     *	@param	string	$info		Info string loaded by _load_ldap_info
+     *	@param	int		$mode		0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
+     *								1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
+     *								2=Return key only (uid=qqq)
+     *	@return	string				DN
+     */
+    function _load_ldap_dn($info,$mode=0)
+    {
+        global $conf;
+        $dn='';
+        if ($mode==0) $dn=$conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS].",".$conf->global->LDAP_MEMBER_DN;
+        if ($mode==1) $dn=$conf->global->LDAP_MEMBER_DN;
+        if ($mode==2) $dn=$conf->global->LDAP_KEY_MEMBERS."=".$info[$conf->global->LDAP_KEY_MEMBERS];
+        return $dn;
+    }
+
+
+    /**
+     *	Initialise tableau info (tableau des attributs LDAP)
+     *
+     *	@return		array		Tableau info des attributs
+     */
+    function _load_ldap_info()
+    {
+        global $conf,$langs;
+
+        $info=array();
+
+        // Object classes
+        $info["objectclass"]=explode(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS);
+
+        $this->fullname=$this->getFullName($langs);
+
+        // Member
+        if ($this->fullname && $conf->global->LDAP_MEMBER_FIELD_FULLNAME) $info[$conf->global->LDAP_MEMBER_FIELD_FULLNAME] = $this->fullname;
+        if ($this->nom && $conf->global->LDAP_MEMBER_FIELD_NAME)         $info[$conf->global->LDAP_MEMBER_FIELD_NAME] = $this->nom;
+        if ($this->prenom && $conf->global->LDAP_MEMBER_FIELD_FIRSTNAME) $info[$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME] = $this->prenom;
+        if ($this->login && $conf->global->LDAP_MEMBER_FIELD_LOGIN)      $info[$conf->global->LDAP_MEMBER_FIELD_LOGIN] = $this->login;
+        if ($this->pass && $conf->global->LDAP_MEMBER_FIELD_PASSWORD)    $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass;	// this->pass = mot de passe non crypte
+        if ($this->poste && $conf->global->LDAP_MEMBER_FIELD_TITLE)      $info[$conf->global->LDAP_MEMBER_FIELD_TITLE] = $this->poste;
+        if ($this->adresse && $conf->global->LDAP_MEMBER_FIELD_ADDRESS)  $info[$conf->global->LDAP_MEMBER_FIELD_ADDRESS] = $this->adresse;
+        if ($this->cp && $conf->global->LDAP_MEMBER_FIELD_ZIP)           $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->cp;
+        if ($this->ville && $conf->global->LDAP_MEMBER_FIELD_TOWN)       $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->ville;
+        if ($this->country_code && $conf->global->LDAP_MEMBER_FIELD_COUNTRY)     $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
+        if ($this->email && $conf->global->LDAP_MEMBER_FIELD_MAIL)       $info[$conf->global->LDAP_MEMBER_FIELD_MAIL] = $this->email;
+        if ($this->phone && $conf->global->LDAP_MEMBER_FIELD_PHONE)      $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
+        if ($this->phone_perso && $conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
+        if ($this->phone_mobile && $conf->global->LDAP_MEMBER_FIELD_MOBILE) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
+        if ($this->fax && $conf->global->LDAP_MEMBER_FIELD_FAX)	      $info[$conf->global->LDAP_MEMBER_FIELD_FAX] = $this->fax;
+        if ($this->note && $conf->global->LDAP_MEMBER_FIELD_DESCRIPTION) $info[$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION] = $this->note;
+        if ($this->naiss && $conf->global->LDAP_MEMBER_FIELD_BIRTHDATE)  $info[$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE] = dol_print_date($this->naiss,'dayhourldap');
+        if (isset($this->statut) && $conf->global->LDAP_FIELD_MEMBER_STATUS)  $info[$conf->global->LDAP_FIELD_MEMBER_STATUS] = $this->statut;
+        if ($this->datefin && $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)  $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
+
+        // Subscriptions
+        if ($this->first_subscription_date && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE)     $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE]  = dol_print_date($this->first_subscription_date,'dayhourldap');
+        if (isset($this->first_subscription_amount) && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
+        if ($this->last_subscription_date && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE)       $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE]   = dol_print_date($this->last_subscription_date,'dayhourldap');
+        if (isset($this->last_subscription_amount) && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT)   $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
+
+        return $info;
+    }
+
+
+    /**
+     *      Charge les informations d'ordre info dans l'objet adherent
+     *
+     *      @param  int		$id       Id of member to load
+     *      @return	void
+     */
+    function info($id)
+    {
+        $sql = 'SELECT a.rowid, a.datec as datec,';
+        $sql.= ' a.datevalid as datev,';
+        $sql.= ' a.tms as datem,';
+        $sql.= ' a.fk_user_author, a.fk_user_valid, a.fk_user_mod';
+        $sql.= ' FROM '.MAIN_DB_PREFIX.'adherent as a';
+        $sql.= ' WHERE a.rowid = '.$id;
+
+        dol_syslog(get_class($this)."::info sql=".$sql, LOG_DEBUG);
+        $result=$this->db->query($sql);
+        if ($result)
+        {
+            if ($this->db->num_rows($result))
+            {
+                $obj = $this->db->fetch_object($result);
+                $this->id = $obj->rowid;
+                if ($obj->fk_user_author)
+                {
+                    $cuser = new User($this->db);
+                    $cuser->fetch($obj->fk_user_author);
+                    $this->user_creation   = $cuser;
+                }
+
+                if ($obj->fk_user_valid)
+                {
+                    $vuser = new User($this->db);
+                    $vuser->fetch($obj->fk_user_valid);
+                    $this->user_validation = $vuser;
+                }
+
+                if ($obj->fk_user_mod)
+                {
+                    $muser = new User($this->db);
+                    $muser->fetch($obj->fk_user_mod);
+                    $this->user_modification = $muser;
+                }
+
+                $this->date_creation     = $this->db->jdate($obj->datec);
+                $this->date_validation   = $this->db->jdate($obj->datev);
+                $this->date_modification = $this->db->jdate($obj->datem);
+            }
+
+            $this->db->free($result);
+
+        }
+        else
+        {
+            dol_print_error($this->db);
+        }
+    }
+
+}
+?>

+ 320 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/class/adherent_type.class.php

@@ -0,0 +1,320 @@
+<?php
+/* Copyright (C) 2002      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2009      Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/adherents/class/adherent_type.class.php
+ *	\ingroup    member
+ *	\brief      File of class to manage members types
+ *	\author     Rodolphe Quiedeville
+ */
+
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
+
+
+/**
+ *	\class      AdherentType
+ *	\brief      Class to manage members type
+ */
+class AdherentType extends CommonObject
+{
+    public $table_element = 'adherent_type';
+
+    var $id;
+    var $libelle;
+    var $statut;
+    var $cotisation;  // Soumis a la cotisation
+    var $vote;		  // droit de vote
+    var $note; 		  // commentaire
+    var $mail_valid;  //mail envoye lors de la validation
+
+
+
+    /**
+	 *	Constructor
+	 *
+	 *	@param 		DoliDB		$DB		Database handler
+     */
+    function AdherentType($DB)
+    {
+        $this->db = $DB ;
+        $this->statut = 1;
+    }
+
+
+    /**
+     *  Fonction qui permet de creer le status de l'adherent
+     *
+     *  @param      User		$user		User making creation
+     *  @return     						>0 if OK, < 0 if KO
+     */
+    function create($user)
+    {
+        global $conf;
+
+        $this->statut=trim($this->statut);
+
+        $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (";
+        $sql.= "libelle";
+        $sql.= ", entity";
+        $sql.= ") VALUES (";
+        $sql.= "'".$this->db->escape($this->libelle)."'";
+        $sql.= ", ".$conf->entity;
+        $sql.= ")";
+
+        dol_syslog("Adherent_type::create sql=".$sql);
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type");
+            return $this->update($user);
+        }
+        else
+        {
+            $this->error=$this->db->error().' sql='.$sql;
+            return -1;
+        }
+    }
+
+
+    /**
+     *  Met a jour en base donnees du type
+     *
+     *	@param		User	$user	Object user making change
+     *  @return		int				>0 if OK, < 0 if KO
+     */
+    function update($user)
+    {
+        $this->libelle=trim($this->libelle);
+
+        $sql = "UPDATE ".MAIN_DB_PREFIX."adherent_type ";
+        $sql.= "SET ";
+        $sql.= "statut = ".$this->statut.",";
+        $sql.= "libelle = '".$this->db->escape($this->libelle) ."',";
+        $sql.= "cotisation = '".$this->cotisation."',";
+        $sql.= "note = '".$this->db->escape($this->note)."',";
+        $sql.= "vote = '".$this->vote."',";
+        $sql.= "mail_valid = '".$this->db->escape($this->mail_valid)."'";
+        $sql .= " WHERE rowid = $this->id";
+
+        $result = $this->db->query($sql);
+        if ($result)
+        {
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->error().' sql='.$sql;
+            return -1;
+        }
+    }
+
+    /**
+     *	Fonction qui permet de supprimer le status de l'adherent
+     *
+     *	@param      int		$rowid		Id of member type to delete
+     *  @return		int					>0 if OK, < 0 if KO
+     */
+    function delete($rowid)
+    {
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type WHERE rowid = $rowid";
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ( $this->db->affected_rows($resql) )
+            {
+                return 1;
+            }
+            else
+            {
+                return 0;
+            }
+        }
+        else
+        {
+            print "Err : ".$this->db->error();
+            return 0;
+        }
+    }
+
+    /**
+     *  Fonction qui permet de recuperer le status de l'adherent
+     *
+     *  @param 		int		$rowid		Id of member type to load
+     *  @return		int					<0 if KO, >0 if OK
+     */
+    function fetch($rowid)
+    {
+        $sql = "SELECT d.rowid, d.libelle, d.statut, d.cotisation, d.mail_valid, d.note, d.vote";
+        $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
+        $sql .= " WHERE d.rowid = ".$rowid;
+
+        dol_syslog("Adherent_type::fetch sql=".$sql);
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            if ($this->db->num_rows($resql))
+            {
+                $obj = $this->db->fetch_object($resql);
+
+                $this->id             = $obj->rowid;
+                $this->ref            = $obj->rowid;
+                $this->libelle        = $obj->libelle;
+                $this->statut         = $obj->statut;
+                $this->cotisation     = $obj->cotisation;
+                $this->mail_valid     = $obj->mail_valid;
+                $this->note           = $obj->note;
+                $this->vote           = $obj->vote;
+            }
+            return 1;
+        }
+        else
+        {
+            $this->error=$this->db->lasterror();
+            dol_syslog("Adherent_type::fetch ".$this->error, LOG_ERR);
+            return -1;
+        }
+    }
+
+    /**
+     *  Return list of members' type
+     *
+     *  @return 	array	List of types of members
+     */
+    function liste_array()
+    {
+        global $conf,$langs;
+
+        $projets = array();
+
+        $sql = "SELECT rowid, libelle";
+        $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type";
+        $sql.= " WHERE entity = ".$conf->entity;
+
+        $resql=$this->db->query($sql);
+        if ($resql)
+        {
+            $nump = $this->db->num_rows($resql);
+
+            if ($nump)
+            {
+                $i = 0;
+                while ($i < $nump)
+                {
+                    $obj = $this->db->fetch_object($resql);
+
+                    $projets[$obj->rowid] = $langs->trans($obj->libelle);
+                    $i++;
+                }
+            }
+            return $projets;
+        }
+        else
+        {
+            print $this->db->error();
+        }
+
+    }
+
+
+    /**
+     *    	Renvoie nom clicable (avec eventuellement le picto)
+     *
+     *		@param		int		$withpicto		0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+     *		@param		int		$maxlen			length max libelle
+     *		@return		string					String with URL
+     */
+    function getNomUrl($withpicto=0,$maxlen=0)
+    {
+        global $langs;
+
+        $result='';
+
+        $lien = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'">';
+        $lienfin='</a>';
+
+        $picto='group';
+        $label=$langs->trans("ShowTypeCard",$this->libelle);
+
+        if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+        if ($withpicto && $withpicto != 2) $result.=' ';
+        $result.=$lien.($maxlen?dol_trunc($this->libelle,$maxlen):$this->libelle).$lienfin;
+        return $result;
+    }
+
+
+    /**
+     *     getMailOnValid
+     *
+     *     @return     Return mail model
+     */
+    function getMailOnValid()
+    {
+        global $conf;
+
+        if (! empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid)))
+        {
+            return $this->mail_valid;
+        }
+        else
+        {
+            return $conf->global->ADHERENT_MAIL_VALID;
+        }
+    }
+
+    /**
+     *     getMailOnSubscription
+     *
+     *     @return     Return mail model
+     */
+    function getMailOnSubscription()
+    {
+        global $conf;
+
+        if (! empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription)))  // Property not yet defined
+        {
+            return $this->mail_subscription;
+        }
+        else
+        {
+            return $conf->global->ADHERENT_MAIL_COTIS;
+        }
+    }
+
+    /**
+     *     getMailOnResiliate
+     *
+     *     @return     Return mail model
+     */
+    function getMailOnResiliate()
+    {
+        global $conf;
+
+        if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate)))  // Property not yet defined
+        {
+            return $this->mail_resiliate;
+        }
+        else
+        {
+            return $conf->global->ADHERENT_MAIL_RESIL;
+        }
+    }
+}
+?>

+ 183 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/class/adherentstats.class.php

@@ -0,0 +1,183 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (c) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/adherents/class/adherentstats.class.php
+ *	\ingroup    member
+ *	\brief      Fichier de la classe de gestion des stats des adhérents
+ */
+
+include_once DOL_DOCUMENT_ROOT . "/core/class/stats.class.php";
+include_once DOL_DOCUMENT_ROOT . "/adherents/class/cotisation.class.php";
+
+
+/**
+ *	\class      AdherentStats
+ *	\brief      Classe permettant la gestion des stats des adherents
+ */
+class AdherentStats extends Stats
+{
+    public $table_element;
+
+    var $socid;
+    var $userid;
+
+    var $from;
+    var $field;
+    var $where;
+
+
+	/**
+	 *	Constructor
+	 *
+	 *	@param 		DoliDB		$db			Database handler
+	 * 	@param 		int			$socid	   	Id third party
+     * 	@param   	int			$userid    	Id user for filter
+	 * 	@return 	AdherentStats
+	 */
+	function AdherentStats($db, $socid=0, $userid=0)
+	{
+		global $user, $conf;
+
+		$this->db = $db;
+        $this->socid = $socid;
+        $this->userid = $userid;
+
+		$object=new Cotisation($this->db);
+
+		$this->from = MAIN_DB_PREFIX.$object->table_element." as p";
+		$this->from.= ", ".MAIN_DB_PREFIX."adherent as m";
+
+		$this->field='cotisation';
+
+		$this->where.= " m.statut != 0";
+		$this->where.= " AND p.fk_adherent = m.rowid AND m.entity = ".$conf->entity;
+		//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($this->memberid)
+		{
+			$this->where .= " AND m.rowid = ".$this->memberid;
+		}
+        //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
+	}
+
+
+	/**
+	 * Renvoie le nombre de proposition par mois pour une annee donnee
+	 *
+     * @param   int		$year       Year
+     * @return	array				Array of nb each month
+	 */
+	function getNbByMonth($year)
+	{
+		global $user;
+
+		$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";
+		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getNbByMonth($year, $sql);
+	}
+
+	/**
+	 * Renvoie le nombre de cotisation par annee
+	 *
+     * @return	array				Array of nb each year
+	 */
+	function getNbByYear()
+	{
+		global $user;
+
+		$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";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getNbByYear($sql);
+	}
+
+	/**
+	 * Renvoie le nombre de cotisation par mois pour une annee donnee
+	 *
+     * @param   int		$year       Year
+     * @return	array				Array of amount each month
+	 */
+	function getAmountByMonth($year)
+	{
+		global $user;
+
+		$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";
+		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
+		$sql.= " AND ".$this->where;
+		$sql.= " GROUP BY dm";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getAmountByMonth($year, $sql);
+	}
+
+	/**
+	 * Return average amount each month
+	 *
+     * @param   int		$year       Year
+     * @return	array				Array of average each month
+	 */
+	function getAverageByMonth($year)
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$this->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";
+        $sql.= $this->db->order('dm','DESC');
+
+		return $this->_getAverageByMonth($year, $sql);
+	}
+
+
+	/**
+	 *	Return nb, total and average
+	 *
+	 * 	@return		array					Array with nb, total amount, average for each year
+	 */
+	function getAllByYear()
+	{
+		global $user;
+
+		$sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+		$sql.= " FROM ".$this->from;
+		//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		$sql.= " WHERE ".$this->where;
+		$sql.= " GROUP BY year";
+        $sql.= $this->db->order('year','DESC');
+
+		return $this->_getAllByYear($sql);
+	}
+
+}
+?>

+ 313 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/class/cotisation.class.php

@@ -0,0 +1,313 @@
+<?php
+/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2006-2008 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *		\file 		htdocs/adherents/class/cotisation.class.php
+ *      \ingroup    member
+ *		\brief      File of class to manage subscriptions of foundation members
+ */
+
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
+
+
+/**
+ *	\class 		Cotisation
+ *	\brief      Class to manage subscriptions of foundation members
+ */
+class Cotisation extends CommonObject
+{
+	public $element='subscription';
+	public $table_element='cotisation';
+
+	var $id;
+	var $datec;
+	var $datem;
+	var $dateh;				// Subscription start date
+	var $datef;				// Subscription end date
+	var $fk_adherent;
+	var $amount;
+	var $note;
+	var $fk_bank;
+
+
+	/**
+	 *	Constructor
+	 *
+	 *	@param 		DoliDB		$db		Database handler
+	 */
+	function Cotisation($db)
+	{
+		$this->db = $db;
+	}
+
+
+	/**
+	 *	Fonction qui permet de creer la cotisation
+	 *
+	 *	@param	int		$userid		userid de celui qui insere
+	 *	@return	int					<0 if KO, Id subscription created if OK
+	 */
+	function create($userid)
+	{
+		global $langs;
+		// Check parameters
+		if ($this->datef <= $this->dateh)
+		{
+			$this->error=$langs->trans("ErrorBadValueForDate");
+			return -1;
+		}
+
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."cotisation (fk_adherent, datec, dateadh, datef, cotisation, note)";
+        $sql.= " VALUES (".$this->fk_adherent.", '".$this->db->idate(mktime())."',";
+		$sql.= " '".$this->db->idate($this->dateh)."',";
+		$sql.= " '".$this->db->idate($this->datef)."',";
+		$sql.= " ".$this->amount.",'".$this->db->escape($this->note)."')";
+
+		dol_syslog(get_class($this)."::create sql=".$sql);
+		$resql = $this->db->query($sql);
+		if ($resql)
+		{
+			return $this->db->last_insert_id(MAIN_DB_PREFIX."cotisation");
+		}
+		else
+		{
+			$this->error=$this->db->error();
+			dol_syslog($this->error, LOG_ERR);
+			return -1;
+		}
+	}
+
+
+	/**
+	 *  Fonction qui permet de recuperer une cotisation
+	 *
+	 *  @param	int		$rowid		Id cotisation
+	 *  @return	int					<0 if KO, =0 if not found, >0 if OK
+	 */
+	function fetch($rowid)
+	{
+        $sql ="SELECT rowid, fk_adherent, datec,";
+		$sql.=" tms,";
+		$sql.=" dateadh,";
+		$sql.=" datef,";
+		$sql.=" cotisation, note, fk_bank";
+		$sql.=" FROM ".MAIN_DB_PREFIX."cotisation";
+		$sql.="	WHERE rowid=".$rowid;
+
+		dol_syslog("Cotisation::fetch sql=".$sql);
+		$resql=$this->db->query($sql);
+		if ($resql)
+		{
+			if ($this->db->num_rows($resql))
+			{
+				$obj = $this->db->fetch_object($resql);
+
+				$this->id             = $obj->rowid;
+				$this->ref            = $obj->rowid;
+
+				$this->fk_adherent    = $obj->fk_adherent;
+				$this->datec          = $this->db->jdate($obj->datec);
+				$this->datem          = $this->db->jdate($obj->tms);
+				$this->dateh          = $this->db->jdate($obj->dateadh);
+				$this->datef          = $this->db->jdate($obj->datef);
+				$this->amount         = $obj->cotisation;
+				$this->note           = $obj->note;
+				$this->fk_bank        = $obj->fk_bank;
+				return 1;
+			}
+			else
+			{
+				return 0;
+			}
+		}
+		else
+		{
+			$this->error=$this->db->error();
+			return -1;
+		}
+	}
+
+
+	/**
+	 *	Met a jour en base la cotisation
+	 *
+	 *	@param	User	$user			Objet user qui met a jour
+	 *	@param 	int		$notrigger		0=Desactive les triggers
+	 *	@return	int						<0 if KO, >0 if OK
+	 */
+	function update($user,$notrigger=0)
+	{
+		$this->db->begin();
+
+		$sql = "UPDATE ".MAIN_DB_PREFIX."cotisation SET ";
+		$sql .= " fk_adherent = ".$this->fk_adherent.",";
+		$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
+		$sql .= " cotisation = '".price2num($this->amount)."',";
+		$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
+		$sql .= " datef='".$this->db->idate($this->datef)."',";
+		$sql .= " datec='".$this->db->idate($this->datec)."',";
+		$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
+		$sql .= " WHERE rowid = ".$this->id;
+
+		dol_syslog("Cotisation::update sql=".$sql);
+		$resql = $this->db->query($sql);
+		if ($resql)
+		{
+			$member=new Adherent($this->db);
+			$result=$member->fetch($this->fk_adherent);
+			$result=$member->update_end_date($user);
+
+			$this->db->commit();
+			return 1;
+		}
+		else
+		{
+			$this->db->rollback();
+			$this->error=$this->db->error();
+			dol_syslog("Cotisation::update ".$this->error, LOG_ERR);
+			return -1;
+		}
+	}
+
+	/**
+	 *	Delete a subscription
+	 *
+	 *	@param	User	$user		User that delete
+	 *	@return	int					<0 if KO, 0 if not found, >0 if OK
+	 */
+	function delete($user)
+	{
+		// It subscription is linked to a bank transaction, we get it
+		if ($this->fk_bank)
+		{
+			require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+			$accountline=new AccountLine($this->db);
+			$result=$accountline->fetch($this->fk_bank);
+		}
+
+		$this->db->begin();
+
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."cotisation WHERE rowid = ".$this->id;
+		dol_syslog("Cotisation::delete sql=".$sql);
+		$resql=$this->db->query($sql);
+		if ($resql)
+		{
+			$num=$this->db->affected_rows($resql);
+			if ($num)
+			{
+				require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+				$member=new Adherent($this->db);
+				$result=$member->fetch($this->fk_adherent);
+				$result=$member->update_end_date($user);
+
+				if ($this->fk_bank)
+				{
+					$result=$accountline->delete($user);		// Return false if refused because line is conciliated
+					if ($result > 0)
+					{
+						$this->db->commit();
+						return 1;
+					}
+					else
+					{
+						$this->error=$accountline->error;
+						$this->db->rollback();
+						return -1;
+					}
+				}
+				else
+				{
+					$this->db->commit();
+					return 1;
+				}
+			}
+			else
+			{
+				$this->db->commit();
+				return 0;
+			}
+		}
+		else
+		{
+			$this->error=$this->db->lasterror();
+			$this->db->rollback();
+			return -1;
+		}
+	}
+
+
+	/**
+	 *  Renvoie nom clicable (avec eventuellement le picto)
+	 *
+	 *	@param	int		$withpicto		0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+	 *	@return	string					Chaine avec URL
+	 */
+	function getNomUrl($withpicto=0)
+	{
+		global $langs;
+
+		$result='';
+
+		$lien = '<a href="'.DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$this->id.'">';
+		$lienfin='</a>';
+
+		$picto='payment';
+		$label=$langs->trans("ShowSubscription");
+
+		if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+		if ($withpicto && $withpicto != 2) $result.=' ';
+		$result.=$lien.$this->ref.$lienfin;
+		return $result;
+	}
+
+
+    /**
+     *  Charge les informations d'ordre info dans l'objet cotisation
+	 *
+     *  @param	int		$id       Id subscription
+     *  @return	void
+     */
+	function info($id)
+	{
+		$sql = 'SELECT c.rowid, c.datec,';
+		$sql.= ' c.tms as datem';
+		$sql.= ' FROM '.MAIN_DB_PREFIX.'cotisation as c';
+		$sql.= ' WHERE c.rowid = '.$id;
+
+		$result=$this->db->query($sql);
+		if ($result)
+		{
+			if ($this->db->num_rows($result))
+			{
+				$obj = $this->db->fetch_object($result);
+				$this->id = $obj->rowid;
+
+				$this->date_creation     = $this->db->jdate($obj->datec);
+				$this->date_modification = $this->db->jdate($obj->datem);
+			}
+
+			$this->db->free($result);
+
+		}
+		else
+		{
+			dol_print_error($this->db);
+		}
+	}
+}
+?>

+ 233 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/cotisations.php

@@ -0,0 +1,233 @@
+<?php
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo <jlb@j1b.org>
+ * Copyright (C) 2004-2009 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/cotisations.php
+ *      \ingroup    member
+ *		\brief      Page de consultation et insertion d'une cotisation
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+
+$langs->load("members");
+
+$filter=$_GET["filter"];
+$statut=isset($_GET["statut"])?$_GET["statut"]:1;
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $conf->liste_limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) {  $sortorder="DESC"; }
+if (! $sortfield) {  $sortfield="c.dateadh"; }
+
+$msg='';
+$date_select=isset($_GET["date_select"])?$_GET["date_select"]:$_POST["date_select"];
+
+if (! $user->rights->adherent->cotisation->lire)
+accessforbidden();
+
+
+/*
+ *	Actions
+ */
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("ListOfSubscriptions"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+if ($msg)	print $msg.'<br>';
+
+// Liste des cotisations
+$sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as lastname, d.societe,";
+$sql.= " c.rowid as crowid, c.cotisation,";
+$sql.= " c.dateadh,";
+$sql.= " c.datef,";
+$sql.= " c.fk_bank as bank, c.note,";
+$sql.= " b.fk_account";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
+$sql.= " WHERE d.rowid = c.fk_adherent";
+if (isset($date_select) && $date_select != '')
+{
+    $sql.= " AND dateadh LIKE '$date_select%'";
+}
+$sql.= $db->order($sortfield,$sortorder);
+$sql.= $db->plimit($conf->liste_limit+1, $offset);
+
+$result = $db->query($sql);
+if ($result)
+{
+    $num = $db->num_rows($result);
+    $i = 0;
+
+    $title=$langs->trans("ListOfSubscriptions");
+    if (! empty($date_select)) $title.=' ('.$langs->trans("Year").' '.$date_select.')';
+    $param.="&amp;statut=$statut&amp;date_select=$date_select";
+    print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num);
+
+
+    print '<table class="noborder" width="100%">';
+
+    print '<tr class="liste_titre">';
+    print_liste_field_titre($langs->trans("Ref"),"cotisations.php","c.rowid",$param,"","",$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("Name"),"cotisations.php","d.nom",$param,"","",$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("Login"),"cotisations.php","d.login",$param,"","",$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("Label"),"cotisations.php","c.note",$param,"",'align="left"',$sortfield,$sortorder);
+    if ($conf->banque->enabled)
+    {
+        print_liste_field_titre($langs->trans("Account"),"cotisations.php","b.fk_account",$pram,"","",$sortfield,$sortorder);
+    }
+    print_liste_field_titre($langs->trans("Date"),"cotisations.php","c.dateadh",$param,"",'align="center"',$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("DateEnd"),"cotisations.php","c.datef",$param,"",'align="center"',$sortfield,$sortorder);
+    print_liste_field_titre($langs->trans("Amount"),"cotisations.php","c.cotisation",$param,"",'align="right"',$sortfield,$sortorder);
+    print "</tr>\n";
+
+    // Static objects
+    $cotisation=new Cotisation($db);
+    $adherent=new Adherent($db);
+    $accountstatic=new Account($db);
+
+    $var=true;
+    $total=0;
+    while ($i < $num && $i < $conf->liste_limit)
+    {
+        $objp = $db->fetch_object($result);
+        $total+=$objp->cotisation;
+
+        $cotisation->ref=$objp->crowid;
+        $cotisation->id=$objp->crowid;
+
+        $adherent->lastname=$objp->lastname;
+        $adherent->firstname=$objp->firstname;
+        $adherent->ref=$adherent->getFullName($langs);
+        $adherent->id=$objp->rowid;
+        $adherent->login=$objp->login;
+
+        $var=!$var;
+
+        if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
+        {
+            print "<form method=\"post\" action=\"cotisations.php\">";
+            print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+        }
+        print "<tr $bc[$var]>";
+
+        // Ref
+        print '<td>'.$cotisation->getNomUrl(1).'</td>';
+
+        // Nom
+        print '<td>'.$adherent->getNomUrl(1).'</td>';
+
+        // Login
+        print '<td>'.$adherent->login.'</td>';
+
+        // Libelle
+        print '<td>';
+        print dol_trunc($objp->note,32);
+        print '</td>';
+
+        // Banque
+        if ($conf->banque->enabled)
+        {
+            if ($objp->fk_account)
+            {
+                $accountstatic->id=$objp->fk_account;
+                $accountstatic->fetch($objp->fk_account);
+                //$accountstatic->label=$objp->label;
+                print '<td>'.$accountstatic->getNomUrl(1).'</td>';
+            }
+            else
+            {
+                print "<td>";
+                if ($allowinsertbankafter && $objp->cotisation)
+                {
+                    print '<input type="hidden" name="action" value="2bank">';
+                    print '<input type="hidden" name="rowid" value="'.$objp->crowid.'">';
+                    $form = new Form($db);
+                    $form->select_comptes('','accountid',0,'',1);
+                    print '<br>';
+                    $form->select_types_paiements('','paymenttypeid');
+                    print '<input name="num_chq" type="text" class="flat" size="5">';
+                }
+                else
+                {
+                    print '&nbsp;';
+                }
+                print "</td>\n";
+            }
+        }
+
+        // Date start
+        print '<td align="center">'.dol_print_date($db->jdate($objp->dateadh),'day')."</td>\n";
+
+        // Date end
+        print '<td align="center">'.dol_print_date($db->jdate($objp->datef),'day')."</td>\n";
+
+        // Price
+        print '<td align="right">'.price($objp->cotisation).'</td>';
+
+        print "</tr>";
+        if ($allowinsertbankafter && ! $objp->fk_account && $conf->banque->enabled && $objp->cotisation)
+        {
+            print "</form>\n";
+        }
+        $i++;
+    }
+
+    // Total
+    $var=!$var;
+    print '<tr class="liste_total">';
+    print "<td>".$langs->trans("Total")."</td>\n";
+    print "<td align=\"right\">&nbsp;</td>\n";
+    print "<td align=\"right\">&nbsp;</td>\n";
+    print "<td align=\"right\">&nbsp;</td>\n";
+    if ($conf->banque->enabled)
+    {
+        print '<td>&nbsp;</td>';
+    }
+   	print '<td>&nbsp;</td>';
+   	print '<td>&nbsp;</td>';
+   	print "<td align=\"right\">".price($total)."</td>\n";
+    print "</tr>\n";
+
+    print "</table>";
+    print "<br>\n";
+
+
+}
+else
+{
+    dol_print_error($db);
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 254 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/document.php

@@ -0,0 +1,254 @@
+<?php
+/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2010      Juanjo Menent        <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       htdocs/adherents/document.php
+ *  \brief      Tab for documents linked to third party
+ *  \ingroup    societe
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("members");
+$langs->load("companies");
+$langs->load('other');
+
+$id=GETPOST('id','int');
+$action=GETPOST('action','alpha');
+$confirm=GETPOST('confirm','alpha');
+
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+	$mesg=$_SESSION['DolMessage'];
+	unset($_SESSION['DolMessage']);
+}
+
+// Security check
+if ($user->societe_id > 0)
+{
+	$id = $user->societe_id;
+}
+$result=restrictedArea($user,'adherent',$id);
+
+// Get parameters
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $conf->liste_limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) $sortorder="ASC";
+if (! $sortfield) $sortfield="name";
+
+
+$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id,2,0,1) . '/' . $id;
+
+
+
+/*
+ * Actions
+ */
+
+// Envoie fichier
+if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+	require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+	if (dol_mkdir($upload_dir) >= 0)
+	{
+		$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
+		if (is_numeric($resupload) && $resupload > 0)
+		{
+		    if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+            {
+                // Create small thumbs for image (Ratio is near 16/9)
+                // Used on logon for example
+                $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+                // Create mini thumbs for image (Ratio is near 16/9)
+                // Used on menu or for setup page for example
+                $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+            }
+		    $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
+		}
+		else
+		{
+			$langs->load("errors");
+			if ($resupload < 0)	// Unknown error
+			{
+				$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
+			}
+			else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload))	// Files infected by a virus
+			{
+				$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
+			}
+			else	// Known error
+			{
+				$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
+			}
+		}
+	}
+}
+
+// Suppression fichier
+if ($action == 'confirm_deletefile' && $confirm == 'yes')
+{
+    $langs->load("other");
+	$file = $upload_dir . "/" . GETPOST('urlfile');	// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+	dol_delete_file($file);
+	$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
+    Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+    exit;
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$member=new Adherent($db);
+$membert=new AdherentType($db);
+
+llxHeader();
+
+if ($id > 0)
+{
+    $result=$member->fetch($id);
+    $result=$membert->fetch($member->typeid);
+	if ($result > 0)
+	{
+		/*
+		 * Affichage onglets
+		 */
+		if ($conf->notification->enabled) $langs->load("mails");
+		$head = member_prepare_head($member);
+
+		$form=new Form($db);
+
+		dol_fiche_head($head, 'document', $langs->trans("Member"),0,'user');
+
+
+		// Construit liste des fichiers
+		$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+		$totalsize=0;
+		foreach($filearray as $key => $file)
+		{
+			$totalsize+=$file['size'];
+		}
+
+
+		print '<table class="border"width="100%">';
+
+        // Ref
+        print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
+        print '<td class="valeur">';
+        print $form->showrefnav($member,'rowid');
+        print '</td></tr>';
+
+        // Login
+        if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+        {
+            print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$member->login.'&nbsp;</td></tr>';
+        }
+
+        // Morphy
+        print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$member->getmorphylib().'</td>';
+        /*print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
+        print $form->showphoto('memberphoto',$member);
+        print '</td>';*/
+        print '</tr>';
+
+        // Type
+        print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
+
+        // Company
+        print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$member->societe.'</td></tr>';
+
+        // Civility
+        print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$member->getCivilityLabel().'&nbsp;</td>';
+        print '</tr>';
+
+        // Nom
+        print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$member->lastname.'&nbsp;</td>';
+        print '</tr>';
+
+        // Prenom
+        print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$member->firstname.'&nbsp;</td>';
+        print '</tr>';
+
+        // Status
+        print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$member->getLibStatut(4).'</td></tr>';
+
+    	// Nbre fichiers
+		print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
+
+		//Total taille
+		print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
+
+		print '</table>';
+
+		print '</div>';
+
+		dol_htmloutput_mesg($mesg,$mesgs);
+
+		/*
+		 * Confirmation suppression fichier
+		 */
+		if ($action == 'delete')
+		{
+			$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$member->id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
+			if ($ret == 'html') print '<br>';
+		}
+
+
+		// Affiche formulaire upload
+		$formfile=new FormFile($db);
+		$formfile->form_attach_new_file(DOL_URL_ROOT.'/adherents/document.php?id='.$member->id,'',0,0,$user->rights->adherent->creer,50,$object);
+
+
+		// List of document
+		$param='&socid='.$societe->id;
+		$formfile->list_of_documents($filearray,$member,'member',$param, 0, get_exdir($member->id,2,0,1).'/'.$member->id.'/');
+
+		print "<br><br>";
+	}
+	else
+	{
+		dol_print_error($db);
+	}
+}
+else
+{
+    $langs->load("errors");
+	print $langs->trans("ErrorRecordNotFound");
+}
+
+
+llxFooter();
+$db->close();
+?>

+ 1543 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/fiche.php

@@ -0,0 +1,1543 @@
+<?php
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/adherents/fiche.php
+ *       \ingroup    member
+ *       \brief      Page of member
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/extrafields.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
+
+$langs->load("companies");
+$langs->load("bills");
+$langs->load("members");
+$langs->load("users");
+
+
+$action=GETPOST('action','alpha');
+$confirm=GETPOST('confirm','alpha');
+$rowid=GETPOST('rowid','int');
+$typeid=GETPOST('typeid','int');
+$userid=GETPOST('userid','int');
+$socid=GETPOST('socid','int');
+
+// Security check
+$result=restrictedArea($user,'adherent',$rowid);
+
+$object = new Adherent($db);
+$extrafields = new ExtraFields($db);
+
+$errmsg=''; $errmsgs=array();
+
+if ($rowid > 0)
+{
+	// Load member
+	$result = $object->fetch($rowid);
+
+	// Define variables to know what current user can do on users
+	$canadduser=($user->admin || $user->rights->user->user->creer);
+	// Define variables to know what current user can do on properties of user linked to edited member
+	if ($object->user_id)
+	{
+		// $user est le user qui edite, $object->user_id est l'id de l'utilisateur lies au membre edite
+		$caneditfielduser=((($user->id == $object->user_id) && $user->rights->user->self->creer)
+		|| (($user->id != $object->user_id) && $user->rights->user->user->creer));
+		$caneditpassworduser=((($user->id == $object->user_id) && $user->rights->user->self->password)
+		|| (($user->id != $object->user_id) && $user->rights->user->user->password));
+	}
+}
+
+// Define variables to know what current user can do on members
+$canaddmember=$user->rights->adherent->creer;
+// Define variables to know what current user can do on properties of a member
+if ($rowid)
+{
+	$caneditfieldmember=$user->rights->adherent->creer;
+}
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+$hookmanager=new HookManager($db);
+$hookmanager->initHooks(array('membercard'));
+
+
+/*
+ * 	Actions
+ */
+
+$parameters=array('socid'=>$socid);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);    // Note that $action and $object may have been modified by some hooks
+
+if ($action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer))
+{
+	$error=0;
+	if (empty($user->rights->user->user->creer))	// If can edit only itself user, we can link to itself only
+	{
+		if ($userid != $user->id && $userid != $object->user_id)
+		{
+			$error++;
+			$mesg='<div class="error">'.$langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly").'</div>';
+		}
+	}
+
+	if (! $error)
+	{
+		if ($userid != $object->user_id)	// If link differs from currently in database
+		{
+			$result=$object->setUserId($userid);
+			if ($result < 0) dol_print_error($object->db,$object->error);
+			$action='';
+		}
+	}
+}
+if ($action == 'setsocid')
+{
+	$error=0;
+	if (! $error)
+	{
+		if ($socid != $object->fk_soc)	// If link differs from currently in database
+		{
+			$sql ="SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
+			$sql.=" WHERE fk_soc = '".$socid."'";
+			$sql.=" AND entity = ".$conf->entity;
+			$resql = $db->query($sql);
+			if ($resql)
+			{
+				$obj = $db->fetch_object($resql);
+				if ($obj && $obj->rowid > 0)
+				{
+					$othermember=new Adherent($db);
+					$othermember->fetch($obj->rowid);
+					$thirdparty=new Societe($db);
+					$thirdparty->fetch($socid);
+					$error++;
+					$errmsg='<div class="error">'.$langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty",$othermember->getFullName($langs),$othermember->login,$thirdparty->name).'</div>';
+				}
+			}
+
+			if (! $error)
+			{
+				$result=$object->setThirdPartyId($socid);
+				if ($result < 0) dol_print_error($object->db,$object->error);
+				$action='';
+			}
+		}
+	}
+}
+
+// Create user from a member
+if ($action == 'confirm_create_user' && $confirm == 'yes' && $user->rights->user->user->creer)
+{
+	if ($result > 0)
+	{
+		// Creation user
+		$nuser = new User($db);
+		$result=$nuser->create_from_member($object,GETPOST('login'));
+
+		if ($result < 0)
+		{
+			$langs->load("errors");
+			$errmsg=$langs->trans($nuser->error);
+		}
+	}
+	else
+	{
+		$errmsg=$object->error;
+	}
+}
+
+// Create third party from a member
+if ($action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->rights->societe->creer)
+{
+	if ($result > 0)
+	{
+		// Creation user
+		$company = new Societe($db);
+		$result=$company->create_from_member($object,GETPOST('companyname'));
+
+		if ($result < 0)
+		{
+			$langs->load("errors");
+			$errmsg=$langs->trans($company->error);
+			$errmsgs=$company->errors;
+		}
+	}
+	else
+	{
+		$errmsg=$object->error;
+	}
+}
+
+if ($action == 'confirm_sendinfo' && $confirm == 'yes')
+{
+	if ($object->email)
+	{
+        $from=$conf->email_from;
+        if ($conf->global->ADHERENT_MAIL_FROM) $from=$conf->global->ADHERENT_MAIL_FROM;
+
+        $result=$object->send_an_email($langs->transnoentitiesnoconv("ThisIsContentOfYourCard")."\n\n%INFOS%\n\n",$langs->transnoentitiesnoconv("CardContent"));
+
+        $langs->load("mails");
+        $mesg=$langs->trans("MailSuccessfulySent", $from, $object->email);
+	}
+}
+
+if ($action == 'update' && ! $_POST["cancel"] && $user->rights->adherent->creer)
+{
+	require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+	$datenaiss='';
+	if (isset($_POST["naissday"]) && $_POST["naissday"]
+		&& isset($_POST["naissmonth"]) && $_POST["naissmonth"]
+		&& isset($_POST["naissyear"]) && $_POST["naissyear"])
+	{
+		$datenaiss=dol_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
+	}
+
+	// Create new object
+	if ($result > 0)
+	{
+		$object->oldcopy=dol_clone($object);
+
+		// Change values
+		$object->civilite_id = trim($_POST["civilite_id"]);
+		$object->prenom      = trim($_POST["prenom"]);     // deprecated
+		$object->nom         = trim($_POST["nom"]);        // deprecated
+		$object->firstname   = trim($_POST["prenom"]);
+		$object->lastname    = trim($_POST["nom"]);
+		$object->login       = trim($_POST["login"]);
+		$object->pass        = trim($_POST["pass"]);
+
+		$object->societe     = trim($_POST["societe"]);
+        $object->adresse     = trim($_POST["address"]);    // deprecated
+		$object->address     = trim($_POST["address"]);
+        $object->cp          = trim($_POST["zipcode"]);    // deprecated
+		$object->zip         = trim($_POST["zipcode"]);
+        $object->ville       = trim($_POST["town"]);       // deprecated
+        $object->town        = trim($_POST["town"]);
+		$object->state_id    = $_POST["departement_id"];
+		$object->country_id  = $_POST["country_id"];
+		$object->fk_departement = $_POST["departement_id"];   // deprecated
+		$object->pays_id     = $_POST["country_id"];   // deprecated
+
+		$object->phone       = trim($_POST["phone"]);
+		$object->phone_perso = trim($_POST["phone_perso"]);
+		$object->phone_mobile= trim($_POST["phone_mobile"]);
+		$object->email       = trim($_POST["email"]);
+		$object->naiss       = $datenaiss;
+
+		$object->typeid      = $_POST["typeid"];
+		//$object->note        = trim($_POST["comment"]);
+		$object->morphy      = $_POST["morphy"];
+
+		$object->amount      = $_POST["amount"];
+
+        if (GETPOST('deletephoto')) $object->photo='';
+		elseif (! empty($_FILES['photo']['name'])) $object->photo  = dol_sanitizeFileName($_FILES['photo']['name']);
+
+		// Get status and public property
+		$object->statut      = $_POST["statut"];
+		$object->public      = $_POST["public"];
+
+		// Get extra fields
+		foreach($_POST as $key => $value)
+		{
+			if (preg_match("/^options_/",$key))
+			{
+				$object->array_options[$key]=$_POST[$key];
+			}
+		}
+
+		// Check if we need to also synchronize user information
+		$nosyncuser=0;
+		if ($object->user_id)	// If linked to a user
+		{
+			if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) $nosyncuser=1;		// Disable synchronizing
+		}
+
+		// Check if we need to also synchronize password information
+		$nosyncuserpass=0;
+		if ($object->user_id)	// If linked to a user
+		{
+			if ($user->id != $object->user_id && empty($user->rights->user->user->password)) $nosyncuserpass=1;	// Disable synchronizing
+		}
+
+		$result=$object->update($user,0,$nosyncuser,$nosyncuserpass);
+		if ($result >= 0 && ! count($object->errors))
+		{
+            $dir= $conf->adherent->dir_output . '/' . get_exdir($object->id,2,0,1).'/photos';
+		    $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
+            if ($file_OK)
+            {
+    		    if (GETPOST('deletephoto'))
+                {
+                    $fileimg=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/'.$object->photo;
+                    $dirthumbs=$conf->adherent->dir_output.'/'.get_exdir($object->id,2,0,1).'/photos/thumbs';
+                    dol_delete_file($fileimg);
+                    dol_delete_dir_recursive($dirthumbs);
+                }
+
+    		    if (image_format_supported($_FILES['photo']['name']) > 0)
+    			{
+    				dol_mkdir($dir);
+
+    				if (@is_dir($dir))
+    				{
+    					$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
+    					if (! dol_move_uploaded_file($_FILES['photo']['tmp_name'],$newfile,1,0,$_FILES['photo']['error']) > 0)
+    					{
+    						$message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
+    					}
+    					else
+    					{
+    						// Create small thumbs for company (Ratio is near 16/9)
+    						// Used on logon for example
+    						$imgThumbSmall = vignette($newfile, $maxwidthsmall, $maxheightsmall, '_small', $quality);
+
+    						// Create mini thumbs for company (Ratio is near 16/9)
+    						// Used on menu or for setup page for example
+    						$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
+    					}
+    				}
+    			}
+    			else
+    			{
+                    $errmsgs[] = "ErrorBadImageFormat";
+    			}
+            }
+
+			$rowid=$object->id;
+			$action='';
+		}
+		else
+		{
+            if ($object->error) $errmsg=$object->error;
+            else $errmsgs=$object->errors;
+			$action='';
+		}
+	}
+}
+
+if ($action == 'add' && $user->rights->adherent->creer)
+{
+	$datenaiss='';
+	if (isset($_POST["naissday"]) && $_POST["naissday"]
+		&& isset($_POST["naissmonth"]) && $_POST["naissmonth"]
+		&& isset($_POST["naissyear"]) && $_POST["naissyear"])
+	{
+		$datenaiss=dol_mktime(12, 0, 0, $_POST["naissmonth"], $_POST["naissday"], $_POST["naissyear"]);
+	}
+	$datecotisation='';
+	if (isset($_POST["reday"]) && isset($_POST["remonth"]) && isset($_POST["reyear"]))
+    {
+		$datecotisation=dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
+	}
+
+    $typeid=$_POST["typeid"];
+	$civilite_id=$_POST["civilite_id"];
+    $nom=$_POST["nom"];
+    $prenom=$_POST["prenom"];
+    $societe=$_POST["societe"];
+    $address=$_POST["address"];
+    $zip=$_POST["zipcode"];
+    $town=$_POST["town"];
+	$state_id=$_POST["departement_id"];
+    $country_id=$_POST["country_id"];
+
+    $phone=$_POST["phone"];
+    $phone_perso=$_POST["phone_perso"];
+    $phone_mobile=$_POST["phone_mobile"];
+    $email=$_POST["member_email"];
+    $login=$_POST["member_login"];
+    $pass=$_POST["password"];
+    $photo=$_POST["photo"];
+    //$comment=$_POST["comment"];
+    $morphy=$_POST["morphy"];
+    $cotisation=$_POST["cotisation"];
+    $public=$_POST["public"];
+
+    $userid=$_POST["userid"];
+    $socid=$_POST["socid"];
+
+    $object->civilite_id = $civilite_id;
+    $object->prenom      = $prenom;    // deprecated
+    $object->nom         = $nom;       // deprecated
+    $object->firstname   = $prenom;
+    $object->lastname    = $nom;
+    $object->societe     = $societe;
+    $object->adresse     = $address; // deprecated
+    $object->address     = $address;
+    $object->cp          = $zip;     // deprecated
+    $object->zip         = $zip;
+    $object->ville       = $town;    // deprecated
+    $object->town        = $town;
+    $object->fk_departement = $state_id;
+    $object->state_id    = $state_id;
+    $object->pays_id     = $country_id;
+    $object->country_id  = $country_id;
+    $object->phone       = $phone;
+    $object->phone_perso = $phone_perso;
+    $object->phone_mobile= $phone_mobile;
+    $object->email       = $email;
+    $object->login       = $login;
+    $object->pass        = $pass;
+    $object->naiss       = $datenaiss;
+    $object->photo       = $photo;
+    $object->typeid      = $typeid;
+    //$object->note        = $comment;
+    $object->morphy      = $morphy;
+    $object->user_id     = $userid;
+    $object->fk_soc      = $socid;
+    $object->public      = $public;
+
+    // Get extra fields
+    foreach($_POST as $key => $value)
+    {
+        if (preg_match("/^options_/",$key))
+        {
+            $object->array_options[$key]=$_POST[$key];
+        }
+    }
+
+    // Check parameters
+    if (empty($morphy) || $morphy == "-1") {
+    	$error++;
+        $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Nature"))."<br>\n";
+    }
+    // Test si le login existe deja
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        if (empty($login)) {
+            $error++;
+            $errmsg .= $langs->trans("ErrorFieldRequired",$langs->trans("Login"))."<br>\n";
+        }
+        else {
+            $sql = "SELECT login FROM ".MAIN_DB_PREFIX."adherent WHERE login='".$db->escape($login)."'";
+            $result = $db->query($sql);
+            if ($result) {
+                $num = $db->num_rows($result);
+            }
+            if ($num) {
+                $error++;
+                $langs->load("errors");
+                $errmsg .= $langs->trans("ErrorLoginAlreadyExists",$login)."<br>\n";
+            }
+        }
+        if (empty($pass)) {
+            $error++;
+            $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Password"))."<br>\n";
+        }
+    }
+    if (empty($nom)) {
+        $error++;
+        $langs->load("errors");
+        $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Lastname"))."<br>\n";
+    }
+	if ($morphy != 'mor' && (!isset($prenom) || $prenom=='')) {
+		$error++;
+        $langs->load("errors");
+		$errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentities("Firstname"))."<br>\n";
+    }
+    if (! ($typeid > 0)) {	// Keep () before !
+        $error++;
+        $errmsg .= $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type"))."<br>\n";
+    }
+    if ($conf->global->ADHERENT_MAIL_REQUIRED && ! isValidEMail($email)) {
+        $error++;
+        $langs->load("errors");
+        $errmsg .= $langs->trans("ErrorBadEMail",$email)."<br>\n";
+    }
+    $public=0;
+    if (isset($public)) $public=1;
+
+    if (! $error)
+    {
+		$db->begin();
+
+		// Email a peu pres correct et le login n'existe pas
+        $result=$object->create($user);
+		if ($result > 0)
+        {
+			$db->commit();
+			$rowid=$object->id;
+			$action='';
+        }
+        else
+		{
+			$db->rollback();
+
+			if ($object->error) $errmsg=$object->error;
+			else $errmsgs=$object->errors;
+
+			$action = 'create';
+        }
+    }
+    else {
+        $action = 'create';
+    }
+}
+
+if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
+{
+    $result=$object->delete($rowid);
+    if ($result > 0)
+    {
+    	Header("Location: liste.php");
+    	exit;
+    }
+    else
+    {
+    	$errmesg=$object->error;
+    }
+}
+
+if ($user->rights->adherent->creer && $action == 'confirm_valid' && $confirm == 'yes')
+{
+    $result=$object->validate($user);
+
+    $adht = new AdherentType($db);
+    $adht->fetch($object->typeid);
+
+	if ($result >= 0 && ! count($object->errors))
+	{
+        // Send confirmation Email (selon param du type adherent sinon generique)
+		if ($object->email && $_POST["send_mail"])
+		{
+			$result=$object->send_an_email($adht->getMailOnValid(),$conf->global->ADHERENT_MAIL_VALID_SUBJECT,array(),array(),array(),"","",0,2);
+			if ($result < 0)
+			{
+				$errmsg.=$object->error;
+			}
+		}
+
+	    // Rajoute l'utilisateur dans les divers abonnements (mailman, spip, etc...)
+	    if ($object->add_to_abo() < 0)
+	    {
+	        // error
+	        $errmsg.= $langs->trans("FaildToAddToMailmanList").': '.$object->error."<br>\n";
+	    }
+	}
+	else
+	{
+        if ($object->error) $errmsg=$object->error;
+        else $errmsgs=$object->errors;
+		$action='';
+	}
+}
+
+if ($user->rights->adherent->supprimer && $action == 'confirm_resign' && $confirm == 'yes')
+{
+    $adht = new AdherentType($db);
+    $adht->fetch($object->typeid);
+
+    $result=$object->resiliate($user);
+
+    if ($result >= 0 && ! count($object->errors))
+	{
+	    if ($object->email && $_POST["send_mail"])
+		{
+			$result=$object->send_an_email($adht->getMailOnResiliate(),$conf->global->ADHERENT_MAIL_RESIL_SUBJECT,array(),array(),array(),"","",0,-1);
+		}
+		if ($result < 0)
+		{
+			$errmsg.=$object->error;
+		}
+
+	    // supprime l'utilisateur des divers abonnements ..
+	    if ($object->del_to_abo() < 0)
+	    {
+	        // error
+	        $errmsg.=$langs->trans("FaildToRemoveFromMailmanList").': '.$object->error."<br>\n";
+	    }
+	}
+	else
+	{
+		if ($object->error) $errmsg=$object->error;
+		else $errmsgs=$object->errors;
+		$action='';
+	}
+}
+
+if ($user->rights->adherent->supprimer && $action == 'confirm_del_spip' && $confirm == 'yes')
+{
+	if (! count($object->errors))
+	{
+	    if(!$object->del_to_spip())
+	    {
+	        $errmsg.="Echec de la suppression de l'utilisateur dans spip: ".$object->error."<BR>\n";
+	    }
+	}
+}
+
+if ($user->rights->adherent->creer && $action == 'confirm_add_spip' && $confirm == 'yes')
+{
+	if (! count($object->errors))
+	{
+	    if (!$object->add_to_spip())
+	    {
+	        $errmsg.="Echec du rajout de l'utilisateur dans spip: ".$object->error."<BR>\n";
+	    }
+	}
+}
+
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formcompany = new FormCompany($db);
+
+// fetch optionals attributes and labels
+$extralabels=$extrafields->fetch_name_optionals_label('member');
+
+$help_url='EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros';
+llxHeader('',$langs->trans("Member"),$help_url);
+
+$countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
+
+if ($action == 'create')
+{
+    /* ************************************************************************** */
+    /*                                                                            */
+    /* Fiche creation                                                             */
+    /*                                                                            */
+    /* ************************************************************************** */
+    $object->fk_departement = $_POST["departement_id"];
+
+    // We set country_id, country_code and country for the selected country
+    $object->country_id=GETPOST('country_id','int')?GETPOST('country_id','int'):$mysoc->country_id;
+    if ($object->country_id)
+    {
+    	$tmparray=getCountry($object->country_id,'all');
+        $object->pays_code=$tmparray['code'];
+        $object->pays=$tmparray['code'];
+        $object->country_code=$tmparray['code'];
+        $object->country=$tmparray['label'];
+    }
+
+    $adht = new AdherentType($db);
+
+    print_fiche_titre($langs->trans("NewMember"));
+
+    dol_htmloutput_mesg($errmsg,$errmsgs,'error');
+    dol_htmloutput_mesg($mesg,$mesgs);
+
+    if ($conf->use_javascript_ajax)
+    {
+        print "\n".'<script type="text/javascript" language="javascript">';
+        print 'jQuery(document).ready(function () {
+                    jQuery("#selectcountry_id").change(function() {
+                        document.formsoc.action.value="create";
+                        document.formsoc.submit();
+                    });
+               })';
+        print '</script>'."\n";
+    }
+
+    print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="add">';
+
+    print '<table class="border" width="100%">';
+
+    // Login
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td><input type="text" name="member_login" size="40" value="'.(isset($_POST["member_login"])?$_POST["member_login"]:$object->login).'"></td></tr>';
+    }
+
+    // Moral-Physique
+    $morphys["phy"] = $langs->trans("Physical");
+    $morphys["mor"] = $langs->trans("Moral");
+    print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature")."</span></td><td>\n";
+    print $form->selectarray("morphy", $morphys, GETPOST('morphy','alpha')?GETPOST('morphy','alpha'):$object->morphy, 1);
+    print "</td>\n";
+
+    // Type
+    print '<tr><td><span class="fieldrequired">'.$langs->trans("MemberType").'</span></td><td>';
+    $listetype=$adht->liste_array();
+    if (count($listetype))
+    {
+        print $form->selectarray("typeid", $listetype, GETPOST('typeid','int')?GETPOST('typeid','int'):$typeid, 1);
+    } else {
+        print '<font class="error">'.$langs->trans("NoTypeDefinedGoToSetup").'</font>';
+    }
+    print "</td>\n";
+
+    // Company
+    print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(GETPOST('societe','alpha')?GETPOST('societe','alpha'):$object->societe).'"></td></tr>';
+
+    // Civility
+    print '<tr><td>'.$langs->trans("UserTitle").'</td><td>';
+    print $formcompany->select_civility(GETPOST('civilite_id','int')?GETPOST('civilite_id','int'):$object->civilite_id,'civilite_id').'</td>';
+    print '</tr>';
+
+    // Lastname
+    print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" value="'.(GETPOST('nom','alpha')?GETPOST('nom','alpha'):$object->lastname).'" size="40"></td>';
+    print '</tr>';
+
+    // Firstname
+    print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(GETPOST('prenom','alpha')?GETPOST('prenom','alpha'):$object->firstname).'"></td>';
+    print '</tr>';
+
+    // Password
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
+        $generated_password=getRandomPassword('');
+        print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td>';
+        print '<input size="30" maxsize="32" type="text" name="password" value="'.$generated_password.'">';
+        print '</td></tr>';
+    }
+
+    // Address
+    print '<tr><td valign="top">'.$langs->trans("Address").'</td><td>';
+    print '<textarea name="address" wrap="soft" cols="40" rows="2">'.(GETPOST('address','alpha')?GETPOST('address','alpha'):$object->address).'</textarea>';
+    print '</td></tr>';
+
+    // Zip / Town
+    print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
+    print $formcompany->select_ziptown((GETPOST('zipcode','alpha')?GETPOST('zipcode','alpha'):$object->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+    print ' ';
+    print $formcompany->select_ziptown((GETPOST('town','alpha')?GETPOST('town','alpha'):$object->town),'town',array('zipcode','selectcountry_id','departement_id'));
+    print '</td></tr>';
+
+    // Country
+    $object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;
+    print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
+    print $form->select_country(GETPOST('country_id','alpha')?GETPOST('country_id','alpha'):$object->country_id,'country_id');
+    if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+    print '</td></tr>';
+
+    // State
+    if (empty($conf->global->MEMBER_DISABLE_STATE))
+    {
+        print '<tr><td>'.$langs->trans('State').'</td><td>';
+        if ($object->country_id)
+        {
+            print $formcompany->select_state(GETPOST('departement_id','int')?GETPOST('departement_id','int'):$object->fk_departement,$object->country_code);
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // Tel pro
+    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>';
+
+    // Tel perso
+    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>';
+
+    // Tel mobile
+    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>';
+
+    // 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" size="40" value="'.(GETPOST('member_email','alpha')?GETPOST('member_email','alpha'):$object->email).'"></td></tr>';
+
+    // Birthday
+    print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
+    $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc');
+    print "</td></tr>\n";
+
+    // Profil public
+    print "<tr><td>".$langs->trans("Public")."</td><td>\n";
+    print $form->selectyesno("public",$object->public,1);
+    print "</td></tr>\n";
+
+    // Other attributes
+    $parameters=array();
+    $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
+    {
+        foreach($extrafields->attribute_label as $key=>$label)
+        {
+            $value=(isset($_POST["options_".$key])?GETPOST('options_'.$key,'alpha'):$object->array_options["options_".$key]);
+            print '<tr><td>'.$label.'</td><td>';
+            print $extrafields->showInputField($key,$value);
+            print '</td></tr>'."\n";
+        }
+    }
+
+	/*
+    // Third party Dolibarr
+    if ($conf->societe->enabled)
+    {
+        print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td class="valeur">';
+        print $form->select_company($object->fk_soc,'socid','',1);
+        print '</td></tr>';
+    }
+
+    // Login Dolibarr
+    print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td class="valeur">';
+    print $form->select_users($object->user_id,'userid',1);
+    print '</td></tr>';
+	*/
+
+    print "</table>\n";
+    print '<br>';
+
+    print '<center><input type="submit" class="button" value="'.$langs->trans("AddMember").'"></center>';
+
+    print "</form>\n";
+
+}
+
+if ($action == 'edit')
+{
+	/********************************************
+	 *
+	 * Fiche en mode edition
+	 *
+	 ********************************************/
+
+    $res=$object->fetch($rowid);
+    if ($res < 0) { dol_print_error($db,$object->error); exit; }
+    $res=$object->fetch_optionals($object->id,$extralabels);
+    if ($res < 0) { dol_print_error($db); exit; }
+
+	$adht = new AdherentType($db);
+    $adht->fetch($object->typeid);
+
+	// We set country_id, and country_code, country of the chosen country
+	if (isset($_POST["pays"]) || $object->country_id)
+	{
+		$sql = "SELECT rowid, code, libelle as label from ".MAIN_DB_PREFIX."c_pays where rowid = ".(isset($_POST["pays"])?$_POST["pays"]:$object->country_id);
+		$resql=$db->query($sql);
+		if ($resql)
+		{
+			$obj = $db->fetch_object($resql);
+		}
+		else
+		{
+			dol_print_error($db);
+		}
+		$object->pays_id=$obj->rowid;
+		$object->pays_code=$obj->code;
+		$object->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
+		$object->country_id=$obj->rowid;
+		$object->country_code=$obj->code;
+		$object->country=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label;
+	}
+
+	$head = member_prepare_head($object);
+
+	dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
+
+	dol_htmloutput_errors($errmsg,$errmsgs);
+	dol_htmloutput_mesg($mesg);
+
+	if ($conf->use_javascript_ajax)
+	{
+        print "\n".'<script type="text/javascript" language="javascript">';
+        print 'jQuery(document).ready(function () {
+                    jQuery("#selectcountry_id").change(function() {
+	               	    document.formsoc.action.value="edit";
+                        document.formsoc.submit();
+                    });
+               })';
+        print '</script>'."\n";
+	}
+
+	$rowspan=15;
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
+	if ($conf->societe->enabled) $rowspan++;
+
+	print '<form name="formsoc" action="'.$_SERVER["PHP_SELF"].'" method="post" enctype="multipart/form-data">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
+	print '<input type="hidden" name="action" value="update" />';
+	print '<input type="hidden" name="rowid" value="'.$rowid.'" />';
+	print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
+
+	print '<table class="border" width="100%">';
+
+    // Ref
+    print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$object->id.'</td></tr>';
+
+    // Login
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td><span class="fieldrequired">'.$langs->trans("Login").' / '.$langs->trans("Id").'</span></td><td colspan="2"><input type="text" name="login" size="30" value="'.(isset($_POST["login"])?$_POST["login"]:$object->login).'"></td></tr>';
+    }
+
+    // Physique-Moral
+	$morphys["phy"] = $langs->trans("Physical");
+	$morphys["mor"] = $langs->trans("Morale");
+	print '<tr><td><span class="fieldrequired">'.$langs->trans("Nature").'</span></td><td>';
+	print $form->selectarray("morphy",  $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy);
+	print "</td>";
+    // Photo
+    print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
+    print $form->showphoto('memberphoto',$object)."\n";
+    if ($caneditfieldmember)
+    {
+        if ($object->photo) print "<br>\n";
+        print '<table class="nobordernopadding">';
+        if ($object->photo) print '<tr><td align="center"><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
+        print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
+        print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
+        print '</table>';
+    }
+    print '</td>';
+
+    // Type
+    print '<tr><td><span class="fieldrequired">'.$langs->trans("Type").'</span></td><td>';
+    if ($user->rights->adherent->creer)
+    {
+        print $form->selectarray("typeid",  $adht->liste_array(), (isset($_POST["typeid"])?$_POST["typeid"]:$object->typeid));
+    }
+    else
+    {
+        print $adht->getNomUrl(1);
+        print '<input type="hidden" name="typeid" value="'.$object->typeid.'">';
+    }
+    print "</td></tr>";
+
+	// Company
+	print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.(isset($_POST["societe"])?$_POST["societe"]:$object->societe).'"></td></tr>';
+
+	// Civilite
+	print '<tr><td width="20%">'.$langs->trans("UserTitle").'</td><td width="35%">';
+	print $formcompany->select_civility(isset($_POST["civilite_id"])?$_POST["civilite_id"]:$object->civilite_id)."\n";
+	print '</td>';
+	print '</tr>';
+
+	// Name
+	print '<tr><td><span class="fieldrequired">'.$langs->trans("Lastname").'</span></td><td><input type="text" name="nom" size="40" value="'.(isset($_POST["nom"])?$_POST["nom"]:$object->lastname).'"></td>';
+	print '</tr>';
+
+	// Firstname
+	print '<tr><td><span class="fieldrequired">'.$langs->trans("Firstname").'</td><td><input type="text" name="prenom" size="40" value="'.(isset($_POST["prenom"])?$_POST["prenom"]:$object->firstname).'"></td>';
+	print '</tr>';
+
+	// Password
+	if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+	{
+	    print '<tr><td><span class="fieldrequired">'.$langs->trans("Password").'</span></td><td><input type="password" name="pass" size="30" value="'.(isset($_POST["pass"])?$_POST["pass"]:$object->pass).'"></td></tr>';
+	}
+
+	// Address
+	print '<tr><td>'.$langs->trans("Address").'</td><td>';
+	print '<textarea name="address" wrap="soft" cols="40" rows="2">'.(isset($_POST["address"])?$_POST["address"]:$object->address).'</textarea>';
+	print '</td></tr>';
+
+    // Zip / Town
+    print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
+    print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','departement_id'),6);
+    print ' ';
+    print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','departement_id'));
+    print '</td></tr>';
+
+    // Country
+    //$object->country_id=$object->country_id?$object->country_id:$mysoc->country_id;    // In edit mode we don't force to company country if not defined
+    print '<tr><td width="25%">'.$langs->trans('Country').'</td><td>';
+    print $form->select_country(isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id,'country_id');
+    if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+    print '</td></tr>';
+
+    // State
+    if (empty($conf->global->MEMBER_DISABLE_STATE))
+    {
+    	print '<tr><td>'.$langs->trans('State').'</td><td>';
+    	print $formcompany->select_state($object->fk_departement,isset($_POST["country_id"])?$_POST["country_id"]:$object->country_id);
+    	print '</td></tr>';
+    }
+
+	// Tel
+	print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?$_POST["phone"]:$object->phone).'"></td></tr>';
+
+	// Tel perso
+	print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?$_POST["phone_perso"]:$object->phone_perso).'"></td></tr>';
+
+	// Tel mobile
+	print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?$_POST["phone_mobile"]:$object->phone_mobile).'"></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="email" size="40" value="'.(isset($_POST["email"])?$_POST["email"]:$object->email).'"></td></tr>';
+
+	// Date naissance
+    print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
+    $form->select_date(($object->naiss ? $object->naiss : -1),'naiss','','',1,'formsoc');
+    print "</td></tr>\n";
+
+	// Profil public
+    print "<tr><td>".$langs->trans("Public")."</td><td>\n";
+    print $form->selectyesno("public",(isset($_POST["public"])?$_POST["public"]:$object->public),1);
+    print "</td></tr>\n";
+
+	// Other attributes
+	$parameters=array();
+    $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
+    {
+    	foreach($extrafields->attribute_label as $key=>$label)
+    	{
+    	    $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]);
+    		print '<tr><td>'.$label.'</td><td>';
+            print $extrafields->showInputField($key,$value);
+    		print '</td></tr>'."\n";
+    	}
+    }
+
+	// Third party Dolibarr
+    if ($conf->societe->enabled)
+    {
+    	print '<tr><td>'.$langs->trans("LinkedToDolibarrThirdParty").'</td><td colspan="2" class="valeur">';
+    	if ($object->fk_soc)
+	    {
+	    	$company=new Societe($db);
+	    	$result=$company->fetch($object->fk_soc);
+	    	print $company->getNomUrl(1);
+	    }
+	    else
+	    {
+	    	print $langs->trans("NoThirdPartyAssociatedToMember");
+	    }
+	    print '</td></tr>';
+    }
+
+    // Login Dolibarr
+	print '<tr><td>'.$langs->trans("LinkedToDolibarrUser").'</td><td colspan="2" class="valeur">';
+	if ($object->user_id)
+	{
+		print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+	}
+	else print $langs->trans("NoDolibarrAccess");
+	print '</td></tr>';
+
+	print '</table>';
+
+	print '<br><center>';
+	print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
+	print ' &nbsp; &nbsp; &nbsp; ';
+	print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+	print '</center';
+
+	print '</form>';
+
+	print '</div>';
+}
+
+if ($rowid && $action != 'edit')
+{
+	dol_htmloutput_mesg($mesg);
+
+    /* ************************************************************************** */
+	/*                                                                            */
+	/* Mode affichage                                                             */
+	/*                                                                            */
+	/* ************************************************************************** */
+
+    $res=$object->fetch($rowid);
+    if ($res < 0) { dol_print_error($db,$object->error); exit; }
+    $res=$object->fetch_optionals($object->id,$extralabels);
+	if ($res < 0) { dol_print_error($db); exit; }
+
+    $adht = new AdherentType($db);
+    $res=$adht->fetch($object->typeid);
+	if ($res < 0) { dol_print_error($db); exit; }
+
+
+	/*
+	 * Affichage onglets
+	 */
+	$head = member_prepare_head($object);
+
+	dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
+
+	dol_htmloutput_errors($errmsg,$errmsgs);
+
+	// Confirm create user
+	if ($_GET["action"] == 'create_user')
+	{
+		$login=$object->login;
+		if (empty($login))
+		{
+			// Full firstname and name separated with a dot : firstname.name
+			include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php');
+			$login=dol_buildlogin($object->lastname,$object->firstname);
+		}
+		if (empty($login)) $login=strtolower(substr($object->firstname, 0, 4)) . strtolower(substr($object->lastname, 0, 4));
+
+		// Create a form array
+		$formquestion=array(
+		array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login)
+		);
+        $text=$langs->trans("ConfirmCreateLogin").'<br>';
+        if ($conf->societe->enabled)
+        {
+            if ($object->fk_soc > 0) $text.=$langs->trans("UserWillBeExternalUser");
+            else $text.=$langs->trans("UserWillBeInternalUser");
+        }
+		$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrLogin"),$text,"confirm_create_user",$formquestion,'yes');
+		if ($ret == 'html') print '<br>';
+	}
+
+	// Confirm create third party
+	if ($_GET["action"] == 'create_thirdparty')
+	{
+		$name = $object->getFullName($langs);
+		if (! empty($name))
+		{
+			if ($object->societe) $name.=' ('.$object->societe.')';
+		}
+		else
+		{
+			$name=$object->societe;
+		}
+
+		// Create a form array
+		$formquestion=array(		array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
+
+		$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$object->id,$langs->trans("CreateDolibarrThirdParty"),$langs->trans("ConfirmCreateThirdParty"),"confirm_create_thirdparty",$formquestion,1);
+		if ($ret == 'html') print '<br>';
+	}
+
+    // Confirm validate member
+    if ($action == 'valid')
+    {
+		$langs->load("mails");
+
+        $adht = new AdherentType($db);
+        $adht->fetch($object->typeid);
+
+        $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_VALID_SUBJECT);
+        $texttosend=$object->makeSubstitution($adht->getMailOnValid());
+
+        $tmp=$langs->trans("SendAnEMailToMember");
+        $tmp.=' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
+        $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
+        $helpcontent='';
+        $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
+        $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
+		$helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
+        $helpcontent.=$subjecttosend."\n";
+        $helpcontent.="<br>";
+        $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
+        $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
+		$label=$form->textwithpicto($tmp,$helpcontent,1,'help');
+
+        // Cree un tableau formulaire
+        $formquestion=array();
+		if ($object->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label,  'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?true:false));
+        $ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ValidateMember"),$langs->trans("ConfirmValidateMember"),"confirm_valid",$formquestion,1);
+        if ($ret == 'html') print '<br>';
+    }
+
+    // Confirm send card by mail
+    if ($action == 'sendinfo')
+    {
+        $ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("SendCardByMail"),$langs->trans("ConfirmSendCardByMail",$object->email),"confirm_sendinfo",'',0,1);
+        if ($ret == 'html') print '<br>';
+    }
+
+    // Confirm resiliate
+    if ($action == 'resign')
+    {
+		$langs->load("mails");
+
+        $adht = new AdherentType($db);
+        $adht->fetch($object->typeid);
+
+        $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_RESIL_SUBJECT);
+        $texttosend=$object->makeSubstitution($adht->getMailOnResiliate());
+
+        $tmp=$langs->trans("SendAnEMailToMember");
+        $tmp.=' ('.$langs->trans("MailFrom").': <b>'.$conf->global->ADHERENT_MAIL_FROM.'</b>, ';
+        $tmp.=$langs->trans("MailRecipient").': <b>'.$object->email.'</b>)';
+        $helpcontent='';
+        $helpcontent.='<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
+        $helpcontent.='<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
+        $helpcontent.='<b>'.$langs->trans("Subject").'</b>:<br>'."\n";
+        $helpcontent.=$subjecttosend."\n";
+        $helpcontent.="<br>";
+        $helpcontent.='<b>'.$langs->trans("Content").'</b>:<br>';
+        $helpcontent.=dol_htmlentitiesbr($texttosend)."\n";
+        $label=$form->textwithpicto($tmp,$helpcontent,1,'help');
+
+        // Cree un tableau formulaire
+		$formquestion=array();
+		if ($object->email) $formquestion[0]=array('type' => 'checkbox', 'name' => 'send_mail', 'label' => $label, 'value' => ($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL?'true':'false'));
+		$ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("ResiliateMember"),$langs->trans("ConfirmResiliateMember"),"confirm_resign",$formquestion);
+        if ($ret == 'html') print '<br>';
+    }
+
+	// Confirm remove member
+    if ($action == 'delete')
+    {
+        $ret=$form->form_confirm("fiche.php?rowid=$rowid",$langs->trans("DeleteMember"),$langs->trans("ConfirmDeleteMember"),"confirm_delete",'',0,1);
+        if ($ret == 'html') print '<br>';
+    }
+
+    /*
+    * Confirm add in spip
+    */
+    if ($action == 'add_spip')
+    {
+        $ret=$form->form_confirm("fiche.php?rowid=$rowid","Ajouter dans spip","Etes-vous sur de vouloir ajouter cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_add_spip");
+        if ($ret == 'html') print '<br>';
+    }
+
+    /*
+    * Confirm removed from spip
+    */
+    if ($action == 'del_spip')
+    {
+        $ret=$form->form_confirm("fiche.php?rowid=$rowid","Supprimer dans spip","Etes-vous sur de vouloir effacer cet adherent dans spip ? (serveur : ".ADHERENT_SPIP_SERVEUR.")","confirm_del_spip");
+        if ($ret == 'html') print '<br>';
+    }
+
+    $rowspan=17;
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++;
+    if ($conf->societe->enabled) $rowspan++;
+
+    print '<table class="border" width="100%">';
+
+    // Ref
+    print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
+	print '<td class="valeur" colspan="2">';
+	print $form->showrefnav($object,'rowid');
+	print '</td></tr>';
+
+    $showphoto='<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
+    $showphoto.=$form->showphoto('memberphoto',$object);
+    $showphoto.='</td>';
+
+    // Login
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td>';
+        print $showphoto; $showphoto='';
+        print '</tr>';
+    }
+
+	// Morphy
+    print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
+    print $showphoto; $showphoto='';
+    print '</tr>';
+
+    // Type
+    print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
+
+    // Company
+    print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
+
+	// Civility
+    print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
+	print '</tr>';
+
+    // Name
+    print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$object->lastname.'&nbsp;</td>';
+	print '</tr>';
+
+    // Firstname
+    print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$object->firstname.'&nbsp;</td></tr>';
+
+	// Password
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i','*',$object->pass).'</td></tr>';
+    }
+
+    // Address
+    print '<tr><td>'.$langs->trans("Address").'</td><td class="valeur">';
+    dol_print_address($object->address,'gmap','member',$object->id);
+    print '</td></tr>';
+
+    // Zip / Town
+    print '<tr><td nowrap="nowrap">'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$object->zip.(($object->zip && $object->town)?' / ':'').$object->town.'</td></tr>';
+
+	// Country
+    print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">';
+	$img=picto_from_langcode($object->country_code);
+	if ($img) print $img.' ';
+    print getCountry($object->country_code);
+    print '</td></tr>';
+
+	// State
+	print '<tr><td>'.$langs->trans('State').'</td><td class="valeur">'.$object->departement.'</td>';
+
+    // Tel pro.
+    print '<tr><td>'.$langs->trans("PhonePro").'</td><td class="valeur">'.dol_print_phone($object->phone,$object->country_code,0,$object->fk_soc,1).'</td></tr>';
+
+    // Tel perso
+    print '<tr><td>'.$langs->trans("PhonePerso").'</td><td class="valeur">'.dol_print_phone($object->phone_perso,$object->country_code,0,$object->fk_soc,1).'</td></tr>';
+
+    // Tel mobile
+    print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td class="valeur">'.dol_print_phone($object->phone_mobile,$object->country_code,0,$object->fk_soc,1).'</td></tr>';
+
+    // EMail
+    print '<tr><td>'.$langs->trans("EMail").'</td><td class="valeur">'.dol_print_email($object->email,0,$object->fk_soc,1).'</td></tr>';
+
+	// Date naissance
+    print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.dol_print_date($object->naiss,'day').'</td></tr>';
+
+    // Public
+    print '<tr><td>'.$langs->trans("Public").'</td><td class="valeur">'.yn($object->public).'</td></tr>';
+
+    // Status
+    print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
+
+    // Other attributes
+    $parameters=array();
+    $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action);    // Note that $action and $object may have been modified by hook
+    if (empty($reshook) && ! empty($extrafields->attribute_label))
+    {
+        foreach($extrafields->attribute_label as $key=>$label)
+        {
+            $value=$object->array_options["options_$key"];
+            print "<tr><td>".$label."</td><td>";
+            print $extrafields->showOutputField($key,$value);
+            print "</td></tr>\n";
+        }
+    }
+
+	// Third party Dolibarr
+    if ($conf->societe->enabled)
+    {
+	    print '<tr><td>';
+		print '<table class="nobordernopadding" width="100%"><tr><td>';
+	    print $langs->trans("LinkedToDolibarrThirdParty");
+	    print '</td>';
+		if ($_GET['action'] != 'editthirdparty' && $user->rights->adherent->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editthirdparty&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToThirdParty'),1).'</a></td>';
+		print '</tr></table>';
+	    print '</td><td colspan="2" class="valeur">';
+		if ($_GET['action'] == 'editthirdparty')
+		{
+			$htmlname='socid';
+			print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" name="form'.$htmlname.'">';
+            print '<input type="hidden" name="rowid" value="'.$object->id.'">';
+			print '<input type="hidden" name="action" value="set'.$htmlname.'">';
+			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+			print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
+			print '<tr><td>';
+			print $form->select_company($object->fk_soc,'socid','',1);
+			print '</td>';
+			print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+			print '</tr></table></form>';
+		}
+		else
+		{
+			if ($object->fk_soc)
+		    {
+		    	$company=new Societe($db);
+		    	$result=$company->fetch($object->fk_soc);
+		    	print $company->getNomUrl(1);
+		    }
+		    else
+		    {
+		    	print $langs->trans("NoThirdPartyAssociatedToMember");
+		    }
+		}
+	    print '</td></tr>';
+    }
+
+	// Login Dolibarr
+	print '<tr><td>';
+	print '<table class="nobordernopadding" width="100%"><tr><td>';
+	print $langs->trans("LinkedToDolibarrUser");
+	print '</td>';
+	if ($_GET['action'] != 'editlogin' && $user->rights->adherent->creer)
+	{
+	    print '<td align="right">';
+	    if ($user->rights->user->user->creer)
+	    {
+	        print '<a href="'.$_SERVER["PHP_SELF"].'?action=editlogin&amp;rowid='.$object->id.'">'.img_edit($langs->trans('SetLinkToUser'),1).'</a>';
+	    }
+	    print '</td>';
+	}
+	print '</tr></table>';
+	print '</td><td colspan="2" class="valeur">';
+	if ($_GET['action'] == 'editlogin')
+	{
+	    print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'userid','');
+	}
+	else
+	{
+		if ($object->user_id)
+		{
+			print $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id,$object->user_id,'none');
+		}
+		else print $langs->trans("NoDolibarrAccess");
+	}
+	print '</td></tr>';
+
+    print "</table>\n";
+
+    print "</div>\n";
+
+
+    /*
+     * Barre d'actions
+     *
+     */
+    print '<div class="tabsAction">';
+
+    if ($action != 'valid' && $action != 'editlogin' && $action != 'editthirdparty')
+    {
+	    // Modify
+		if ($user->rights->adherent->creer)
+		{
+			print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=edit\">".$langs->trans("Modify")."</a>";
+	    }
+		else
+		{
+			print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("Modify")."</font>";
+		}
+
+		// Valider
+		if ($object->statut == -1)
+		{
+			if ($user->rights->adherent->creer)
+			{
+				print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=valid\">".$langs->trans("Validate")."</a>\n";
+			}
+			else
+			{
+				print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("Validate")."</font>";
+			}
+		}
+
+		// Reactiver
+		if ($object->statut == 0)
+		{
+			if ($user->rights->adherent->creer)
+			{
+		        print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=valid\">".$langs->trans("Reenable")."</a>\n";
+		    }
+			else
+			{
+				print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("Reenable")."</font>";
+			}
+		}
+
+		// Send card by email
+		if ($user->rights->adherent->creer)
+		{
+       		if ($object->statut >= 1)
+       		{
+				if ($object->email) print "<a class=\"butAction\" href=\"fiche.php?rowid=$object->id&action=sendinfo\">".$langs->trans("SendCardByMail")."</a>\n";
+				else print "<a class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NoEMail"))."\">".$langs->trans("SendCardByMail")."</a>\n";
+       		}
+       		else
+       		{
+       		    print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("ValidateBefore"))."\">".$langs->trans("SendCardByMail")."</font>";
+       		}
+	    }
+		else
+		{
+			print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("SendCardByMail")."</font>";
+		}
+
+		// Resilier
+		if ($object->statut >= 1)
+		{
+			if ($user->rights->adherent->supprimer)
+			{
+		        print "<a class=\"butAction\" href=\"fiche.php?rowid=$rowid&action=resign\">".$langs->trans("Resiliate")."</a>\n";
+		    }
+			else
+			{
+				print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("Resiliate")."</font>";
+			}
+		}
+
+		// Create third party
+		if ($conf->societe->enabled && ! $object->fk_soc)
+		{
+			if ($user->rights->societe->creer)
+			{
+				if ($object->statut != -1) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_thirdparty">'.$langs->trans("CreateDolibarrThirdParty").'</a>';
+				else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrThirdParty").'</a>';
+			}
+			else
+			{
+				print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrThirdParty")."</font>";
+			}
+		}
+
+		// Create user
+		if (! $user->societe_id && ! $object->user_id)
+		{
+			if ($user->rights->user->user->creer)
+			{
+				if ($object->statut != -1) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&amp;action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
+				else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a>';
+			}
+			else
+			{
+				print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("CreateDolibarrLogin")."</font>";
+			}
+		}
+
+		// Delete
+	    if ($user->rights->adherent->supprimer)
+	    {
+	        print "<a class=\"butActionDelete\" href=\"fiche.php?rowid=$object->id&action=delete\">".$langs->trans("Delete")."</a>\n";
+	    }
+		else
+		{
+			print "<font class=\"butActionRefused\" href=\"#\" title=\"".dol_escape_htmltag($langs->trans("NotEnoughPermissions"))."\">".$langs->trans("Delete")."</font>";
+		}
+
+	    // Action SPIP
+	    if ($conf->mailmanspip->enabled && $conf->global->ADHERENT_USE_SPIP)
+	    {
+	        $isinspip=$object->is_in_spip();
+	        if ($isinspip == 1)
+	        {
+	            print "<a class=\"butAction\" href=\"fiche.php?rowid=$object->id&action=del_spip\">".$langs->trans("DeleteIntoSpip")."</a>\n";
+	        }
+	        if ($isinspip == 0)
+	        {
+	            print "<a class=\"butAction\" href=\"fiche.php?rowid=$object->id&action=add_spip\">".$langs->trans("AddIntoSpip")."</a>\n";
+	        }
+	        if ($isinspip == -1)
+	        {
+	            print '<br><br><font class="error">Failed to connect to SPIP: '.$object->error.'</font>';
+	        }
+	    }
+
+    }
+
+    print '</div>';
+    print "<br>\n";
+
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 395 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/fiche_subscription.php

@@ -0,0 +1,395 @@
+<?php
+/* Copyright (C) 2007-2012 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/adherents/fiche_subscription.php
+ *       \ingroup    member
+ *       \brief      Page to add/edit/remove a member subscription
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+
+$langs->load("companies");
+$langs->load("bills");
+$langs->load("members");
+$langs->load("users");
+
+$adh = new Adherent($db);
+$subscription = new Cotisation($db);
+$errmsg='';
+
+$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];
+$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
+$typeid=isset($_GET["typeid"])?$_GET["typeid"]:$_POST["typeid"];
+
+if (! $user->rights->adherent->cotisation->lire)
+	 accessforbidden();
+
+
+/*
+ * 	Actions
+ */
+
+if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update' && ! $_POST["cancel"])
+{
+	// Charge objet actuel
+	$result=$subscription->fetch($_POST["rowid"]);
+	if ($result > 0)
+	{
+		$db->begin();
+
+		$errmsg='';
+
+		if ($subscription->fk_bank)
+		{
+			$accountline=new AccountLine($db);
+			$result=$accountline->fetch($subscription->fk_bank);
+
+			// If transaction consolidated
+			if ($accountline->rappro)
+			{
+				$errmsg=$langs->trans("SubscriptionLinkedToConciliatedTrnasaction");
+			}
+			else
+			{
+				$accountline->datev=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+				$accountline->dateo=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+				$accountline->amount=$_POST["amount"];
+				$result=$accountline->update($user);
+				if ($result < 0)
+				{
+					$errmsg=$accountline->error;
+				}
+			}
+		}
+
+		if (! $errmsg)
+		{
+			// Modifie valeures
+			$subscription->dateh=dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
+			$subscription->datef=dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
+			$subscription->note=$_POST["note"];
+			$subscription->amount=$_POST["amount"];
+			//print 'datef='.$subscription->datef.' '.$_POST['datesubendday'];
+
+			$result=$subscription->update($user);
+			if ($result >= 0 && ! count($subscription->errors))
+			{
+				$db->commit();
+
+				header("Location: fiche_subscription.php?rowid=".$subscription->id);
+				exit;
+			}
+			else
+			{
+				$db->rollback();
+
+			    if ($subscription->error)
+				{
+					$errmsg=$subscription->error;
+				}
+				else
+				{
+					foreach($subscription->errors as $error)
+					{
+						if ($errmsg) $errmsg.='<br>';
+						$errmsg.=$error;
+					}
+				}
+				$action='';
+			}
+		}
+		else
+		{
+			$db->rollback();
+		}
+	}
+}
+
+if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->adherent->cotisation->creer)
+{
+	$result=$subscription->fetch($rowid);
+    $result=$subscription->delete($user);
+    if ($result > 0)
+    {
+    	Header("Location: card_subscriptions.php?rowid=".$subscription->fk_adherent);
+    	exit;
+    }
+    else
+    {
+    	$mesg=$adh->error;
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("SubscriptionCard"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$form = new Form($db);
+
+
+dol_htmloutput_errors($errmsg);
+
+
+if ($user->rights->adherent->cotisation->creer && $action == 'edit')
+{
+	/********************************************
+	 *
+	 * Fiche en mode edition
+	 *
+	 ********************************************/
+
+    $subscription->fetch($rowid);
+	$result=$adh->fetch($subscription->fk_adherent);
+
+	/*
+	 * Affichage onglets
+	 */
+	$h = 0;
+	$head = array();
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id;
+	$head[$h][1] = $langs->trans("SubscriptionCard");
+	$head[$h][2] = 'general';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
+
+	dol_fiche_head($head, 'general', $langs->trans("Subscription"));
+
+	print "\n";
+	print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="post">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"update\">";
+	print "<input type=\"hidden\" name=\"rowid\" value=\"$rowid\">";
+	print "<input type=\"hidden\" name=\"fk_bank\" value=\"".$subscription->fk_bank."\">";
+	print '<table class="border" width="100%">';
+
+    // Ref
+    print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td class="valeur" colspan="2">'.$subscription->ref.'&nbsp;</td></tr>';
+
+    // Member
+	$adh->ref=$adh->getFullName($langs);
+    print '<tr>';
+	print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1,0,'subscription').'</td>';
+    print '</tr>';
+
+    // Date start subscription
+    print '<tr><td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="2">';
+	$form->select_date($subscription->dateh,'datesub',1,1,0,'update',1);
+	print '</td>';
+    print '</tr>';
+
+    // Date end subscription
+    print '<tr><td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="2">';
+	$form->select_date($subscription->datef,'datesubend',0,0,0,'update',1);
+	print '</td>';
+    print '</tr>';
+
+    // Amount
+    print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="2">';
+	print '<input type="text" class="flat" size="10" name="amount" value="'.price($subscription->amount).'"></td></tr>';
+
+    // Label
+    print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="2">';
+	print '<input type="text" class="flat" size="60" name="note" value="'.$subscription->note.'"></td></tr>';
+
+	// Bank line
+	if ($conf->banque->enabled)
+	{
+		if ($conf->global->ADHERENT_BANK_USE || $subscription->fk_bank)
+	    {
+    		print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
+			if ($subscription->fk_bank)
+			{
+	    		$bankline=new AccountLine($db);
+		    	$result=$bankline->fetch($subscription->fk_bank);
+				print $bankline->getNomUrl(1,0,'showall');
+			}
+			else
+			{
+				print $langs->trans("NoneF");
+			}
+	    	print '</td></tr>';
+	    }
+	}
+
+	print '<tr><td colspan="3" align="center">';
+	print '<input type="submit" class="button" name="submit" value="'.$langs->trans("Save").'">';
+	print ' &nbsp; &nbsp; &nbsp; ';
+	print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+	print '</td></tr>';
+
+	print '</table>';
+	print '</form>';
+	print "\n";
+
+	print '</div>';
+	print "\n";
+}
+
+if ($rowid && $action != 'edit')
+{
+	/* ************************************************************************** */
+	/*                                                                            */
+	/* Mode affichage                                                             */
+	/*                                                                            */
+	/* ************************************************************************** */
+
+    $result=$subscription->fetch($rowid);
+	$result=$adh->fetch($subscription->fk_adherent);
+
+	/*
+	 * Affichage onglets
+	 */
+	$h = 0;
+	$head = array();
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id;
+	$head[$h][1] = $langs->trans("SubscriptionCard");
+	$head[$h][2] = 'general';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
+
+	dol_fiche_head($head, 'general', $langs->trans("Subscription"), '', 'payment');
+
+	if ($msg) print '<div class="error">'.$msg.'</div>';
+
+    // Confirmation to delete subscription
+    if ($action == 'delete')
+    {
+		//$formquestion=array();
+        //$formquestion['text']='<b>'.$langs->trans("ThisWillAlsoDeleteBankRecord").'</b>';
+		$text=$langs->trans("ConfirmDeleteSubscription");
+		if ($conf->banque->enabled && $conf->global->ADHERENT_BANK_USE) $text.='<br>'.img_warning().' '.$langs->trans("ThisWillAlsoDeleteBankRecord");
+		$ret=$form->form_confirm($_SERVER["PHP_SELF"]."?rowid=".$subscription->id,$langs->trans("DeleteSubscription"),$text,"confirm_delete",$formquestion,0,1);
+        if ($ret == 'html') print '<br>';
+    }
+
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="border" width="100%">';
+
+    // Ref
+    print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
+	print '<td class="valeur" colspan="3">';
+	print $form->showrefnav($subscription,'rowid','',1);
+	print '</td></tr>';
+
+    // Member
+	$adh->ref=$adh->getFullName($langs);
+    print '<tr>';
+	print '<td>'.$langs->trans("Member").'</td><td class="valeur" colspan="3">'.$adh->getNomUrl(1,0,'subscription').'</td>';
+    print '</tr>';
+
+    // Date record
+    /*print '<tr>';
+	print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->datec,'dayhour').'</td>';
+    print '</tr>';*/
+
+    // Date subscription
+    print '<tr>';
+	print '<td>'.$langs->trans("DateSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->dateh,'day').'</td>';
+    print '</tr>';
+
+    // Date end subscription
+    print '<tr>';
+	print '<td>'.$langs->trans("DateEndSubscription").'</td><td class="valeur" colspan="3">'.dol_print_date($subscription->datef,'day').'</td>';
+    print '</tr>';
+
+    // Amount
+    print '<tr><td>'.$langs->trans("Amount").'</td><td class="valeur" colspan="3">'.price($subscription->amount).'</td></tr>';
+
+    // Amount
+    print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur" colspan="3">'.$subscription->note.'</td></tr>';
+
+    // Bank line
+	if ($conf->banque->enabled)
+	{
+		if ($conf->global->ADHERENT_BANK_USE || $subscription->fk_bank)
+	    {
+    		print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="3">';
+			if ($subscription->fk_bank)
+			{
+	    		$bankline=new AccountLine($db);
+		    	$result=$bankline->fetch($subscription->fk_bank);
+		    	print $bankline->getNomUrl(1,0,'showall');
+			}
+			else
+			{
+				print $langs->trans("NoneF");
+			}
+	    	print '</td></tr>';
+	    }
+	}
+
+
+    print "</table>\n";
+    print '</form>';
+
+    print "</div>\n";
+
+
+    /*
+     * Barre d'actions
+     *
+     */
+    print '<div class="tabsAction">';
+
+    if ($user->rights->adherent->cotisation->creer)
+	{
+		if (! $bankline->rappro)
+		{
+			print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?rowid=".$subscription->id."&action=edit\">".$langs->trans("Modify")."</a>";
+		}
+		else
+		{
+			print "<a class=\"butActionRefused\" title=\"".$langs->trans("BankLineConciliated")."\" href=\"#\">".$langs->trans("Modify")."</a>";
+		}
+	}
+
+    // Supprimer
+    if ($user->rights->adherent->cotisation->creer)
+    {
+        print "<a class=\"butActionDelete\" href=\"".$_SERVER["PHP_SELF"]."?rowid=".$subscription->id."&action=delete\">".$langs->trans("Delete")."</a>\n";
+    }
+
+    print '</div>';
+    print "<br>\n";
+
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 91 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/htpasswd.php

@@ -0,0 +1,91 @@
+<?php
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2006-2008 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  	\file 		htdocs/adherents/htpasswd.php
+ *      \ingroup    member
+ *      \brief      Page d'export htpasswd du fichier des adherents
+ *      \author     Rodolphe Quiedeville
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/security2.lib.php");
+
+// Security check
+if (! $user->rights->adherent->export) accessforbidden();
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+if ($sortorder == "") {  $sortorder="ASC"; }
+if ($sortfield == "") {  $sortfield="d.login"; }
+if (! isset($statut))
+{
+  $statut = 1 ;
+}
+
+if (! isset($cotis))
+{
+  // par defaut les adherents doivent etre a jour de cotisation
+  $cotis=1;
+}
+
+
+$sql = "SELECT d.login, d.pass, d.datefin";
+$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
+$sql .= " WHERE d.statut = $statut ";
+if ($cotis==1)
+{
+	$sql .= " AND datefin > '".$db->idate(mktime())."'";
+}
+$sql.= $db->order($sortfield,$sortorder);
+//$sql.=$db->plimit($conf->liste_limit, $offset);
+
+$resql = $db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+
+	print_barre_liste($langs->trans("HTPasswordExport"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',0);
+
+	print "<hr>\n";
+	while ($i < $num)
+	{
+		$objp = $db->fetch_object($result);
+		$htpass=crypt($objp->pass,makesalt());
+		print $objp->login.":".$htpass."<br>\n";
+		$i++;
+	}
+	print "<hr>\n";
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 433 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/index.php

@@ -0,0 +1,433 @@
+<?php
+/* Copyright (C) 2001-2002	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2003		Jean-Louis Bergamo		<jlb@j1b.org>
+ * Copyright (C) 2004-2012	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012	Regis Houssin			<regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/adherents/index.php
+ *       \ingroup    member
+ *       \brief      Page accueil module adherents
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+
+$langs->load("companies");
+$langs->load("members");
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("Members"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$staticmember=new Adherent($db);
+$statictype=new AdherentType($db);
+$subscriptionstatic=new Cotisation($db);
+
+print_fiche_titre($langs->trans("MembersArea"));
+
+print '<table border="0" width="100%" class="notopnoleftnoright">';
+
+$var=True;
+
+$Adherents=array();
+$AdherentsAValider=array();
+$MemberUpToDate=array();
+$AdherentsResilies=array();
+
+$AdherentType=array();
+
+// Liste les adherents
+$sql = "SELECT t.rowid, t.libelle, t.cotisation,";
+$sql.= " d.statut, count(d.rowid) as somme";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
+$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
+$sql.= " ON t.rowid = d.fk_adherent_type";
+$sql.= " AND d.entity IN (".getEntity().")";
+$sql.= " WHERE t.entity IN (".getEntity().")";
+$sql.= " GROUP BY t.rowid, t.libelle, t.cotisation, d.statut";
+
+dol_syslog("index.php::select nb of members by type sql=".$sql, LOG_DEBUG);
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+	while ($i < $num)
+	{
+		$objp = $db->fetch_object($result);
+
+		$adhtype=new AdherentType($db);
+		$adhtype->id=$objp->rowid;
+		$adhtype->cotisation=$objp->cotisation;
+		$adhtype->libelle=$objp->libelle;
+		$AdherentType[$objp->rowid]=$adhtype;
+
+		if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
+		if ($objp->statut == 1)  { $MembersValidated[$objp->rowid]=$objp->somme; }
+		if ($objp->statut == 0)  { $MembersResiliated[$objp->rowid]=$objp->somme; }
+
+		$i++;
+	}
+	$db->free($result);
+}
+
+$now=dol_now();
+
+// List members up to date
+// current rule: uptodate = the end date is in future whatever is type
+// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
+$sql = "SELECT count(*) as somme , d.fk_adherent_type";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+$sql.= " WHERE d.entity IN (".getEntity().")";
+//$sql.= " AND d.statut = 1 AND ((t.cotisation = 0 AND d.datefin IS NULL) OR d.datefin >= ".$db->idate($now).')';
+$sql.= " AND d.statut = 1 AND d.datefin >= ".$db->idate($now);
+$sql.= " AND t.rowid = d.fk_adherent_type";
+$sql.= " GROUP BY d.fk_adherent_type";
+
+dol_syslog("index.php::select nb of uptodate members by type sql=".$sql, LOG_DEBUG);
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+	while ($i < $num)
+	{
+		$objp = $db->fetch_object($result);
+		$MemberUpToDate[$objp->fk_adherent_type]=$objp->somme;
+		$i++;
+	}
+	$db->free();
+}
+
+
+print '<tr><td width="30%" class="notopnoleft" valign="top">';
+
+
+// Formulaire recherche adherent
+print '<form action="liste.php" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="search">';
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td colspan="3">'.$langs->trans("SearchAMember").'</td>';
+print "</tr>\n";
+$var=false;
+print "<tr $bc[$var]>";
+print '<td>';
+print $langs->trans("Ref").':</td><td><input type="text" name="search_ref" class="flat" size="16">';
+print '</td><td rowspan="3"><input class="button" type="submit" value="'.$langs->trans("Search").'"></td></tr>';
+print "<tr $bc[$var]>";
+print '<td>';
+print $langs->trans("Name").':</td><td><input type="text" name="search_nom" class="flat" size="16">';
+print '</td></tr>';
+print "<tr $bc[$var]>";
+print '<td>';
+print $langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="16">';
+print '</td></tr>';
+print "</table></form>";
+
+
+/*
+ * Statistics
+ */
+
+if ($conf->use_javascript_ajax)
+{
+    print '<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").'</td></tr>';
+    print '<tr><td align="center">';
+
+    $SommeA=0;
+    $SommeB=0;
+    $SommeC=0;
+    $SommeD=0;
+    $dataval=array();
+    $datalabels=array();
+    $i=0;
+    foreach ($AdherentType as $key => $adhtype)
+    {
+        $datalabels[]=array($i,$adhtype->getNomUrl(0,dol_size(16)));
+        $dataval['draft'][]=array($i,isset($MemberToValidate[$key])?$MemberToValidate[$key]:0);
+        $dataval['notuptodate'][]=array($i,isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0);
+        $dataval['uptodate'][]=array($i,isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0);
+        $dataval['resiliated'][]=array($i,isset($MembersResiliated[$key])?$MembersResiliated[$key]:0);
+        $SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
+        $SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-$MemberUpToDate[$key]:0;
+        $SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
+        $SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
+        $i++;
+    }
+
+    /*
+    $dataseries=array();
+    $dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'data'=>(int) $dataval['draft']);
+    $dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'data'=>(int) $dataval['notuptodate']);
+    $dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'data'=>(int) $dataval['uptodate']);
+    $dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'data'=>(int) $dataval['resiliated']);
+    $data=array('series'=>$dataseries,'seriestype'=>array('bar','bar','bar','bar'),'xlabel'=>$datalabels);
+    dol_print_graph('stats2',300,180,$data,1,'barline');
+    */
+
+    $dataseries=array();
+    $dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'data'=>round($SommeB));
+    $dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'data'=>round($SommeC));
+    $dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'data'=>round($SommeD));
+    $dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'data'=>round($SommeA));
+    $data=array('series'=>$dataseries);
+    dol_print_graph('stats',300,180,$data,1,'pie',1);
+    print '</td></tr>';
+    print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td align="right">';
+    print $SommeA+$SommeB+$SommeC+$SommeD;
+    print '</td></tr>';
+    print '</table>';
+}
+
+print '</td><td class="notopnoleftnoright" valign="top">';
+
+
+$var=true;
+
+/*
+ * Last modified members
+ */
+$max=5;
+
+$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname, a.societe as company, a.fk_soc,";
+$sql.= " a.tms as datem, datefin as date_end_subscription,";
+$sql.= " ta.rowid as typeid, ta.libelle, ta.cotisation";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
+$sql.= " WHERE a.entity IN (".getEntity().")";
+$sql.= " AND a.fk_adherent_type = ta.rowid";
+$sql.= $db->order("a.tms","DESC");
+$sql.= $db->plimit($max, 0);
+
+$resql=$db->query($sql);
+if ($resql)
+{
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre">';
+	print '<td colspan="4">'.$langs->trans("LastMembersModified",$max).'</td></tr>';
+
+	$num = $db->num_rows($resql);
+	if ($num)
+	{
+		$i = 0;
+		$var = True;
+		while ($i < $num)
+		{
+			$var=!$var;
+			$obj = $db->fetch_object($resql);
+			print "<tr ".$bc[$var].">";
+			$staticmember->id=$obj->rowid;
+			$staticmember->lastname=$obj->lastname;
+			$staticmember->firstname=$obj->firstname;
+			if (! empty($obj->fk_soc)) {
+				$staticmember->socid = $obj->fk_soc;
+				$staticmember->fetch_thirdparty();
+				$staticmember->name=$staticmember->thirdparty->name;
+			} else {
+				$staticmember->name=$obj->company;
+			}
+			$staticmember->ref=$staticmember->getFullName($langs);
+			$statictype->id=$obj->typeid;
+			$statictype->libelle=$obj->libelle;
+			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 align="right">'.$staticmember->LibStatut($obj->statut,($obj->cotisation=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';
+			print '</tr>';
+			$i++;
+		}
+	}
+	print "</table><br>";
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+/*
+ * Last modified subscriptions
+ */
+$max=5;
+
+$sql = "SELECT a.rowid, a.statut, a.nom as lastname, a.prenom as firstname, a.societe as company, a.fk_soc,";
+$sql.= " datefin as date_end_subscription,";
+$sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.cotisation";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."cotisation as c";
+$sql.= " WHERE a.entity IN (".getEntity().")";
+$sql.= " AND c.fk_adherent = a.rowid";
+$sql.= $db->order("c.tms","DESC");
+$sql.= $db->plimit($max, 0);
+
+$resql=$db->query($sql);
+if ($resql)
+{
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre">';
+	print '<td colspan="5">'.$langs->trans("LastSubscriptionsModified",$max).'</td></tr>';
+
+	$num = $db->num_rows($resql);
+	if ($num)
+	{
+		$i = 0;
+		$var = True;
+		while ($i < $num)
+		{
+			$var=!$var;
+			$obj = $db->fetch_object($resql);
+			print "<tr ".$bc[$var].">";
+			$subscriptionstatic->id=$obj->cid;
+			$subscriptionstatic->ref=$obj->cid;
+			$staticmember->id=$obj->rowid;
+			$staticmember->lastname=$obj->lastname;
+			$staticmember->firstname=$obj->firstname;
+			if (! empty($obj->fk_soc)) {
+				$staticmember->socid = $obj->fk_soc;
+				$staticmember->fetch_thirdparty();
+				$staticmember->name=$staticmember->thirdparty->name;
+			} else {
+				$staticmember->name=$obj->company;
+			}
+			$staticmember->ref=$staticmember->getFullName($langs);
+			print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
+			print '<td>'.$staticmember->getNomUrl(1,32,'subscription').'</td>';
+			print '<td>'.get_date_range($db->jdate($obj->date_start),$db->jdate($obj->date_end)).'</td>';
+			print '<td align="right">'.price($obj->cotisation).'</td>';
+			//print '<td align="right">'.$staticmember->LibStatut($obj->statut,($obj->cotisation=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';
+			print '<td align="right">'.dol_print_date($db->jdate($obj->datem?$obj->datem:$obj->datec),'dayhour').'</td>';
+			print '</tr>';
+			$i++;
+		}
+	}
+	print "</table><br>";
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+// Summary of members by type
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("MembersTypes").'</td>';
+print '<td align=right>'.$langs->trans("MembersStatusToValid").'</td>';
+print '<td align=right>'.$langs->trans("MenuMembersNotUpToDate").'</td>';
+print '<td align=right>'.$langs->trans("MenuMembersUpToDate").'</td>';
+print '<td align=right>'.$langs->trans("MembersStatusResiliated").'</td>';
+print "</tr>\n";
+
+foreach ($AdherentType as $key => $adhtype)
+{
+	$var=!$var;
+	print "<tr $bc[$var]>";
+	print '<td>'.$adhtype->getNomUrl(1, dol_size(32)).'</td>';
+	print '<td align="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
+	print '<td align="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-$MemberUpToDate[$key] > 0) ? $MembersValidated[$key]-$MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
+	print '<td align="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).'</td>';
+	print '<td align="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
+	print "</tr>\n";
+}
+print '<tr class="liste_total">';
+print '<td class="liste_total">'.$langs->trans("Total").'</td>';
+print '<td class="liste_total" align="right">'.$SommeA.' '.$staticmember->LibStatut(-1,$adhtype->cotisation,0,3).'</td>';
+print '<td class="liste_total" align="right">'.$SommeB.' '.$staticmember->LibStatut(1,$adhtype->cotisation,0,3).'</td>';
+print '<td class="liste_total" align="right">'.$SommeC.' '.$staticmember->LibStatut(1,$adhtype->cotisation,$now,3).'</td>';
+print '<td class="liste_total" align="right">'.$SommeD.' '.$staticmember->LibStatut(0,$adhtype->cotisation,0,3).'</td>';
+print '</tr>';
+
+print "</table>\n";
+print "<br>\n";
+
+
+// List of subscription by year
+$Total=array();
+$Number=array();
+$tot=0;
+$numb=0;
+
+$sql = "SELECT c.cotisation, c.dateadh";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."cotisation as c";
+$sql.= " WHERE d.entity IN (".getEntity().")";
+$sql.= " AND d.rowid = c.fk_adherent";
+if(isset($date_select) && $date_select != '')
+{
+	$sql .= " AND dateadh LIKE '$date_select%'";
+}
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+	while ($i < $num)
+	{
+		$objp = $db->fetch_object($result);
+		$year=dol_print_date($db->jdate($objp->dateadh),"%Y");
+		$Total[$year]=(isset($Total[$year])?$Total[$year]:0)+$objp->cotisation;
+		$Number[$year]=(isset($Number[$year])?$Number[$year]:0)+1;
+		$tot+=$objp->cotisation;
+		$numb+=1;
+		$i++;
+	}
+}
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Subscriptions").'</td>';
+print '<td align="right">'.$langs->trans("Number").'</td>';
+print '<td align="right">'.$langs->trans("AmountTotal").'</td>';
+print '<td align="right">'.$langs->trans("AmountAverage").'</td>';
+print "</tr>\n";
+
+$var=true;
+krsort($Total);
+foreach ($Total as $key=>$value)
+{
+	$var=!$var;
+	print "<tr $bc[$var]>";
+	print "<td><a href=\"cotisations.php?date_select=$key\">$key</a></td>";
+	print "<td align=\"right\">".$Number[$key]."</td>";
+	print "<td align=\"right\">".price($value)."</td>";
+	print "<td align=\"right\">".price(price2num($value/$Number[$key],'MT'))."</td>";
+	print "</tr>\n";
+}
+
+// Total
+print '<tr class="liste_total">';
+print '<td>'.$langs->trans("Total").'</td>';
+print "<td align=\"right\">".$numb."</td>";
+print '<td align="right">'.price($tot)."</td>";
+print "<td align=\"right\">".price(price2num($numb>0?($tot/$numb):0,'MT'))."</td>";
+print "</tr>\n";
+print "</table><br>\n";
+
+print '</td></tr>';
+print '</table>';
+
+
+llxFooter();
+$db->close();
+?>

+ 65 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/info.php

@@ -0,0 +1,65 @@
+<?php
+/* Copyright (C) 2005-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/info.php
+ *      \ingroup    member
+ *		\brief      Page des informations d'un adherent
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+
+$langs->load("companies");
+$langs->load("bills");
+$langs->load("members");
+$langs->load("users");
+
+$id=(GETPOST('id','int') ? GETPOST('id','int') : GETPOST('rowid','int'));
+
+// Security check
+$result=restrictedArea($user,'adherent',$id);
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$adh = new Adherent($db);
+$adh->fetch($id);
+$adh->info($id);
+
+$head = member_prepare_head($adh);
+
+dol_fiche_head($head, 'info', $langs->trans("Member"), 0, 'user');
+
+
+print '<table width="100%"><tr><td>';
+dol_print_object_info($adh);
+print '</td></tr></table>';
+
+print '</div>';
+
+
+llxFooter();
+$db->close();
+?>

+ 83 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/info_subscription.php

@@ -0,0 +1,83 @@
+<?php
+/* Copyright (C) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2006 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/info_subscription.php
+ *      \ingroup    member
+ *		\brief      Page with information of subscriptions of a member
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php");
+
+$langs->load("companies");
+$langs->load("bills");
+$langs->load("members");
+$langs->load("users");
+
+if (!$user->rights->adherent->lire)
+	accessforbidden();
+
+$rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"];
+
+
+
+/*
+ * Visualisation de la fiche
+ *
+ */
+
+llxHeader();
+
+$form = new Form($db);
+
+$subscription = new Cotisation($db);
+$result=$subscription->fetch($rowid);
+
+$h = 0;
+$head = array();
+
+$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche_subscription.php?rowid='.$subscription->id;
+$head[$h][1] = $langs->trans("SubscriptionCard");
+$head[$h][2] = 'general';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/adherents/info_subscription.php?rowid='.$subscription->id;
+$head[$h][1] = $langs->trans("Info");
+$head[$h][2] = 'info';
+$h++;
+
+
+dol_fiche_head($head, 'info', $langs->trans("Subscription"), '', 'payment');
+
+$subscription->info($rowid);
+
+print '<table width="100%"><tr><td>';
+dol_print_object_info($subscription);
+print '</td></tr></table>';
+
+print '</div>';
+
+
+$db->close();
+
+llxFooter();
+?>

+ 244 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/ldap.php

@@ -0,0 +1,244 @@
+<?php
+/* Copyright (C) 2006 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2006 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/adherents/ldap.php
+ *       \ingroup    ldap member
+ *       \brief      Page fiche LDAP adherent
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("companies");
+$langs->load("members");
+$langs->load("ldap");
+$langs->load("admin");
+
+$rowid = GETPOST('id','int');
+$action = GETPOST('action');
+
+// Protection
+$socid=0;
+if ($user->societe_id > 0)
+{
+    $socid = $user->societe_id;
+}
+
+$adh = new Adherent($db);
+$adh->id = $rowid;
+$result=$adh->fetch($rowid);
+if (! $result)
+{
+	dol_print_error($db,"Failed to get adherent: ".$adh->error);
+	exit;
+}
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'dolibarr2ldap')
+{
+	$message="";
+
+	$db->begin();
+
+	$ldap=new Ldap();
+	$result=$ldap->connect_bind();
+
+	$info=$adh->_load_ldap_info();
+	$dn=$adh->_load_ldap_dn($info);
+	$olddn=$dn;	// We can say that old dn = dn as we force synchro
+
+	$result=$ldap->update($dn,$info,$user,$olddn);
+
+	if ($result >= 0)
+	{
+		$message.='<div class="ok">'.$langs->trans("MemberSynchronized").'</div>';
+		$db->commit();
+	}
+	else
+	{
+		$message.='<div class="error">'.$ldap->error.'</div>';
+		$db->rollback();
+	}
+}
+
+
+
+/*
+ *	View
+ */
+
+llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$form = new Form($db);
+
+$head = member_prepare_head($adh);
+
+dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user');
+
+
+print '<table class="border" width="100%">';
+
+// Ref
+print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
+print '<td class="valeur">';
+print $form->showrefnav($adh,'id');
+print '</td></tr>';
+
+// Nom
+print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$adh->lastname.'&nbsp;</td>';
+print '</tr>';
+
+// Prenom
+print '<tr><td width="15%">'.$langs->trans("Firstname").'</td><td class="valeur">'.$adh->firstname.'&nbsp;</td>';
+print '</tr>';
+
+// Login
+print '<tr><td>'.$langs->trans("Login").'</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
+
+// Password not crypted
+if ($conf->global->LDAP_MEMBER_FIELD_PASSWORD)
+{
+	print '<tr><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td>';
+	print '<td class="valeur">'.$adh->pass.'</td>';
+	print "</tr>\n";
+}
+
+// Password crypted
+if ($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)
+{
+	print '<tr><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td>';
+	print '<td class="valeur">'.$adh->pass_crypted.'</td>';
+	print "</tr>\n";
+}
+
+// Type
+print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adh->type."</td></tr>\n";
+
+$langs->load("admin");
+
+// LDAP DN
+print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
+
+// LDAP Cle
+print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS."</td></tr>\n";
+
+// LDAP Server
+print '<tr><td>LDAP '.$langs->trans("Type").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_TYPE."</td></tr>\n";
+print '<tr><td>LDAP '.$langs->trans("Version").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PROTOCOLVERSION."</td></tr>\n";
+print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
+print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
+print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
+
+print '</table>';
+
+print '</div>';
+
+
+dol_htmloutput_mesg($message);
+
+
+/*
+ * Barre d'actions
+ */
+
+print '<div class="tabsAction">';
+
+if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr')
+{
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$adh->id.'&amp;action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
+}
+
+print "</div>\n";
+
+if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') print "<br>\n";
+
+
+
+// Affichage attributs LDAP
+print_titre($langs->trans("LDAPInformationsForThisMember"));
+
+print '<table width="100%" class="noborder">';
+
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("LDAPAttributes").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print '</tr>';
+
+// Lecture LDAP
+$ldap=new Ldap();
+$result=$ldap->connect_bind();
+if ($result > 0)
+{
+	$info=$adh->_load_ldap_info();
+	$dn=$adh->_load_ldap_dn($info,1);
+	$search = "(".$adh->_load_ldap_dn($info,2).")";
+
+	if (empty($dn))
+	{
+	    $langs->load("errors");
+	    print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete").'</font></td></tr>';
+	}
+    else
+    {
+    	$records=$ldap->getAttribute($dn,$search);
+
+    	//print_r($records);
+
+    	// Affichage arbre
+    	if (count($records) && $records != false && (! isset($records['count']) || $records['count'] > 0))
+    	{
+    		if (! is_array($records))
+    		{
+    			print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
+    		}
+    		else
+    		{
+    			$result=show_ldap_content($records,0,$records['count'],true);
+    		}
+    	}
+    	else
+    	{
+    		print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
+    	}
+    }
+
+	$ldap->unbind();
+	$ldap->close();
+}
+else
+{
+	dol_print_error('',$ldap->error);
+}
+
+
+print '</table>';
+
+
+llxFooter();
+
+$db->close();
+?>

+ 370 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/liste.php

@@ -0,0 +1,370 @@
+<?php
+/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2012 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/liste.php
+ *      \ingroup    member
+ *		\brief      Page to list all members of foundation
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("members");
+$langs->load("companies");
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $conf->liste_limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) {  $sortorder="ASC"; }
+if (! $sortfield) {  $sortfield="d.nom"; }
+
+$action=GETPOST("action");
+$filter=GETPOST("filter");
+$statut=GETPOST("statut");
+$search=GETPOST("search");
+$search_ref=GETPOST("search_ref");
+$search_nom=GETPOST("search_nom");
+$search_prenom=GETPOST("search_prenom");
+$search_login=GETPOST("search_login");
+$type=GETPOST("type");
+$search_email=GETPOST("search_email");
+$search_categ=GETPOST("search_categ");
+$sall=GETPOST("sall");
+
+if (GETPOST("button_removefilter"))
+{
+    $search="";
+	$search_ref="";
+    $search_nom="";
+	$search_prenom="";
+	$search_login="";
+	$type="";
+	$search_email="";
+	$search_categ="";
+	$sall="";
+}
+
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formother=new FormOther($db);
+$membertypestatic=new AdherentType($db);
+$memberstatic=new Adherent($db);
+
+llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$now=dol_now();
+
+$sql = "SELECT d.rowid, d.login, d.nom as lastname, d.prenom as firstname, d.societe as company, d.fk_soc,";
+$sql.= " d.datefin,";
+$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
+$sql.= " t.libelle as type, t.cotisation";
+$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_member as cf";
+$sql.= " WHERE d.fk_adherent_type = t.rowid ";
+if ($search_categ) $sql.= " AND d.rowid = cf.fk_member";	// Join for the needed table to filter by categ
+$sql.= " AND d.entity = ".$conf->entity;
+if ($sall)
+{
+	$sql.=" AND (";
+	if (is_numeric($sall)) $sql.= "d.rowid = ".$sall." OR ";
+	$sql.=" d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
+	$sql.=" OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'";
+	$sql.=" OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')";
+}
+if ($type > 0)
+{
+	$sql.=" AND t.rowid=".$type;
+}
+if (isset($_GET["statut"]) || isset($_POST["statut"]))
+{
+	$sql.=" AND d.statut in (".$statut.")";     // Peut valoir un nombre ou liste de nombre separes par virgules
+}
+if ($search_ref)
+{
+	if (is_numeric($search_ref)) $sql.= " AND (d.rowid = ".$search_ref.")";
+	else $sql.=" AND 1 = 2";    // Always wrong
+}
+if ($search_nom)
+{
+	$sql.= " AND (d.prenom LIKE '%".$search_nom."%' OR d.nom LIKE '%".$search_nom."%')";
+}
+if ($search_login)
+{
+	$sql.= " AND d.login LIKE '%".$search_login."%'";
+}
+if ($search_email)
+{
+	$sql.= " AND (d.email LIKE '%".$search_email."%')";
+}
+if ($filter == 'uptodate')
+{
+	$sql.=" AND datefin >= '".$db->idate($now)."'";
+}
+if ($filter == 'outofdate')
+{
+	$sql.=" AND (datefin IS NULL OR datefin < '".$db->idate($now)."')";
+}
+// Insert categ filter
+if ($search_categ)
+{
+	$sql.= " AND cf.fk_categorie = ".$db->escape($search_categ);
+}
+
+// Count total nb of records with no order and no limits
+$nbtotalofrecords = 0;
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+{
+	$resql = $db->query($sql);
+	if ($resql) $nbtotalofrecords = $db->num_rows($result);
+	else dol_print_error($db);
+}
+// Add order and limit
+$sql.= $db->order($sortfield,$sortorder);
+$sql.= $db->plimit($conf->liste_limit+1, $offset);
+
+dol_syslog("get list sql=".$sql);
+$resql = $db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+
+	$titre=$langs->trans("MembersList");
+	if (isset($_GET["statut"]))
+	{
+		if ($statut == '-1,1') { $titre=$langs->trans("MembersListQualified"); }
+		if ($statut == '-1')   { $titre=$langs->trans("MembersListToValid"); }
+		if ($statut == '1' && ! $filter)    		{ $titre=$langs->trans("MembersListValid"); }
+		if ($statut == '1' && $filter=='uptodate')  { $titre=$langs->trans("MembersListUpToDate"); }
+		if ($statut == '1' && $filter=='outofdate')	{ $titre=$langs->trans("MembersListNotUpToDate"); }
+		if ($statut == '0')    { $titre=$langs->trans("MembersListResiliated"); }
+	}
+	elseif ($action == 'search')
+	{
+		$titre=$langs->trans("MembersListQualified");
+	}
+
+	if ($type > 0)
+	{
+		$membertype=new AdherentType($db);
+		$result=$membertype->fetch($_REQUEST["type"]);
+		$titre.=" (".$membertype->libelle.")";
+	}
+
+	$param="";
+	if (isset($_GET["statut"]))       $param.="&statut=".$statut;
+	if ($search_nom)   $param.="&search_nom=".$search_nom;
+	if ($search_login) $param.="&search_login=".$search_login;
+	if ($search_email) $param.="&search_email=".$search_email;
+	if ($filter)       $param.="&filter=".$filter;
+	print_barre_liste($titre,$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
+
+	if ($sall)
+	{
+		print $langs->trans("Filter")." (".$langs->trans("Ref").", ".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
+	}
+
+	print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
+	print "<table class=\"noborder\" width=\"100%\">";
+
+	// Filter on categories
+	$moreforfilter='';
+	if ($conf->categorie->enabled)
+	{
+		$moreforfilter.=$langs->trans('Categories'). ': ';
+		$moreforfilter.=$formother->select_categories(3,$search_categ,'search_categ');
+		$moreforfilter.=' &nbsp; &nbsp; &nbsp; ';
+	}
+	if ($moreforfilter)
+	{
+		print '<tr class="liste_titre">';
+		print '<td class="liste_titre" colspan="9">';
+		print $moreforfilter;
+		print '</td></tr>';
+	}
+
+	print '<tr class="liste_titre">';
+	print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.nom",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"t.libelle",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
+	print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
+	print "</tr>\n";
+
+	// Lignes des champs de filtre
+	print '<tr class="liste_titre">';
+
+	print '<td class="liste_titre" align="left">';
+	print '<input class="flat" type="text" name="search_ref" value="'.$search_ref.'" size="4"></td>';
+
+	print '<td class="liste_titre" align="left">';
+	print '<input class="flat" type="text" name="search_nom" value="'.$search_nom.'" size="12"></td>';
+
+	print '<td class="liste_titre" align="left">';
+	print '<input class="flat" type="text" name="search_login" value="'.$search_login.'" size="7"></td>';
+
+	print '<td class="liste_titre">';
+	$listetype=$membertypestatic->liste_array();
+	print $form->selectarray("type", $listetype, $type, 1, 0, 0, '', 0, 32);
+	print '</td>';
+
+	print '<td class="liste_titre">&nbsp;</td>';
+
+	print '<td class="liste_titre" align="left">';
+	print '<input class="flat" type="text" name="search_email" value="'.$search_email.'" size="12"></td>';
+
+	print '<td class="liste_titre">&nbsp;</td>';
+
+	print '<td align="right" colspan="2" class="liste_titre">';
+	print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
+	print '&nbsp; ';
+	print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
+	print '</td>';
+
+	print "</tr>\n";
+	print '</form>';
+
+	$var=True;
+	while ($i < $num && $i < $conf->liste_limit)
+	{
+		$objp = $db->fetch_object($resql);
+
+		$datefin=$db->jdate($objp->datefin);
+		$memberstatic->id=$objp->rowid;
+		$memberstatic->ref=$objp->rowid;
+		$memberstatic->lastname=$objp->lastname;
+		$memberstatic->firstname=$objp->firstname;
+
+		if (! empty($objp->fk_soc)) {
+			$memberstatic->socid = $objp->fk_soc;
+			$memberstatic->fetch_thirdparty();
+			$companyname=$memberstatic->thirdparty->name;
+		} else {
+			$companyname=$objp->company;
+		}
+
+		$var=!$var;
+		print "<tr ".$bc[$var].">";
+
+		// Ref
+		print "<td>";
+		print $memberstatic->getNomUrl(1);
+		print "</td>\n";
+
+		// Lastname
+		print "<td><a href=\"fiche.php?rowid=$objp->rowid\">";
+		print ((! empty($objp->lastname) || ! empty($objp->firstname)) ? dol_trunc($memberstatic->getFullName($langs)) : '');
+		print (((! empty($objp->lastname) || ! empty($objp->firstname)) && ! empty($companyname)) ? ' / ' : '');
+		print (! empty($companyname) ? dol_trunc($companyname, 32) : '');
+		print "</a></td>\n";
+
+		// Login
+		print "<td>".$objp->login."</td>\n";
+
+		// Type
+		$membertypestatic->id=$objp->type_id;
+		$membertypestatic->libelle=$objp->type;
+		print '<td nowrap="nowrap">';
+		print $membertypestatic->getNomUrl(1,32);
+		print '</td>';
+
+		// Moral/Physique
+		print "<td>".$memberstatic->getmorphylib($objp->morphy)."</td>\n";
+
+		// EMail
+		print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
+
+		// Statut
+		print '<td nowrap="nowrap">';
+		print $memberstatic->LibStatut($objp->statut,$objp->cotisation,$datefin,2);
+		print "</td>";
+
+		// End of subscription date
+		if ($datefin)
+		{
+			print '<td align="center" nowrap="nowrap">';
+			print dol_print_date($datefin,'day');
+			if ($datefin < ($now -  $conf->adherent->cotisation->warning_delay) && $objp->statut > 0) print " ".img_warning($langs->trans("SubscriptionLate"));
+			print '</td>';
+		}
+		else
+		{
+			print '<td align="left" nowrap="nowrap">';
+			if ($objp->cotisation == 'yes')
+			{
+				print $langs->trans("SubscriptionNotReceived");
+				if ($objp->statut > 0) print " ".img_warning();
+			}
+			else
+			{
+				print '&nbsp;';
+			}
+			print '</td>';
+		}
+
+		// Actions
+		print '<td align="center">';
+		if ($user->rights->adherent->creer)
+		{
+			print "<a href=\"fiche.php?rowid=$objp->rowid&action=edit&return=liste.php\">".img_edit()."</a>";
+		}
+		print '&nbsp;';
+		if ($user->rights->adherent->supprimer)
+		{
+			print "<a href=\"fiche.php?rowid=$objp->rowid&action=resign&return=liste.php\">".img_picto($langs->trans("Resiliate"),'disable.png')."</a>";
+		}
+		print "</td>";
+
+		print "</tr>\n";
+		$i++;
+	}
+
+	print "</table>\n";
+
+	if ($num > $conf->liste_limit)
+	{
+		print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
+	}
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 181 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/note.php

@@ -0,0 +1,181 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2007 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/note.php
+ *      \ingroup    member
+ *      \brief      Fiche de notes sur un adherent
+*/
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php');
+require_once(DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php');
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("companies");
+$langs->load("members");
+$langs->load("bills");
+
+$action=GETPOST('action','alpha');
+$id=GETPOST('id','int');
+
+// Security check
+$result=restrictedArea($user,'adherent',$id);
+
+$object = new Adherent($db);
+$result=$object->fetch($id);
+if ($result > 0)
+{
+    $adht = new AdherentType($db);
+    $result=$adht->fetch($object->typeid);
+}
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update' && $user->rights->adherent->creer && ! $_POST["cancel"])
+{
+	$db->begin();
+
+	$res=$object->update_note($_POST["note"],$user);
+	if ($res < 0)
+	{
+		$mesg='<div class="error">'.$object->error.'</div>';
+		$db->rollback();
+	}
+	else
+	{
+		$db->commit();
+	}
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("Member"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$form = new Form($db);
+
+if ($id)
+{
+	$head = member_prepare_head($object);
+
+	dol_fiche_head($head, 'note', $langs->trans("Member"), 0, 'user');
+
+	dol_htmloutput_errors($msg);
+
+	print "<form method=\"post\" action=\"note.php\">";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+    print '<table class="border" width="100%">';
+
+    // Reference
+	print '<tr><td width="20%">'.$langs->trans('Ref').'</td>';
+	print '<td colspan="3">';
+	print $form->showrefnav($object,'id');
+	print '</td>';
+	print '</tr>';
+
+    // Login
+    if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
+    {
+        print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
+    }
+
+    // Morphy
+    print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
+    /*print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
+    print $form->showphoto('memberphoto',$member);
+    print '</td>';*/
+    print '</tr>';
+
+    // Type
+    print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
+
+    // Company
+    print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->societe.'</td></tr>';
+
+    // Civility
+    print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
+    print '</tr>';
+
+    // Lastname
+    print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur" colspan="3">'.$object->lastname.'&nbsp;</td>';
+	print '</tr>';
+
+    // Firstname
+    print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur" colspan="3">'.$object->firstname.'&nbsp;</td></tr>';
+
+    // Status
+    print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$object->getLibStatut(4).'</td></tr>';
+
+    // Note
+    print '<tr><td valign="top">'.$langs->trans("Note").'</td>';
+	print '<td valign="top" colspan="3">';
+	if ($action == 'edit' && $user->rights->adherent->creer)
+	{
+	    print "<input type=\"hidden\" name=\"action\" value=\"update\">";
+		print "<input type=\"hidden\" name=\"id\" value=\"".$object->id."\">";
+        require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+        $doleditor=new DolEditor('note',$object->note,'',280,'dolibarr_notes','',true,true,$conf->global->FCKEDITOR_ENABLE_SOCIETE,10,80);
+        $doleditor->Create();
+	}
+	else
+	{
+		print nl2br($object->note);
+	}
+	print "</td></tr>";
+
+	if ($action == 'edit')
+	{
+		print '<tr><td colspan="4" align="center">';
+		print '<input type="submit" class="button" name="update" value="'.$langs->trans("Save").'">';
+		print '&nbsp; &nbsp;';
+		print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+		print '</td></tr>';
+	}
+
+    print "</table>";
+	print "</form>\n";
+
+
+    /*
+    * Actions
+    */
+    print '</div>';
+    print '<div class="tabsAction">';
+
+    if ($user->rights->adherent->creer && $action != 'edit')
+    {
+        print "<a class=\"butAction\" href=\"note.php?id=".$object->id."&amp;action=edit\">".$langs->trans('Modify')."</a>";
+    }
+
+    print "</div>";
+
+
+}
+
+
+llxFooter();
+$db->close();
+?>

+ 283 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/stats/geo.php

@@ -0,0 +1,283 @@
+<?php
+/* Copyright (c) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/adherents/stats/geo.php
+ *      \ingroup    member
+ *		\brief      Page with geographical statistics on members
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+
+$graphwidth = 700;
+$mapratio = 0.5;
+$graphheight = round($graphwidth * $mapratio);
+
+$mode=GETPOST('mode')?GETPOST('mode'):'';
+
+
+// Security check
+if ($user->societe_id > 0)
+{
+    $action = '';
+    $socid = $user->societe_id;
+}
+if (! $user->rights->adherent->cotisation->lire)
+accessforbidden();
+
+$year = strftime("%Y", time());
+$startyear=$year-2;
+$endyear=$year;
+
+
+
+/*
+ * View
+ */
+
+
+llxHeader('','','','',0,0,array('http://www.google.com/jsapi'));
+
+$title=$langs->trans("Statistics");
+if ($mode == 'memberbycountry') $title=$langs->trans("MembersStatisticsByCountries");
+if ($mode == 'memberbystate') $title=$langs->trans("MembersStatisticsByState");
+if ($mode == 'memberbytown') $title=$langs->trans("MembersStatisticsByTown");
+
+print_fiche_titre($title, $mesg);
+
+dol_mkdir($dir);
+
+if ($mode)
+{
+    // Define sql
+    if ($mode == 'memberbycountry')
+    {
+        $label=$langs->trans("Country");
+        $tab='statscountry';
+
+        $data = array();
+        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.libelle as label";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_pays as c on d.pays = c.rowid";
+        $sql.=" WHERE d.entity IN (".getEntity().")";
+        $sql.=" AND d.statut = 1";
+        $sql.=" GROUP BY c.libelle, c.code";
+        //print $sql;
+    }
+    if ($mode == 'memberbystate')
+    {
+        $label=$langs->trans("Country");
+        $label2=$langs->trans("State");
+        $tab='statsstate';
+
+        $data = array();
+        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, c.nom as label2";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.fk_departement = c.rowid";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" WHERE d.entity IN (".getEntity().")";
+        $sql.=" AND d.statut = 1";
+        $sql.=" GROUP BY p.libelle, p.code, c.nom";
+        //print $sql;
+    }
+    if ($mode == 'memberbytown')
+    {
+        $label=$langs->trans("Country");
+        $label2=$langs->trans("Town");
+        $tab='statstown';
+
+        $data = array();
+        $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, p.code, p.libelle as label, d.ville as label2";
+        $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
+        $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p on d.pays = p.rowid";
+        $sql.=" WHERE d.entity IN (".getEntity().")";
+        $sql.=" AND d.statut = 1";
+        $sql.=" GROUP BY p.libelle, p.code, d.ville";
+        //print $sql;
+    }
+
+    $langsen=new Translate('',$conf);
+    $langsen->setDefaultLang('en_US');
+    $langsen->load("dict");
+    //print $langsen->trans("Country"."FI");exit;
+
+    // Define $data array
+    dol_syslog("Count member sql=".$sql);
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $num=$db->num_rows($resql);
+        $i=0;
+        while ($i < $num)
+        {
+            $obj=$db->fetch_object($resql);
+            if ($mode == 'memberbycountry')
+            {
+                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+							'code'=>$obj->code,
+							'nb'=>$obj->nb,
+							'lastdate'=>$db->jdate($obj->lastdate)
+                );
+            }
+            if ($mode == 'memberbystate')
+            {
+                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+				            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+							'nb'=>$obj->nb,
+							'lastdate'=>$db->jdate($obj->lastdate)
+                );
+            }
+            if ($mode == 'memberbytown')
+            {
+                $data[]=array('label'=>(($obj->code && $langs->trans("Country".$obj->code)!="Country".$obj->code)?$langs->trans("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))),
+                            'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")),
+                            'nb'=>$obj->nb,
+                            'lastdate'=>$db->jdate($obj->lastdate)
+                );
+            }
+
+            $i++;
+        }
+        $db->free($resql);
+    }
+    else
+    {
+        dol_print_error($db);
+    }
+}
+
+
+$head = member_stats_prepare_head($adh);
+
+dol_fiche_head($head, $tab, $langs->trans("Statistics"), 0, 'user');
+
+
+// Print title
+if ($mode && ! count($data))
+{
+    print $langs->trans("NoValidatedMemberYet").'<br>';
+    print '<br>';
+}
+else
+{
+    if ($mode == 'memberbycountry') print $langs->trans("MembersByCountryDesc").'<br>';
+    else if ($mode == 'memberbystate') print $langs->trans("MembersByStateDesc").'<br>';
+    else if ($mode == 'memberbytown') print $langs->trans("MembersByTownDesc").'<br>';
+    else
+    {
+        print $langs->trans("MembersStatisticsDesc").'<br>';
+        print '<br>';
+        print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
+        print '<br>';
+        print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
+        print '<br>';
+        print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
+    }
+    print '<br>';
+}
+
+
+// Show graphics
+if ($mode == 'memberbycountry')
+{
+    $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/graph-color.php';
+    if (is_readable($color_file)) include_once($color_file);
+
+    // Assume we've already included the proper headers so just call our script inline
+    // More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
+    print "\n<script type='text/javascript'>\n";
+    print "google.load('visualization', '1', {'packages': ['geomap']});\n";
+    print "google.setOnLoadCallback(drawMap);\n";
+    print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
+
+    // Get the total number of rows
+    print "\tdata.addRows(".count($data).");\n";
+    print "\tdata.addColumn('string', 'Country');\n";
+    print "\tdata.addColumn('number', 'Number');\n";
+
+    // loop and dump
+    $i=0;
+    foreach($data as $val)
+    {
+        $valcountry=strtoupper($val['code']);    // Should be ISO-3166 code (faster)
+        //$valcountry=ucfirst($val['label_en']);
+        if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; }    // fix case of uk (when we use labels)
+        print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
+        print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
+        // Google's Geomap only supports up to 400 entries
+        if ($i >= 400){ break; }
+        $i++;
+    }
+
+    print "\tvar options = {};\n";
+    print "\toptions['dataMode'] = 'regions';\n";
+    print "\toptions['showZoomOut'] = false;\n";
+    //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
+    print "\toptions['width'] = ".$graphwidth.";\n";
+    print "\toptions['height'] = ".$graphheight.";\n";
+    print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1],'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0],'444444')."];\n";
+    print "\tvar container = document.getElementById('".$mode."');\n";
+    print "\tvar geomap = new google.visualization.GeoMap(container);\n";
+    print "\tgeomap.draw(data, options);\n";
+    print "};\n";
+    print "</script>\n";
+
+    // print the div tag that will contain the map
+    print '<div align="center" id="'.$mode.'"></div>'."\n";
+    print '<br>';
+}
+
+if ($mode)
+{
+    // Print array
+    print '<table class="border" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td align="center">'.$label.'</td>';
+    if ($label2) print '<td align="center">'.$label2.'</td>';
+    print '<td align="center">'.$langs->trans("NbOfMembers").'</td>';
+    print '<td align="center">'.$langs->trans("LastMemberDate").'</td>';
+    print '</tr>';
+
+    $oldyear=0;
+    $var=true;
+    foreach ($data as $val)
+    {
+        $year = $val['year'];
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td align="center">'.$val['label'].'</td>';
+        if ($label2) print '<td align="center">'.$val['label2'].'</td>';
+        print '<td align="right">'.$val['nb'].'</td>';
+        print '<td align="right">'.dol_print_date($val['lastdate'],'dayhour').'</td>';
+        print '</tr>';
+        $oldyear=$year;
+    }
+
+    print '</table>';
+}
+
+
+dol_fiche_end();
+
+
+$db->close();
+
+llxFooter();
+?>

+ 232 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/stats/index.php

@@ -0,0 +1,232 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/adherents/stats/index.php
+ *      \ingroup    member
+ *		\brief      Page of subscription members statistics
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherentstats.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php");
+
+$WIDTH=500;
+$HEIGHT=200;
+
+$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)
+{
+    $action = '';
+    $socid = $user->societe_id;
+}
+
+$year = strftime("%Y", time());
+$startyear=$year-2;
+$endyear=$year;
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+$langs->load("propal");
+
+llxHeader();
+
+print_fiche_titre($langs->trans("SubscriptionsStatistics"), $mesg);
+
+$dir=$conf->adherent->dir_temp;
+
+dol_mkdir($dir);
+
+$stats = new AdherentStats($db, $socid, $userid);
+
+// Build graphic number of object
+$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+
+$filenamenb = $dir.'/subscriptionsnbinyear-'.$year.'.png';
+$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.'.png';
+
+
+$px1 = new DolGraph();
+$mesg = $px1->isGraphKo();
+if (! $mesg)
+{
+    $px1->SetData($data);
+    $px1->SetPrecisionY(0);
+    $i=$startyear;
+    while ($i <= $endyear)
+    {
+        $legend[]=$i;
+        $i++;
+    }
+    $px1->SetLegend($legend);
+    $px1->SetMaxValue($px1->GetCeilMaxValue());
+    $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
+    $px1->SetWidth($WIDTH);
+    $px1->SetHeight($HEIGHT);
+    $px1->SetYLabel($langs->trans("NbOfSubscriptions"));
+    $px1->SetShading(3);
+    $px1->SetHorizTickIncrement(1);
+    $px1->SetPrecisionY(0);
+    $px1->mode='depth';
+    $px1->SetTitle($langs->trans("NbOfSubscriptions"));
+
+    $px1->draw($filenamenb,$fileurlnb);
+}
+
+// Build graphic amount of object
+$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+$filenameamount = $dir.'/subscriptionsamountinyear-'.$year.'.png';
+$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.'.png';
+
+$px2 = new DolGraph();
+$mesg = $px2->isGraphKo();
+if (! $mesg)
+{
+    $px2->SetData($data);
+    $px2->SetPrecisionY(0);
+    $i=$startyear;
+    while ($i <= $endyear)
+    {
+        $legend[]=$i;
+        $i++;
+    }
+    $px2->SetLegend($legend);
+    $px2->SetMaxValue($px2->GetCeilMaxValue());
+    $px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
+    $px2->SetWidth($WIDTH);
+    $px2->SetHeight($HEIGHT);
+    $px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
+    $px2->SetShading(3);
+    $px2->SetHorizTickIncrement(1);
+    $px2->SetPrecisionY(0);
+    $px2->mode='depth';
+    $px2->SetTitle($langs->trans("AmountOfSubscriptions"));
+
+    $px2->draw($filenameamount,$fileurlamount);
+}
+
+
+$head = member_stats_prepare_head($adh);
+
+dol_fiche_head($head, 'statssubscription', $langs->trans("Statistics"), 0, 'user');
+
+
+print '<table class="notopnoleftnopadd" width="100%"><tr>';
+print '<td align="center" valign="top">';
+
+// Show filter box
+/*print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+print '<table class="border" width="100%">';
+print '<tr><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
+print '<tr><td>'.$langs->trans("Member").'</td><td>';
+$filter='s.client in (1,2,3)';
+print $form->select_company($id,'memberid',$filter,1);
+print '</td></tr>';
+print '<tr><td>'.$langs->trans("User").'</td><td>';
+print $form->select_users($userid,'userid',1);
+print '</td></tr>';
+print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
+print '</table>';
+print '</form>';
+print '<br><br>';
+*/
+
+// Show array
+$data = $stats->getAllByYear();
+
+
+print '<table class="border" width="100%">';
+print '<tr height="24">';
+print '<td align="center">'.$langs->trans("Year").'</td>';
+print '<td align="center">'.$langs->trans("NbOfSubscriptions").'</td>';
+print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
+print '<td align="center">'.$langs->trans("AmountAverage").'</td>';
+print '</tr>';
+
+$oldyear=0;
+foreach ($data as $val)
+{
+    $year = $val['year'];
+    print $avg;
+    while ($oldyear > $year+1)
+    {	// If we have empty year
+        $oldyear--;
+        print '<tr height="24">';
+        print '<td align="center">';
+        print '<a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">';
+        print $oldyear;
+        print '</a>';
+        print '</td>';
+        print '<td align="right">0</td>';
+        print '<td align="right">0</td>';
+        print '<td align="right">0</td>';
+        print '</tr>';
+    }
+    print '<tr height="24">';
+    print '<td align="center">';
+    //print '<a href="month.php?year='.$year.'">';
+    print $year;
+    //print '</a>';
+    print '</td>';
+    print '<td align="right">'.$val['nb'].'</td>';
+    print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
+    print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';
+    print '</tr>';
+    $oldyear=$year;
+}
+
+print '</table>';
+
+
+print '</td>';
+print '<td align="center" valign="top">';
+
+// Show graphs
+print '<table class="border" width="100%"><tr valign="top"><td align="center">';
+if ($mesg) { print $mesg; }
+else {
+    print $px1->show();
+    print "<br>\n";
+    print $px2->show();
+}
+print '</td></tr></table>';
+
+print '</td></tr></table>';
+
+dol_fiche_end();
+
+
+llxFooter();
+
+$db->close();
+?>

+ 642 - 0
dolicloudimages/dolibarr/src/htdocs/adherents/type.php

@@ -0,0 +1,642 @@
+<?php
+/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/adherents/type.php
+ *      \ingroup    member
+ *		\brief      Member's type setup
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+
+$langs->load("members");
+
+$rowid		= GETPOST('rowid','int');
+$action		= GETPOST('action','alpha');
+
+$search_lastname	= GETPOST('search_nom','alpha');
+$search_login		= GETPOST('search_login','alpha');
+$search_email		= GETPOST('search_email','alpha');
+$type				= GETPOST('type','alpha');
+$status				= GETPOST('status','alpha');
+
+$sortfield	= GETPOST('sortfield','alpha');
+$sortorder	= GETPOST('sortorder','alpha');
+$page		= GETPOST('page','int');
+if ($page == -1) { $page = 0 ; }
+$offset = $conf->liste_limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+if (! $sortorder) {  $sortorder="DESC"; }
+if (! $sortfield) {  $sortfield="d.nom"; }
+
+// Security check
+$result=restrictedArea($user,'adherent',$rowid,'adherent_type');
+
+if (GETPOST('button_removefilter'))
+{
+    $search_lastname="";
+    $search_login="";
+    $search_email="";
+    $type="";
+    $sall="";
+}
+
+
+
+/*
+ *	Actions
+ */
+if ($action == 'add' && $user->rights->adherent->configurer)
+{
+	if ($_POST["button"] != $langs->trans("Cancel"))
+	{
+		$adht = new AdherentType($db);
+
+		$adht->libelle     = trim($_POST["libelle"]);
+		$adht->cotisation  = trim($_POST["cotisation"]);
+		$adht->note        = trim($_POST["comment"]);
+		$adht->mail_valid  = trim($_POST["mail_valid"]);
+		$adht->vote        = trim($_POST["vote"]);
+
+		if ($adht->libelle)
+		{
+			$id=$adht->create($user->id);
+			if ($id > 0)
+			{
+				Header("Location: ".$_SERVER["PHP_SELF"]);
+				exit;
+			}
+			else
+			{
+				$mesg=$adht->error;
+				$action = 'create';
+			}
+		}
+		else
+		{
+			$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Label"));
+			$action = 'create';
+		}
+	}
+}
+
+if ($action == 'update' && $user->rights->adherent->configurer)
+{
+	if ($_POST["button"] != $langs->trans("Cancel"))
+	{
+		$adht = new AdherentType($db);
+		$adht->id          = $_POST["rowid"];
+		$adht->libelle     = trim($_POST["libelle"]);
+		$adht->cotisation  = trim($_POST["cotisation"]);
+		$adht->note        = trim($_POST["comment"]);
+		$adht->mail_valid  = trim($_POST["mail_valid"]);
+		$adht->vote        = trim($_POST["vote"]);
+
+		$adht->update($user->id);
+
+		Header("Location: ".$_SERVER["PHP_SELF"]."?rowid=".$_POST["rowid"]);
+		exit;
+	}
+}
+
+if ($action == 'delete' && $user->rights->adherent->configurer)
+{
+	$adht = new AdherentType($db);
+	$adht->delete($rowid);
+	Header("Location: ".$_SERVER["PHP_SELF"]);
+	exit;
+}
+
+if ($action == 'commentaire' && $user->rights->adherent->configurer)
+{
+	$don = new Don($db);
+	$don->fetch($rowid);
+	$don->update_note($_POST["commentaire"]);
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("MembersTypeSetup"),'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros');
+
+$form=new Form($db);
+
+
+// Liste of members type
+
+if (! $rowid && $action != 'create' && $action != 'edit')
+{
+
+	print_fiche_titre($langs->trans("MembersTypes"));
+
+
+	$sql = "SELECT d.rowid, d.libelle, d.cotisation, d.vote";
+	$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
+	$sql.= " WHERE d.entity IN (".getEntity().")";
+
+	$result = $db->query($sql);
+	if ($result)
+	{
+		$num = $db->num_rows($result);
+		$i = 0;
+
+		print '<table class="noborder" width="100%">';
+
+		print '<tr class="liste_titre">';
+		print '<td>'.$langs->trans("Ref").'</td>';
+		print '<td>'.$langs->trans("Label").'</td>';
+		print '<td align="center">'.$langs->trans("SubscriptionRequired").'</td>';
+		print '<td align="center">'.$langs->trans("VoteAllowed").'</td>';
+		print '<td>&nbsp;</td>';
+		print "</tr>\n";
+
+		$var=True;
+		while ($i < $num)
+		{
+			$objp = $db->fetch_object($result);
+			$var=!$var;
+			print "<tr ".$bc[$var].">";
+			print '<td><a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a></td>';
+			print '<td>'.$objp->libelle.'</td>';
+			print '<td align="center">'.yn($objp->cotisation).'</td>';
+			print '<td align="center">'.yn($objp->vote).'</td>';
+			print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$objp->rowid.'">'.img_edit().'</a></td>';
+			print "</tr>";
+			$i++;
+		}
+		print "</table>";
+	}
+	else
+	{
+		dol_print_error($db);
+	}
+
+
+	/*
+	 * Barre d'actions
+	 *
+	 */
+	print '<div class="tabsAction">';
+
+	// New type
+	if ($user->rights->adherent->configurer)
+	{
+		print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=create">'.$langs->trans("NewType").'</a>';
+	}
+
+	print "</div>";
+
+}
+
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Creation d'un type adherent                                                */
+/*                                                                            */
+/* ************************************************************************** */
+if ($action == 'create')
+{
+	$form = new Form($db);
+
+	print_fiche_titre($langs->trans("NewMemberType"));
+
+	if ($mesg) print '<div class="error">'.$mesg.'</div>';
+
+	print '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<table class="border" width="100%">';
+
+	print '<input type="hidden" name="action" value="add">';
+
+	print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40"></td></tr>';
+
+	print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
+	print $form->selectyesno("cotisation",1,1);
+	print '</td></tr>';
+
+	print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
+	print $form->selectyesno("vote",0,1);
+	print '</td></tr>';
+
+	print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
+	print '<textarea name="comment" wrap="soft" cols="60" rows="3"></textarea></td></tr>';
+
+	print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
+	require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+	$doleditor=new DolEditor('mail_valid',$adht->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90);
+	$doleditor->Create();
+	print '</td></tr>';
+
+	print "</table>\n";
+
+	print '<br>';
+	print '<center><input type="submit" name="button" class="button" value="'.$langs->trans("Add").'"> &nbsp; &nbsp; ';
+	print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
+
+	print "</form>\n";
+}
+
+/* ************************************************************************** */
+/*                                                                            */
+/* Edition de la fiche                                                        */
+/*                                                                            */
+/* ************************************************************************** */
+if ($rowid > 0)
+{
+	if ($action != 'edit')
+	{
+		$adht = new AdherentType($db);
+		$adht->fetch($rowid);
+
+		$h=0;
+
+		$head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id;
+		$head[$h][1] = $langs->trans("Card");
+		$head[$h][2] = 'card';
+		$h++;
+
+		dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
+
+
+		print '<table class="border" width="100%">';
+
+		// Ref
+		print '<tr><td width="15%">'.$langs->trans("Ref").'</td>';
+		print '<td>';
+		print $form->showrefnav($adht,'rowid');
+		print '</td></tr>';
+
+		// Label
+		print '<tr><td width="15%">'.$langs->trans("Label").'</td><td>'.$adht->libelle.'</td></tr>';
+
+		print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
+		print yn($adht->cotisation);
+		print '</tr>';
+
+		print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
+		print yn($adht->vote);
+		print '</tr>';
+
+		print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
+		print nl2br($adht->note)."</td></tr>";
+
+		print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
+		print nl2br($adht->mail_valid)."</td></tr>";
+
+		print '</table>';
+
+		print '</div>';
+
+		/*
+		 * Barre d'actions
+		 *
+		 */
+		print '<div class="tabsAction">';
+
+		// Edit
+		if ($user->rights->adherent->configurer)
+		{
+			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;rowid='.$adht->id.'">'.$langs->trans("Modify").'</a>';
+		}
+
+		// Add
+		print '<a class="butAction" href="fiche.php?action=create&typeid='.$adht->id.'">'.$langs->trans("AddMember").'</a>';
+
+		// Delete
+		if ($user->rights->adherent->configurer)
+		{
+			print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?action=delete&rowid='.$adht->id.'">'.$langs->trans("DeleteType").'</a>';
+		}
+
+		print "</div>";
+
+
+		// Show list of members (nearly same code than in page liste.php)
+
+		$membertypestatic=new AdherentType($db);
+
+		$sql = "SELECT d.rowid, d.login, d.prenom as firstname, d.nom as lastname, d.societe, ";
+		$sql.= " d.datefin,";
+		$sql.= " d.email, d.fk_adherent_type as type_id, d.morphy, d.statut,";
+		$sql.= " t.libelle as type, t.cotisation";
+		$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
+		$sql.= " WHERE d.fk_adherent_type = t.rowid ";
+		$sql.= " AND d.entity IN (".getEntity().")";
+		$sql.= " AND t.rowid = ".$adht->id;
+		if ($sall)
+		{
+		    $sql.= " AND (d.prenom LIKE '%".$sall."%' OR d.nom LIKE '%".$sall."%' OR d.societe LIKE '%".$sall."%'";
+		    $sql.= " OR d.email LIKE '%".$sall."%' OR d.login LIKE '%".$sall."%' OR d.adresse LIKE '%".$sall."%'";
+		    $sql.= " OR d.ville LIKE '%".$sall."%' OR d.note LIKE '%".$sall."%')";
+		}
+		if ($status != '')
+		{
+		    $sql.= " AND d.statut IN (".$status.")";     // Peut valoir un nombre ou liste de nombre separes par virgules
+		}
+		if ($action == 'search')
+		{
+		  if (isset($_POST['search']) && $_POST['search'] != '')
+		  {
+		    $sql.= " AND (d.prenom LIKE '%".$_POST['search']."%' OR d.nom LIKE '%".$_POST['search']."%')";
+		  }
+		}
+		if (! empty($search_lastname))
+		{
+			$sql.= " AND (d.prenom LIKE '%".$search_lastname."%' OR d.nom LIKE '%".$search_lastname."%')";
+		}
+		if (! empty($search_login))
+		{
+		    $sql.= " AND d.login LIKE '%".$search_login."%'";
+		}
+		if (! empty($search_email))
+		{
+		    $sql.= " AND d.email LIKE '%".$search_email."%'";
+		}
+		if ($filter == 'uptodate')
+		{
+		    $sql.=" AND datefin >= ".$db->idate(mktime());
+		}
+		if ($filter == 'outofdate')
+		{
+		    $sql.=" AND datefin < ".$db->idate(mktime());
+		}
+		// Count total nb of records
+		$nbtotalofrecords = 0;
+		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
+		{
+			$resql = $db->query($sql);
+		    if ($resql) $nbtotalofrecords = $db->num_rows($result);
+		    else dol_print_error($db);
+		}
+		// Add order and limit
+		$sql.= " ".$db->order($sortfield,$sortorder);
+		$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
+
+		$resql = $db->query($sql);
+		if ($resql)
+		{
+		    $num = $db->num_rows($resql);
+		    $i = 0;
+
+		    $titre=$langs->trans("MembersList");
+		    if ($status != '')
+		    {
+		        if ($status == '-1,1')								{ $titre=$langs->trans("MembersListQualified"); }
+		        else if ($status == '-1')							{ $titre=$langs->trans("MembersListToValid"); }
+		        else if ($status == '1' && ! $filter)				{ $titre=$langs->trans("MembersListValid"); }
+		        else if ($status == '1' && $filter=='uptodate')		{ $titre=$langs->trans("MembersListUpToDate"); }
+		        else if ($status == '1' && $filter=='outofdate')	{ $titre=$langs->trans("MembersListNotUpToDate"); }
+		        else if ($status == '0')							{ $titre=$langs->trans("MembersListResiliated"); }
+		    }
+		    elseif ($action == 'search')
+		    {
+		        $titre=$langs->trans("MembersListQualified");
+		    }
+
+		    if ($type > 0)
+		    {
+				$membertype=new AdherentType($db);
+		        $result=$membertype->fetch($type);
+				$titre.=" (".$membertype->libelle.")";
+		    }
+
+		    $param="&rowid=".$rowid;
+		    if (! empty($status))			$param.="&status=".$status;
+		    if (! empty($search_lastname))	$param.="&search_nom=".$search_lastname;
+		    if (! empty($search_firstname))	$param.="&search_prenom=".$search_firstname;
+		    if (! empty($search_login))		$param.="&search_login=".$search_login;
+		    if (! empty($search_email))		$param.="&search_email=".$search_email;
+		    if (! empty($filter))			$param.="&filter=".$filter;
+
+		    if ($sall)
+		    {
+		        print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
+		    }
+
+		    print '<br>';
+            print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords);
+		    print '<table class="noborder" width="100%">';
+
+		    print '<tr class="liste_titre">';
+		    print_liste_field_titre($langs->trans("Name")." / ".$langs->trans("Company"),$_SERVER["PHP_SELF"],"d.nom",$param,"","",$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("Login"),$_SERVER["PHP_SELF"],"d.login",$param,"","",$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("Person"),$_SERVER["PHP_SELF"],"d.morphy",$param,"","",$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("EMail"),$_SERVER["PHP_SELF"],"d.email",$param,"","",$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.statut,d.datefin",$param,"","",$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("EndSubscription"),$_SERVER["PHP_SELF"],"d.datefin",$param,"",'align="center"',$sortfield,$sortorder);
+		    print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"",$param,"",'width="60" align="center"',$sortfield,$sortorder);
+		    print "</tr>\n";
+
+			// Lignes des champs de filtre
+			print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
+			print '<input class="flat" type="hidden" name="rowid" value="'.$rowid.'" size="12"></td>';
+
+			print '<tr class="liste_titre">';
+
+			print '<td class="liste_titre" align="left">';
+			print '<input class="flat" type="text" name="search_nom" value="'.$search_lastname.'" size="12"></td>';
+
+			print '<td class="liste_titre" align="left">';
+			print '<input class="flat" type="text" name="search_login" value="'.$search_login.'" size="7"></td>';
+
+			print '<td class="liste_titre">&nbsp;</td>';
+
+			print '<td class="liste_titre" align="left">';
+			print '<input class="flat" type="text" name="search_email" value="'.$search_email.'" size="12"></td>';
+
+			print '<td class="liste_titre">&nbsp;</td>';
+
+			print '<td align="right" colspan="2" class="liste_titre">';
+			print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
+		    print '&nbsp; ';
+		    print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
+			print '</td>';
+
+			print "</tr>\n";
+			print '</form>';
+
+		    $var=True;
+		    while ($i < $num && $i < $conf->liste_limit)
+		    {
+		        $objp = $db->fetch_object($resql);
+
+		        $datefin=$db->jdate($objp->datefin);
+
+		        $adh=new Adherent($db);
+		        $adh->lastname=$objp->lastname;
+		        $adh->firstname=$objp->firstname;
+
+		        // Nom
+		        $var=!$var;
+		        print '<tr '.$bc[$var].'>';
+		        if ($objp->societe != '')
+		        {
+		            print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,20).' / '.dol_trunc($objp->societe,12).'</a></td>'."\n";
+		        }
+		        else
+		        {
+		            print '<td><a href="fiche.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"),"user").' '.$adh->getFullName($langs,0,-1,32).'</a></td>'."\n";
+		        }
+
+		        // Login
+		        print "<td>".$objp->login."</td>\n";
+
+		        // Type
+		        /*print '<td nowrap="nowrap">';
+		        $membertypestatic->id=$objp->type_id;
+		        $membertypestatic->libelle=$objp->type;
+		        print $membertypestatic->getNomUrl(1,12);
+		        print '</td>';
+				*/
+
+		        // Moral/Physique
+		        print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
+
+		        // EMail
+		        print "<td>".dol_print_email($objp->email,0,0,1)."</td>\n";
+
+		        // Statut
+		        print '<td nowrap="nowrap">';
+		        print $adh->LibStatut($objp->statut,$objp->cotisation,$datefin,2);
+		        print "</td>";
+
+		        // Date fin cotisation
+		        if ($datefin)
+		        {
+			        print '<td align="center" nowrap="nowrap">';
+		            if ($datefin < time() && $objp->statut > 0)
+		            {
+		                print dol_print_date($datefin,'day')." ".img_warning($langs->trans("SubscriptionLate"));
+		            }
+		            else
+		            {
+		                print dol_print_date($datefin,'day');
+		            }
+		            print '</td>';
+		        }
+		        else
+		        {
+			        print '<td align="left" nowrap="nowrap">';
+			        if ($objp->cotisation == 'yes')
+			        {
+		                print $langs->trans("SubscriptionNotReceived");
+		                if ($objp->statut > 0) print " ".img_warning();
+			        }
+			        else
+			        {
+			            print '&nbsp;';
+			        }
+		            print '</td>';
+		        }
+
+		        // Actions
+		        print '<td align="center">';
+				if ($user->rights->adherent->creer)
+				{
+					print '<a href="fiche.php?rowid='.$objp->rowid.'&action=edit&return=liste.php">'.img_edit().'</a>';
+				}
+				print '&nbsp;';
+				if ($user->rights->adherent->supprimer)
+				{
+					print '<a href="fiche.php?rowid='.$objp->rowid.'&action=resign&return=liste.php">'.img_picto($langs->trans("Resiliate"),'disable.png').'</a>';
+		        }
+				print "</td>";
+
+		        print "</tr>\n";
+		        $i++;
+		    }
+
+		    print "</table>\n";
+
+			if ($num > $conf->liste_limit)
+			{
+			    print_barre_liste('',$page,$_SERVER["PHP_SELF"],$param,$sortfield,$sortorder,'',$num,$nbtotalofrecords,'');
+			}
+		}
+		else
+		{
+		    dol_print_error($db);
+		}
+
+	}
+
+	if ($action == 'edit')
+	{
+		$form = new Form($db);
+
+		$adht = new AdherentType($db);
+		$adht->id = $rowid;
+		$adht->fetch($rowid);
+
+
+		$h=0;
+
+		$head[$h][0] = $_SERVER["PHP_SELF"].'?rowid='.$adht->id;
+		$head[$h][1] = $langs->trans("Card");
+		$head[$h][2] = 'card';
+		$h++;
+
+		dol_fiche_head($head, 'card', $langs->trans("MemberType"), 0, 'group');
+
+		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'">';
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+		print '<input type="hidden" name="action" value="update">';
+		print '<table class="border" width="100%">';
+
+		print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td>'.$adht->id.'</td></tr>';
+
+		print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="libelle" size="40" value="'.$adht->libelle.'"></td></tr>';
+
+		print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
+		print $form->selectyesno("cotisation",$adht->cotisation,1);
+		print '</td></tr>';
+
+		print '<tr><td>'.$langs->trans("VoteAllowed").'</td><td>';
+		print $form->selectyesno("vote",$adht->vote,1);
+		print '</td></tr>';
+
+		print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
+		print '<textarea name="comment" wrap="soft" cols="90" rows="3">'.$adht->note.'</textarea></td></tr>';
+
+		print '<tr><td valign="top">'.$langs->trans("WelcomeEMail").'</td><td>';
+		require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+		$doleditor=new DolEditor('mail_valid',$adht->mail_valid,'',280,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,15,90);
+		$doleditor->Create();
+		print "</td></tr>";
+
+		print '</table>';
+
+		print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"> &nbsp; &nbsp;';
+		print '<input type="submit" name="button" class="button" value="'.$langs->trans("Cancel").'"></center>';
+
+		print "</form>";
+	}
+}
+
+$db->close();
+
+llxFooter();
+?>

+ 172 - 0
dolicloudimages/dolibarr/src/htdocs/admin/accounting.php

@@ -0,0 +1,172 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2009 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/accounting.php
+ *      \ingroup    accounting
+ *      \brief      Page de configuration du module comptabilite expert
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load('admin');
+$langs->load('compta');
+
+if (!$user->admin)
+  accessforbidden();
+
+
+
+$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
+
+if ($_POST['action'] == 'setcomptamode')
+{
+  $compta_mode = $_POST['compta_mode'];
+  if (! dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity)) { print $db->error(); }
+}
+
+
+$form = new Form($db);
+$typeconst=array('yesno','texte','chaine');
+
+
+if ($_POST['action'] == 'update' || $_POST['action'] == 'add')
+{
+	if (! dolibarr_set_const($db, $_POST['constname'], $_POST['constvalue'], $typeconst[$_POST['consttype']], 0, isset($_POST['constnote']) ? $_POST['constnote'] : '',$conf->entity));
+	{
+	  	print $db->error();
+	}
+}
+
+
+if ($_GET['action'] == 'delete')
+{
+	if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
+	{
+	  	print $db->error();
+	}
+}
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
+
+
+print '<br>';
+
+print '<table class="noborder" width="100%">';
+
+// Cas du parametre COMPTA_MODE
+print '<form action="compta.php" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setcomptamode">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
+print '<td><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
+print "</tr>\n";
+print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
+print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'))."</td></tr>\n";
+print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
+print '<td colspan="2">'.$langs->trans('OptionModeVirtualDesc')."</td></tr>\n";
+print '</form>';
+
+print "</table>\n";
+
+print "<br>\n";
+
+// Cas des autres param�tres COMPTA_*
+/*
+$sql ="SELECT rowid, name, value, type, note";
+$sql.=" FROM ".MAIN_DB_PREFIX."const";
+$sql.=" WHERE name like 'COMPTA_%' and name not in ('COMPTA_MODE')";
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+	$var=true;
+
+	if ($num)
+	{
+		print '<table class="noborder" width="100%">';
+		print '<tr class="liste_titre">';
+		print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
+		print "</tr>\n";
+	}
+
+	while ($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$var=!$var;
+
+		print '<form action="compta.php" method="POST">';
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+		print '<input type="hidden" name="action" value="update">';
+		print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+		print '<input type="hidden" name="constname" value="'.$obj->name.'">';
+
+		print '<tr '.$bc[$var].' class="value">';
+		print '<td>'.stripslashes(nl2br($obj->note))."</td>\n";
+
+		print '<td>';
+		if ($obj->type == 'yesno')
+		{
+			print $form->selectyesno('constvalue',$obj->value,1);
+		}
+		elseif ($obj->type == 'texte')
+		{
+			print '<textarea name="constvalue" cols="35" rows="5" wrap="soft">';
+			print $obj->value;
+			print "</textarea>\n";
+		}
+		else
+		{
+			print '<input type="text" size="30" name="constvalue" value="'.stripslashes($obj->value).'">';
+		}
+		print '</td><td>';
+		print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
+		print "</td></tr>\n";
+
+		print '</form>';
+
+		$i++;
+	}
+
+	if ($num)
+	{
+		print "</table>\n";
+	}
+}
+*/
+
+
+$db->close();
+
+
+llxFooter();
+
+?>

+ 169 - 0
dolicloudimages/dolibarr/src/htdocs/admin/agenda.php

@@ -0,0 +1,169 @@
+<?php
+/* Copyright (C) 2008-2010	Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2011		Regis Houssin		<regis@dolibarr.fr>
+ * Copyright (C) 2011-2012  Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/agenda.php
+ *      \ingroup    agenda
+ *      \brief      Autocreate actions for agenda module setup page
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
+
+if (!$user->admin)
+    accessforbidden();
+
+$langs->load("admin");
+$langs->load("other");
+
+$action = GETPOST('action','alpha');
+$cancel = GETPOST('cancel','alpha');
+
+// Get list of triggers available
+$sql = "SELECT a.rowid, a.code, a.label, a.elementtype";
+$sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a";
+$sql.= " ORDER BY a.rang ASC";
+
+$resql=$db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+	while ($i < $num)
+	{
+		$obj = $db->fetch_object($resql);
+		$triggers[$i]['rowid'] 		= $obj->rowid;
+		$triggers[$i]['code'] 		= $obj->code;
+		$triggers[$i]['element'] 	= $obj->elementtype;
+		$triggers[$i]['label']		= ($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
+
+		$i++;
+	}
+	$db->free($resql);
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+/*
+*	Actions
+*/
+if ($action == "save" && empty($cancel))
+{
+    $i=0;
+
+    $db->begin();
+
+	foreach ($triggers as $trigger)
+	{
+		$param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
+		//print "param=".$param." - ".$_POST[$param];
+		if (GETPOST($param,'alpha')) $res = dolibarr_set_const($db,$param,GETPOST($param,'alpha'),'chaine',0,'',$conf->entity);
+		else $res = dolibarr_del_const($db,$param,$conf->entity);
+		if (! $res > 0) $error++;
+	}
+
+ 	if (! $error)
+    {
+    	$db->commit();
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+    	$db->rollback();
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+
+/**
+ * Affichage du formulaire de saisie
+ */
+
+llxHeader();
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
+print "<br>\n";
+
+print $langs->trans("AgendaAutoActionDesc")."<br>\n";
+print "<br>\n";
+
+$head=agenda_prepare_head();
+
+dol_fiche_head($head, 'autoactions', $langs->trans("Agenda"));
+
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="save">';
+
+$var=true;
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td colspan="2">'.$langs->trans("ActionsEvents").'</td>';
+print '<td><a href="'.$_SERVER["PHP_SELF"].'?action=selectall">'.$langs->trans("All").'</a>/<a href="'.$_SERVER["PHP_SELF"].'?action=selectnone">'.$langs->trans("None").'</a>';
+print '</tr>'."\n";
+if (! empty($triggers))
+{
+	foreach ($triggers as $trigger)
+	{
+		$module = $trigger['element'];
+		if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur';
+		if ($module == 'shipping') $module = 'expedition_bon';
+		if ($module == 'member') $module = 'adherent';
+		//print 'module='.$module.'<br>';
+		if ($conf->$module->enabled)
+		{
+			$var=!$var;
+			print '<tr '.$bc[$var].'>';
+			print '<td>'.$trigger['code'].'</td>';
+			print '<td>'.$trigger['label'].'</td>';
+			print '<td align="right" width="40">';
+			$key='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
+			$value=$conf->global->$key;
+			print '<input '.$bc[$var].' type="checkbox" name="'.$key.'" value="1"'.((($action=='selectall'||$value) && $action!="selectnone")?' checked="checked"':'').'>';
+			print '</td></tr>'."\n";
+		}
+	}
+}
+print '</table>';
+
+print '<br><center>';
+print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
+print ' &nbsp; &nbsp; ';
+print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
+print "</center>";
+
+print "</form>\n";
+
+print '</div>';
+
+print "<br>";
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 193 - 0
dolicloudimages/dolibarr/src/htdocs/admin/agenda_extsites.php

@@ -0,0 +1,193 @@
+<?php
+/* Copyright (C) 2008-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011-2012 Juanjo Menent        <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/agenda_extsites.php
+ *      \ingroup    agenda
+ *      \brief      Page to setup external calendars for agenda module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php');
+require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php');
+require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
+
+if (!$user->admin)
+    accessforbidden();
+
+$langs->load("agenda");
+$langs->load("admin");
+$langs->load("other");
+
+$def = array();
+$actiontest=GETPOST('test','alpha');
+$actionsave=GETPOST('save','alpha');
+
+if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
+$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
+
+// List of aviable colors
+$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
+
+/*
+ * Actions
+ */
+if ($actionsave)
+{
+    $db->begin();
+
+    $disableext=GETPOST('AGENDA_DISABLE_EXT','alpha');
+    if ($disableext) $disableext=0; else $disableext=1;
+	$res=dolibarr_set_const($db,'AGENDA_DISABLE_EXT',$disableext,'chaine',0);
+
+	$i=1;
+	$error=0;
+
+	// Save agendas
+	while ($i <= $MAXAGENDA)
+	{
+		$color=trim(GETPOST('agenda_ext_color'.$i,'alpha'));
+		if ($color=='-1') $color='';
+
+		//print 'color='.$color;
+		$res=dolibarr_set_const($db,'AGENDA_EXT_NAME'.$i,trim(GETPOST('agenda_ext_name'.$i),'alpha'),'chaine',0);
+		if (! $res > 0) $error++;
+		$res=dolibarr_set_const($db,'AGENDA_EXT_SRC'.$i,trim(GETPOST('agenda_ext_src'.$i,'alpha')),'chaine',0);
+		if (! $res > 0) $error++;
+		$res=dolibarr_set_const($db,'AGENDA_EXT_COLOR'.$i,$color,'chaine',0);
+		if (! $res > 0) $error++;
+		$i++;
+	}
+	// Save nb of agenda
+	$res=dolibarr_set_const($db,'AGENDA_EXT_NB',trim(GETPOST('AGENDA_EXT_NB','alpha')),'chaine',0);
+	if (! $res > 0) $error++;
+	if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
+	$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
+
+    if (! $error)
+    {
+        $db->commit();
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $db->rollback();
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formadmin=new FormAdmin($db);
+$formother=new FormOther($db);
+
+$arrayofjs=array();
+$arrayofcss=array();
+
+llxHeader('',$langs->trans("AgendaSetup"),'','',0,0,$arrayofjs,$arrayofcss);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
+print '<br>';
+
+print $langs->trans("AgendaExtSitesDesc")."<br>\n";
+print "<br>\n";
+
+$head=agenda_prepare_head();
+
+dol_fiche_head($head, 'extsites', $langs->trans("Agenda"));
+
+print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
+
+$selectedvalue=(GETPOST('AGENDA_DISABLE_AGENDA','alpha'))?GETPOST('AGENDA_DISABLE_EXT','alpha'):$conf->global->AGENDA_DISABLE_EXT;
+if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
+print $langs->trans("ExtSitesEnableThisTool").' '.$form->selectyesno("AGENDA_DISABLE_EXT",$selectedvalue,1).'<br><br>';
+
+$var=false;
+print "<table class=\"noborder\" width=\"100%\">";
+
+print "<tr class=\"liste_titre\">";
+print '<td width="180">'.$langs->trans("Parameter")."</td>";
+print "<td>".$langs->trans("Value")."</td>";
+print "</tr>";
+
+// Nb of agenda
+print "<tr ".$bc[$var].">";
+print "<td>".$langs->trans("ExtSitesNbOfAgenda")."</td>";
+print "<td>";
+print '<input class="flat" type="text" size="2" name="AGENDA_EXT_NB" value="'.$conf->global->AGENDA_EXT_NB.'">';
+print "</td>";
+print "</tr>";
+
+print "</table>";
+print "<br>";
+
+print "<table class=\"noborder\" width=\"100%\">";
+
+print "<tr class=\"liste_titre\">";
+print "<td>".$langs->trans("Parameter")."</td>";
+print "<td>".$langs->trans("Name")."</td>";
+print "<td>".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics)</td>';
+print '<td align="center">'.$langs->trans("Color").'</td>';
+print "</tr>";
+
+$i=1;
+$var=true;
+while ($i <= $MAXAGENDA)
+{
+	$key=$i;
+	$var=!$var;
+	print "<tr ".$bc[$var].">";
+	print '<td width="180" nowrap="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";
+	$name='AGENDA_EXT_NAME'.$key;
+	$src='AGENDA_EXT_SRC'.$key;
+	$color='AGENDA_EXT_COLOR'.$key;
+	print "<td><input type=\"text\" class=\"flat\" name=\"agenda_ext_name".$key."\" value=\"". $conf->global->$name . "\" size=\"28\"></td>";
+	print "<td><input type=\"text\" class=\"flat\" name=\"agenda_ext_src".$key."\" value=\"". $conf->global->$src . "\" size=\"60\"></td>";
+	print '<td nowrap="nowrap" align="center">';
+	// Possible colors are limited by Google
+	//print $formadmin->select_colors($conf->global->$color, "google_agenda_color".$key, $colorlist);
+	print $formother->select_color($conf->global->$color, "agenda_ext_color".$key, 'extsitesconfig', 1, '');
+	print '</td>';
+	print "</tr>";
+	$i++;
+}
+
+print '</table>';
+print '<br>';
+
+print '<center>';
+
+print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
+print "</center>";
+
+print "</form>\n";
+
+dol_fiche_end();
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 162 - 0
dolicloudimages/dolibarr/src/htdocs/admin/agenda_xcal.php

@@ -0,0 +1,162 @@
+<?php
+/* Copyright (C) 2008-2010 	Laurent Destailleur <eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/agenda_xcal.php
+ *      \ingroup    agenda
+ *      \brief      Page to setup miscellaneous options of agenda module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php');
+
+
+if (!$user->admin)
+    accessforbidden();
+
+$langs->load("admin");
+$langs->load("other");
+$langs->load("agenda");
+
+$def = array();
+$actionsave=GETPOST('save','alpha');
+
+// Sauvegardes parametres
+if ($actionsave)
+{
+    $i=0;
+
+    $db->begin();
+
+    $i+=dolibarr_set_const($db,'MAIN_AGENDA_XCAL_EXPORTKEY',trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha')),'chaine',0,'',$conf->entity);
+    $i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_PAST_DELAY',trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY','alpha')),'chaine',0,'',$conf->entity);
+    $i+=dolibarr_set_const($db,'MAIN_AGENDA_EXPORT_CACHE',trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE','alpha')),'chaine',0,'',$conf->entity);
+
+    if ($i >= 3)
+    {
+        $db->commit();
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $db->rollback();
+        $mesg = "<font class=\"error\">".$langs->trans("SaveFailed")."</font>";
+    }
+}
+
+
+
+/**
+ * View
+ */
+
+if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
+
+llxHeader();
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup');
+print '<br>';
+
+print $langs->trans("AgendaSetupOtherDesc")."<br>\n";
+print "<br>\n";
+
+$head=agenda_prepare_head();
+
+dol_fiche_head($head, 'xcal', $langs->trans("Agenda"));
+
+
+print '<form name="agendasetupform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print "<table class=\"noborder\" width=\"100%\">";
+
+print "<tr class=\"liste_titre\">";
+print "<td>".$langs->trans("Parameter")."</td>";
+print "<td>".$langs->trans("Value")."</td>";
+//print "<td>".$langs->trans("Examples")."</td>";
+print "<td>&nbsp;</td>";
+print "</tr>";
+
+print "<tr class=\"impair\">";
+print '<td class="fieldrequired">'.$langs->trans("PasswordTogetVCalExport")."</td>";
+print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_XCAL_EXPORTKEY\" value=\"". (GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha')?GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY','alpha'):$conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) . "\" size=\"40\"></td>";
+print "<td>&nbsp;</td>";
+print "</tr>";
+
+print "<tr class=\"pair\">";
+print "<td>".$langs->trans("PastDelayVCalExport")."</td>";
+print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_PAST_DELAY\" value=\"". (GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY','alpha')?GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY','alpha'):$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY) . "\" size=\"10\"> ".$langs->trans("days")."</td>";
+print "<td>&nbsp;</td>";
+print "</tr>";
+
+print "<tr class=\"impair\">";
+print "<td>".$langs->trans("UseACacheDelay")."</td>";
+print "<td><input type=\"text\" class=\"flat\" name=\"MAIN_AGENDA_EXPORT_CACHE\" value=\"". (GETPOST('MAIN_AGENDA_EXPORT_CACHE','alpha')?GETPOST('MAIN_AGENDA_EXPORT_CACHE','alpha'):$conf->global->MAIN_AGENDA_EXPORT_CACHE) . "\" size=\"10\"></td>";
+print "<td>&nbsp;</td>";
+print "</tr>";
+
+print '</table>';
+
+print '<br><center>';
+print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
+print "</center>";
+
+print "</form>\n";
+
+print '</div>';
+
+clearstatcache();
+
+//if ($mesg) print "<br>$mesg<br>";
+print "<br>";
+
+
+// Define $urlwithroot
+$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT;		// This is to use external domain name found into config file
+//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
+
+
+// Show message
+$message='';
+$urlvcal='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=vcal&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
+$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'vcal',$urlvcal);
+$message.='<br>';
+$urlical='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
+$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'ical/ics',$urlical);
+$message.='<br>';
+$urlrss='<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'...').'" target="_blank">'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY):'KEYNOTDEFINED').'</a>';
+$message.=img_picto('','object_globe.png').' '.$langs->trans("WebCalUrlForVCalExport",'rss',$urlrss);
+$message.='<br>';
+$message.='<br>';
+print $message;
+
+$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
+$message.=$langs->trans("AgendaUrlOptions2",$user->login,$user->login).'<br>';
+$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
+$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
+$message.=$langs->trans("AgendaUrlOptions5",$user->login,$user->login);
+print info_admin($message);
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 337 - 0
dolicloudimages/dolibarr/src/htdocs/admin/barcode.php

@@ -0,0 +1,337 @@
+<?php
+/* Copyright (C) 2003-2004	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012	Regis Houssin			<regis@dolibarr.fr>
+ * Copyright (C) 2011		Juanjo Menent			<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/barcode.php
+ *	\ingroup    barcode
+ *	\brief      Page to setup barcode module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formbarcode.class.php");
+
+$langs->load("admin");
+
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'setcoder')
+{
+	$coder = GETPOST('coder','alpha');
+	$code_id = GETPOST('code_id','alpha');
+	$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
+	$sqlp.= " SET coder = '" . $coder."'";
+	$sqlp.= " WHERE rowid = ". $code_id;
+	$sqlp.= " AND entity = ".$conf->entity;
+
+	$resql=$db->query($sqlp);
+	//print $sqlp;
+}
+else if ($action == 'setgenbarcodelocation')
+{
+	$location = GETPOST('genbarcodelocation','alpha');
+	$res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity);
+}
+else if ($action == 'setdefaultbarcodetype')
+{
+	$coder_id = GETPOST('coder_id','alpha');
+	$res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity);
+}
+else if ($action == 'GENBARCODE_BARCODETYPE_THIRDPARTY')
+{
+	$coder_id = GETPOST('coder_id','alpha');
+	$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity);
+}
+/*
+ else if ($_POST["action"] == 'setproductusebarcode')
+ {
+ dolibarr_set_const($db, "PRODUIT_USE_BARCODE",$_POST["value"],'chaine',0,'',$conf->entity);
+ Header("Location: barcode.php");
+ exit;
+ }
+ */
+
+if($action && $action!='setcoder')
+{
+	if (! $res > 0) $error++;
+
+	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+	}
+}
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formbarcode = new FormBarCode($db);
+
+llxHeader('',$langs->trans("BarcodeSetup"),'BarcodeConfiguration');
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("BarcodeSetup"),$linkback,'setup');
+
+// Detect bar codes modules
+$barcodelist=array();
+
+clearstatcache();
+
+
+// Check if there is external substitution to do asked by plugins
+$dirbarcode=array_merge(array("/core/modules/barcode/"),$conf->barcode_modules);
+
+foreach($dirbarcode as $reldir)
+{
+    $dir=dol_buildpath($reldir);
+    $newdir=dol_osencode($dir);
+
+    // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
+    if (! is_dir($newdir)) continue;
+
+	$handle=@opendir($newdir);
+	if (is_resource($handle))
+	{
+		while (($file = readdir($handle))!==false)
+		{
+			if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
+			{
+				if (is_readable($newdir.$file))
+				{
+					if (preg_match('/(.*)\.modules\.php$/i',$file,$reg))
+					{
+						$filebis=$reg[1];
+
+						// Chargement de la classe de codage
+						require_once($newdir.$file);
+						$classname = "mod".ucfirst($filebis);
+						$module = new $classname($db);
+
+						// Show modules according to features level
+						if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+						if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+						if ($module->isEnabled())
+						{
+							$barcodelist[$filebis]=$module->info();
+						}
+					}
+				}
+			}
+		}
+	}
+}
+
+/*
+ *  CHOIX ENCODAGE
+ */
+$var=true;
+
+print '<br>';
+print_titre($langs->trans("BarcodeEncodeModule"));
+
+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 width="200" align="center">'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("CodeBarGenerator").'</td>';
+print "</tr>\n";
+
+$sql = "SELECT rowid, code as encoding, libelle, coder, example";
+$sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+$sql.= " WHERE entity = ".$conf->entity;
+$sql.= " ORDER BY code";
+
+dol_syslog("admin/barcode.php sql=".$sql);
+$resql=$db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+	$var=true;
+
+	while ($i <	$num)
+	{
+		$obj = $db->fetch_object($resql);
+
+		print '<tr '.$bc[$var].'><td width="100">';
+		print $obj->libelle;
+		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>";
+		//print "L'utilisation des symbologies EAN8 impose la souscription et l'abonnement aupres d'organisme tel que GENCOD.<br>";
+		//print "Codes numeriques utilises exclusivement a l'identification des produits susceptibles d'etre vendus au grand public.";
+		print '</td>';
+
+		// Show example
+		print '<td align="center">';
+		if ($obj->coder && $obj->coder != -1)
+		{
+			$result=0;
+
+			foreach($dirbarcode as $reldir)
+			{
+			    $dir=dol_buildpath($reldir,0);
+			    $newdir=dol_osencode($dir);
+
+			    // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
+			    if (! is_dir($newdir)) continue;
+
+				$result=@include_once($newdir.$obj->coder.".modules.php");
+				if ($result) break;
+			}
+			if ($result)
+			{
+				$classname = "mod".ucfirst($obj->coder);
+				if (class_exists($classname))
+				{
+					$module = new $classname($db);
+					if ($module->encodingIsSupported($obj->encoding))
+					{
+						// Build barcode on disk (not used, this is done to make debug easier)
+					    $result=$module->writeBarCode($obj->example,$obj->encoding,'Y');
+						// Generate on the fly and output barcode with generator
+						$url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding);
+						//print $url;
+						print '<img src="'.$url.'" title="'.$obj->example.'" border="0">';
+					}
+					else
+					{
+						print $langs->trans("FormatNotSupportedByGenerator");
+					}
+				}
+				else
+				{
+					print 'ErrorClassNotFoundInModule '.$classname.' '.$obj->coder;
+				}
+			}
+		}
+		else
+		{
+			print $langs->trans("ChooseABarCode");
+		}
+		print '</td>';
+
+		print '<td align="center">';
+		print $formbarcode->setBarcodeEncoder($obj->coder,$barcodelist,$obj->rowid,'form'.$i);
+		print "</td></tr>\n";
+		$var=!$var;
+		$i++;
+	}
+}
+print "</table>\n";
+
+print "<br>";
+
+/*
+ * Autres options
+ *
+ */
+print_titre($langs->trans("OtherOptions"));
+
+$var=true;
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td width="60" align="center">'.$langs->trans("Value").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// Chemin du binaire genbarcode sous linux
+if (! isset($_SERVER['WINDIR']))
+{
+	$var=!$var;
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="setgenbarcodelocation">';
+	print '<tr '.$bc[$var].'>';
+	print '<td>'.$langs->trans("GenbarcodeLocation").'</td>';
+	print '<td width="60" align="center">';
+	print '<input type="text" size="40" name="genbarcodelocation" value="'.$conf->global->GENBARCODE_LOCATION.'">';
+	if (! empty($conf->global->GENBARCODE_LOCATION) && ! @file_exists($conf->global->GENBARCODE_LOCATION))
+	{
+		$langs->load("errors");
+		print '<br><font class="error">'.$langs->trans("ErrorFileNotFound",$conf->global->GENBARCODE_LOCATION).'</font>';
+	}
+	print '</td>';
+	print '<td width="60" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+	print '</tr>';
+	print '</form>';
+}
+
+// Module produits
+if ($conf->societe->enabled)
+{
+	$var=!$var;
+	print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"setdefaultbarcodetype\">";
+	print "<tr ".$bc[$var].">";
+	print '<td>'.$langs->trans("SetDefaultBarcodeTypeProducts").'</td>';
+	print '<td width="60" align="right">';
+	print $formbarcode->select_barcode_type($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE,"coder_id",1);
+	print '</td><td align="right">';
+	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+	print "</td>";
+	print '</tr>';
+	print '</form>';
+}
+
+// Module produits
+if ($conf->product->enabled)
+{
+	$var=!$var;
+	print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print "<input type=\"hidden\" name=\"action\" value=\"GENBARCODE_BARCODETYPE_THIRDPARTY\">";
+	print "<tr ".$bc[$var].">";
+	print '<td>'.$langs->trans("SetDefaultBarcodeTypeThirdParties").'</td>';
+	print '<td width="60" align="right">';
+	print $formbarcode->select_barcode_type($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY,"coder_id",1);
+	print '</td><td align="right">';
+	print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+	print "</td>";
+	print '</tr>';
+	print '</form>';
+}
+
+print '</table>';
+
+print "<br>";
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 450 - 0
dolicloudimages/dolibarr/src/htdocs/admin/boxes.php

@@ -0,0 +1,450 @@
+<?php
+/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   \file       htdocs/admin/boxes.php
+ *   \brief      Page to setup boxes
+ */
+
+require("../main.inc.php");
+include_once(DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/infobox.class.php");
+include_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+
+if (!$user->admin) accessforbidden();
+
+$rowid = GETPOST('rowid','int');
+$action = GETPOST('action');
+
+// Definition des positions possibles pour les boites
+$pos_array = array(0);                             // Positions possibles pour une boite (0,1,2,...)
+$pos_name = array(0=>$langs->trans("Home"));       // Nom des positions 0=Homepage, 1=...
+$boxes = array();
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'addconst')
+
+{
+    dolibarr_set_const($db, "MAIN_BOXES_MAXLINES",$_POST["MAIN_BOXES_MAXLINES"],'',0,'',$conf->entity);
+}
+
+if ($action == 'add')
+{
+    $error=0;
+
+    $db->begin();
+
+	// Initialize distinctfkuser with all already existing values of fk_user (user that use a personalized view of boxes for pos)
+	$distinctfkuser=array();
+	if (! $error)
+	{
+		$sql = "SELECT fk_user";
+		$sql.= " FROM ".MAIN_DB_PREFIX."user_param";
+		$sql.= " WHERE param = 'MAIN_BOXES_".$db->escape(GETPOST("pos","alpha"))."' AND value = '1'";
+		$sql.= " AND entity = ".$conf->entity;
+		$resql = $db->query($sql);
+		dol_syslog("boxes.php search fk_user to activate box for sql=".$sql);
+		if ($resql)
+		{
+		    $num = $db->num_rows($resql);
+            $i=0;
+		    while ($i < $num)
+		    {
+		        $obj=$db->fetch_object($resql);
+		        $distinctfkuser[$obj->fk_user]=$obj->fk_user;
+		        $i++;
+		    }
+		}
+		else
+		{
+		    $errmesg=$db->lasterror();
+		    $error++;
+		}
+	}
+
+	foreach($distinctfkuser as $fk_user)
+	{
+	    if (! $error && $fk_user != 0)    // We will add fk_user = 0 later.
+	    {
+	        $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
+	        $sql.= "box_id, position, box_order, fk_user";
+	        $sql.= ") values (";
+	        $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', ".$fk_user;
+	        $sql.= ")";
+
+	        dol_syslog("boxes.php activate box sql=".$sql);
+	        $resql = $db->query($sql);
+	        if (! $resql)
+	        {
+		        $errmesg=$db->lasterror();
+	            $error++;
+	        }
+	    }
+	}
+
+	// If value 0 was not included, we add it.
+	if (! $error)
+	{
+	    $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
+	    $sql.= "box_id, position, box_order, fk_user";
+	    $sql.= ") values (";
+	    $sql.= GETPOST("boxid","int").", ".GETPOST("pos","alpha").", 'A01', 0";
+	    $sql.= ")";
+
+	    dol_syslog("boxes.php activate box sql=".$sql);
+	    $resql = $db->query($sql);
+        if (! $resql)
+        {
+		    $errmesg=$db->lasterror();
+            $error++;
+        }
+	}
+
+	if (! $error)
+	{
+		Header("Location: boxes.php");
+	    $db->commit();
+		exit;
+	}
+	else
+	{
+	    $db->rollback();
+	}
+}
+
+if ($action == 'delete')
+{
+
+	$sql = "SELECT box_id FROM ".MAIN_DB_PREFIX."boxes";
+	$sql.= " WHERE rowid=".$rowid;
+	$resql = $db->query($sql);
+	$obj=$db->fetch_object($resql);
+    if (! empty($obj->box_id))
+    {
+	    $db->begin();
+
+    	// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
+        //	$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
+        //	$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
+        //	$resql = $db->query($sql);
+
+	    $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
+    	$sql.= " WHERE box_id=".$obj->box_id;
+    	$resql = $db->query($sql);
+
+    	$db->commit();
+    }
+}
+
+if ($action == 'switch')
+{
+	// On permute les valeur du champ box_order des 2 lignes de la table boxes
+	$db->begin();
+
+	$objfrom=new ModeleBoxes($db);
+	$objfrom->fetch($_GET["switchfrom"]);
+
+	$objto=new ModeleBoxes($db);
+	$objto->fetch($_GET["switchto"]);
+
+	$resultupdatefrom=0;
+	$resultupdateto=0;
+	if (is_object($objfrom) && is_object($objto))
+	{
+	    $newfirst=$objto->box_order;
+		$newsecond=$objfrom->box_order;
+	    if ($newfirst == $newsecond)
+	    {
+	         $newsecondchar=preg_replace('/[0-9]+/','',$newsecond);
+	         $newsecondnum=preg_replace('/[a-zA-Z]+/','',$newsecond);
+	         $newsecond=sprintf("%s%02d",$newsecondchar?$newsecondchar:'A',$newsecondnum+1);
+	    }
+		$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
+		dol_syslog($sql);
+		$resultupdatefrom = $db->query($sql);
+		if (! $resultupdatefrom) { dol_print_error($db); }
+
+		$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$newsecond."' WHERE rowid=".$objto->rowid;
+		dol_syslog($sql);
+		$resultupdateto = $db->query($sql);
+		if (! $resultupdateto) { dol_print_error($db); }
+	}
+
+	if ($resultupdatefrom && $resultupdateto)
+	{
+		$db->commit();
+	}
+	else
+	{
+		$db->rollback();
+	}
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$emptyuser=new User($db);
+//$infobox=new InfoBox($db);
+
+llxHeader('',$langs->trans("Boxes"));
+
+print_fiche_titre($langs->trans("Boxes"),'','setup');
+
+print $langs->trans("BoxesDesc")." ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
+
+dol_htmloutput_errors($errmesg);
+
+
+/*
+ * Recherche des boites actives par defaut pour chaque position possible
+ * On stocke les boites actives par defaut dans $boxes[position][id_boite]=1
+ */
+
+$actives = array();
+
+$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order,";
+$sql.= " bd.rowid as boxid";
+$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b, ".MAIN_DB_PREFIX."boxes_def as bd";
+$sql.= " WHERE b.box_id = bd.rowid";
+$sql.= " AND bd.entity = ".$conf->entity;
+$sql.= " AND b.fk_user=0";
+$sql.= " ORDER by b.position, b.box_order";
+
+$resql = $db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+	$decalage=0;
+	while ($i < $num)
+	{
+		$var = ! $var;
+		$obj = $db->fetch_object($resql);
+		$boxes[$obj->position][$obj->box_id]=1;
+		$i++;
+
+		array_push($actives,$obj->box_id);
+
+		if ($obj->box_order == '' || $obj->box_order == '0' || $decalage) $decalage++;
+		// On renumerote l'ordre des boites si l'une d'elle est a ''
+		// This occurs just after an insert.
+		if ($decalage)
+		{
+			$sql="UPDATE ".MAIN_DB_PREFIX."boxes set box_order='".$decalage."' WHERE rowid=".$obj->rowid;
+			$db->query($sql);
+		}
+	}
+
+	if ($decalage)
+	{
+	    // Si on a renumerote, on corrige champ box_order
+		// This occurs just after an insert.
+		$sql = "SELECT box_order";
+		$sql.= " FROM ".MAIN_DB_PREFIX."boxes";
+		$sql.= " WHERE length(box_order) <= 2";
+
+		dol_syslog("Execute requests to renumber box order sql=".$sql);
+		$result = $db->query($sql);
+		if ($result)
+		{
+			while ($record = $db->fetch_array($result))
+			{
+				if (dol_strlen($record['box_order']) == 1)
+				{
+					if (preg_match("/[13579]{1}/",substr($record['box_order'],-1)))
+					{
+						$box_order = "A0".$record['box_order'];
+						$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
+						$resql = $db->query($sql);
+					}
+					else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1)))
+					{
+						$box_order = "B0".$record['box_order'];
+						$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
+						$resql = $db->query($sql);
+					}
+				}
+				else if (dol_strlen($record['box_order']) == 2)
+				{
+					if (preg_match("/[13579]{1}/",substr($record['box_order'],-1)))
+					{
+						$box_order = "A".$record['box_order'];
+						$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
+						$resql = $db->query($sql);
+					}
+					else if (preg_match("/[02468]{1}/",substr($record['box_order'],-1)))
+					{
+						$box_order = "B".$record['box_order'];
+						$sql="UPDATE ".MAIN_DB_PREFIX."boxes SET box_order = '".$box_order."' WHERE box_order = '".$record['box_order']."'";
+						$resql = $db->query($sql);
+					}
+				}
+			}
+		}
+	}
+	$db->free($resql);
+}
+
+
+// Available boxes
+$boxtoadd=InfoBox::listboxes($db,'available',-1,$emptyuser,$actives);
+
+print "<br>\n";
+print_titre($langs->trans("BoxesAvailable"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="300">'.$langs->trans("Box").'</td>';
+print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
+print '<td>'.$langs->trans("SourceFile").'</td>';
+print '<td width="160">'.$langs->trans("ActivateOn").'</td>';
+print "</tr>\n";
+$var=true;
+foreach($boxtoadd as $box)
+{
+    $var=!$var;
+
+    if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
+    {
+        $logo = $box->boximg;
+    }
+    else
+    {
+        $logo=preg_replace("/^object_/i","",$box->boximg);
+    }
+
+    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<tr '.$bc[$var].'>';
+    print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
+    print '<td>' . ($box->note?$box->note:'&nbsp;') . '</td>';
+    print '<td>' . $box->sourcefile . '</td>';
+
+    // Pour chaque position possible, on affiche un lien d'activation si boite non deja active pour cette position
+    print '<td>';
+    print $form->selectarray("pos",$pos_name);
+    print '<input type="hidden" name="action" value="add">';
+    print '<input type="hidden" name="boxid" value="'.$box->box_id.'">';
+    print ' <input type="submit" class="button" name="button" value="'.$langs->trans("Activate").'">';
+    print '</td>';
+
+    print '</tr>';
+    print '</form>';
+}
+
+print '</table>';
+
+
+// Activated boxes
+$boxactivated=InfoBox::listboxes($db,'activated',-1,$emptyuser);
+
+print "<br>\n\n";
+print_titre($langs->trans("BoxesActivated"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="300">'.$langs->trans("Box").'</td>';
+print '<td>'.$langs->trans("Note").'/'.$langs->trans("Parameters").'</td>';
+print '<td align="center" width="160">'.$langs->trans("ActiveOn").'</td>';
+print '<td align="center" width="60" colspan="2">'.$langs->trans("PositionByDefault").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Disable").'</td>';
+print '</tr>'."\n";
+
+$var=true;
+$box_order=1;
+$foundrupture=1;
+foreach($boxactivated as $key => $box)
+{
+    $var = ! $var;
+
+	if (preg_match('/^([^@]+)@([^@]+)$/i',$box->boximg))
+	{
+		$logo = $box->boximg;
+	}
+	else
+	{
+		$logo=preg_replace("/^object_/i","",$box->boximg);
+	}
+
+    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+	print '<tr '.$bc[$var].'>';
+	print '<td>'.img_object("",$logo).' '.$box->boxlabel.'</td>';
+	print '<td>' . ($box->note?$box->note:'&nbsp;') . '</td>';
+	print '<td align="center">' . $pos_name[$box->position] . '</td>';
+	$hasnext=($key < (count($boxactivated)-1));
+	$hasprevious=($key != 0);
+	print '<td align="center">'.($key+1).'</td>';
+	print '<td align="center">';
+	print ($hasnext?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key+1]->rowid.'">'.img_down().'</a>&nbsp;':'');
+	print ($hasprevious?'<a href="boxes.php?action=switch&switchfrom='.$box->rowid.'&switchto='.$boxactivated[$key-1]->rowid.'">'.img_up().'</a>':'');
+	print '</td>';
+	print '<td align="center">';
+	print '<a href="boxes.php?rowid='.$box->rowid.'&amp;action=delete">'.img_delete().'</a>';
+	print '</td>';
+
+	print '</tr>'."\n";
+}
+
+print '</table><br>';
+
+
+// Other parameters
+
+print_titre($langs->trans("Other"));
+print '<table class="noborder" width="100%">';
+
+$var=false;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="addconst">';
+print '<tr class="liste_titre">';
+print '<td class="liste_titre">'.$langs->trans("Parameter").'</td>';
+print '<td class="liste_titre">'.$langs->trans("Value").'</td>';
+print '<td class="liste_titre"></td>';
+print '</tr>';
+print '<tr '.$bc[$var].'>';
+print '<td>';
+print $langs->trans("MaxNbOfLinesForBoxes");
+print '</td>'."\n";
+print '<td>';
+print '<input type="text" class="flat" size="6" name="MAIN_BOXES_MAXLINES" value="'.$conf->global->MAIN_BOXES_MAXLINES.'">';
+print '</td>';
+print '<td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Save").'" name="Button">';
+print '</td>'."\n";
+print '</tr>';
+print '</form>';
+
+print '</table>';
+
+
+llxFooter();
+
+$db->close();
+?>

+ 101 - 0
dolicloudimages/dolibarr/src/htdocs/admin/clicktodial.php

@@ -0,0 +1,101 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.org>
+ * Copyright (C) 2011 	    Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   \file       htdocs/admin/clicktodial.php
+ *   \ingroup    clicktodial
+ *   \brief      Page to setup module clicktodial
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST("action");
+
+
+/*
+ *	Actions
+ */
+if ($action == 'setvalue' && $user->admin)
+{
+    $result=dolibarr_set_const($db, "CLICKTODIAL_URL",GETPOST("url"),'chaine',0,'',$conf->entity);
+    if ($result >= 0)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
+llxHeader('',$langs->trans("ClickToDialSetup"),$wikihelp);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("ClickToDialSetup"),$linkback,'setup');
+
+print $langs->trans("ClickToDialDesc")."<br>\n";
+
+print '<br>';
+print '<form method="post" action="clicktodial.php">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setvalue">';
+
+$var=true;
+
+print '<table class="nobordernopadding" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="120">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print "</tr>\n";
+$var=!$var;
+print '<tr '.$bc[$var].'><td valign="top">';
+print $langs->trans("URL").'</td><td>';
+print '<input size="92" type="text" name="url" value="'.$conf->global->CLICKTODIAL_URL.'"><br>';
+print '<br>';
+print $langs->trans("ClickToDialUrlDesc").'<br>';
+print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__';
+print '</td></tr>';
+
+print '<tr><td colspan="3" align="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table></form>';
+
+/*if (! empty($conf->global->CLICKTODIAL_URL))
+ {
+ print $langs->trans("Test");
+ // Add a phone number to test
+ }
+ */
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 596 - 0
dolicloudimages/dolibarr/src/htdocs/admin/commande.php

@@ -0,0 +1,596 @@
+<?php
+/* Copyright (C) 2003-2006 Rodolphe Quiedeville	        <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur          <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio          <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier               <benoit.mortier@opensides.be>
+ * Copyright (C) 2004      Andre Cianfarani             <acianfa@free.fr>
+ * Copyright (C) 2005-2012 Regis Houssin                <regis@dolibarr.fr>
+ * Copyright (C) 2008 	   Raphael Bertrand (Resultic)  <raphael.bertrand@resultic.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent			    <jmenent@2byte.es>
+ * Copyright (C) 2011 	   Philippe Grand			    <philippe.grand@atoo-net.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/commande.php
+ *	\ingroup    commande
+ *	\brief      Setup page of module Order
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php');
+
+$langs->load("admin");
+$langs->load("errors");
+$langs->load("orders");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+
+/*
+ * Actions
+ */
+
+if ($action == 'updateMask')
+{
+	$maskconstorder=GETPOST('maskconstorder','alpha');
+	$maskorder=GETPOST('maskorder','alpha');
+
+	if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'specimen')
+{
+	$modele=GETPOST('module','alpha');
+
+	$commande = new Commande($db);
+	$commande->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/commande/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($commande,$langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande&file=SPECIMEN.pdf");
+			return;
+		}
+		else
+		{
+			$mesg='<font class="error">'.$module->error.'</font>';
+			dol_syslog($module->error, LOG_ERR);
+		}
+	}
+	else
+	{
+		$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
+}
+
+if ($action == 'set')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+	$type='order';
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+	if ($db->query($sql))
+	{
+
+	}
+}
+
+if ($action == 'del')
+{
+	$type='order';
+	$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+	$sql.= " WHERE nom = '".$db->escape($value)."'";
+	$sql.= " AND type = '".$type."'";
+	$sql.= " AND entity = ".$conf->entity;
+
+	if ($db->query($sql))
+	{
+        if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF',$conf->entity);
+	}
+}
+
+if ($action == 'setdoc')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+	$db->begin();
+
+	if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+	{
+		$conf->global->COMMANDE_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$type='order';
+	$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+	$sql_del.= " WHERE nom = '".$db->escape($value)."'";
+	$sql_del.= " AND type = '".$type."'";
+	$sql_del.= " AND entity = ".$conf->entity;
+	$result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$scandir."'":"null");
+    $sql.= ")";
+	$result2=$db->query($sql);
+	if ($result1 && $result2)
+	{
+		$db->commit();
+	}
+	else
+	{
+		$db->rollback();
+	}
+}
+
+if ($action == 'setmod')
+{
+	// TODO Verifier si module numerotation choisi peut etre active
+	// par appel methode canBeActivated
+
+	dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+if ($action == 'set_COMMANDE_DRAFT_WATERMARK')
+{
+	$draft = GETPOST("COMMANDE_DRAFT_WATERMARK");
+	$res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_COMMANDE_FREE_TEXT')
+{
+	$freetext = GETPOST("COMMANDE_FREE_TEXT");
+	$res = dolibarr_set_const($db, "COMMANDE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup');
+
+print "<br>";
+
+
+
+/*
+ * Numbering module
+ */
+
+print_titre($langs->trans("OrdersNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/commande/");
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			$var=true;
+
+			while (($file = readdir($handle))!==false)
+			{
+				if (substr($file, 0, 13) == 'mod_commande_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+				{
+					$file = substr($file, 0, dol_strlen($file)-4);
+
+					require_once(DOL_DOCUMENT_ROOT ."/core/modules/commande/".$file.".php");
+
+					$module = new $file;
+
+					// 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())
+					{
+						$var=!$var;
+						print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
+						print $module->info();
+						print '</td>';
+
+                        // Show example of numbering module
+                        print '<td nowrap="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+						print '<td align="center">';
+						if ($conf->global->COMMANDE_ADDON == $file)
+						{
+							print img_picto($langs->trans("Activated"),'switch_on');
+						}
+						else
+						{
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
+							print img_picto($langs->trans("Disabled"),'switch_off');
+							print '</a>';
+						}
+						print '</td>';
+
+						$commande=new Commande($db);
+						$commande->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$commande->type=0;
+						$nextval=$module->getNextValue($mysoc,$commande);
+						if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+						{
+							$htmltooltip.=''.$langs->trans("NextValue").': ';
+							if ($nextval)
+							{
+								$htmltooltip.=$nextval.'<br>';
+							}
+							else
+							{
+								$htmltooltip.=$langs->trans($module->error).'<br>';
+							}
+						}
+
+						print '<td align="center">';
+						print $form->textwithpicto('',$htmltooltip,1,0);
+						print '</td>';
+
+						print '</tr>';
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
+}
+
+print '</table><br>';
+
+
+/*
+ * Document templates generators
+ */
+print_titre($langs->trans("OrdersModelModule"));
+
+// Load array def with activated templates
+$type='order';
+$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 align="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td align="center" width="38" colspan="2">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
+    {
+    	$dir = dol_buildpath($reldir."core/modules/commande".$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 '.$bc[$var].'><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 align="center">'."\n";
+	                            	print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">';
+	                            	print img_picto($langs->trans("Enabled"),'switch_on');
+	                            	print '</a>';
+	                            	print '</td>';
+	                            }
+	                            else
+	                            {
+	                                print '<td align="center">'."\n";
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Defaut
+	                            print '<td align="center">';
+	                            if ($conf->global->COMMANDE_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"),'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$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("Escompte").': '.yn($module->option_escompte,1,1);
+					    		//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+
+
+	                            print '<td align="center">';
+	                            print $form->textwithpicto('',$htmltooltip,1,0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td align="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>';
+
+//Autres Options
+print "<br>";
+print_titre($langs->trans("OtherOptions"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print "<td>&nbsp;</td>\n";
+print "</tr>\n";
+$var=true;
+
+// Valider la commande apres cloture de la propale
+// permet de na pas passer par l'option commande provisoire
+/*
+$var=! $var;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setvalidorder">';
+print '<tr '.$bc[$var].'>';
+print '<td>'.$langs->trans("ValidOrderAfterPropalClosed").'</td>';
+print '<td width="60" align="center">'.$form->selectyesno("validorder",$conf->global->COMMANDE_VALID_AFTER_CLOSE_PROPAL,1).'</td>';
+print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+print '</tr>';
+print '</form>';
+*/
+
+// Ajouter une ligne de frais port indiquant le poids de la commande
+/*
+$var=! $var;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="deliverycostline">';
+print '<tr '.$bc[$var].'>';
+print '<td>'.$langs->trans("AddDeliveryCostLine").'</td>';
+print '<td width="60" align="center">'.$form->selectyesno("addline",$conf->global->COMMANDE_ADD_DELIVERY_COST_LINE,1).'</td>';
+print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+print '</tr>';
+print '</form>';
+*/
+
+// Utiliser le contact de la commande dans le document
+/*
+$var=! $var;
+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_use_customer_contact_as_recipient">';
+print '<tr '.$bc[$var].'>';
+print '<td>'.$langs->trans("UseCustomerContactAsOrderRecipientIfExist").'</td>';
+print '<td width="60" align="center">'.$form->selectyesno("use_customer_contact_as_recipient",$conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT,1).'</td>';
+print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+print '</tr>';
+print '</form>';
+*/
+
+$var=! $var;
+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_COMMANDE_FREE_TEXT">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="COMMANDE_FREE_TEXT" class="flat" cols="120">'.$conf->global->COMMANDE_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+//Use draft Watermark
+$var=!$var;
+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_COMMANDE_DRAFT_WATERMARK\">";
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("WatermarkOnDraftOrders").'<br>';
+print '<input size="50" class="flat" type="text" name="COMMANDE_DRAFT_WATERMARK" value="'.$conf->global->COMMANDE_DRAFT_WATERMARK.'">';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+print '</table>';
+
+print '<br>';
+
+dol_htmloutput_mesg($mesg);
+
+llxFooter();
+
+$db->close();
+?>

+ 1005 - 0
dolicloudimages/dolibarr/src/htdocs/admin/company.php

@@ -0,0 +1,1005 @@
+<?php
+/* Copyright (C) 2001-2007	Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012	Regis Houssin			<regis@dolibarr.fr>
+ * Copyright (C) 2010		Juanjo Menent			<jmenent@2byte.es>
+ * Copyright (C) 2011		Philippe Grand			<philippe.grand@atoo-net.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/company.php
+ *	\ingroup    company
+ *	\brief      Setup page to configure company/foundation
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
+
+$action=GETPOST('action');
+
+$langs->load("admin");
+$langs->load("companies");
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+if ( ($action == 'update' && empty($_POST["cancel"]))
+|| ($action == 'updateedit') )
+{
+    require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+    $new_country_id=$_POST["country_id"];
+    $new_country_code=getCountry($new_country_id,2);
+    $new_country_label=getCountry($new_country_id,0);
+
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_PAYS", $new_country_id.':'.$new_country_code.':'.$new_country_label,'chaine',0,'',$conf->entity);
+
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_VILLE",$_POST["ville"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_CP",$_POST["cp"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_DEPARTEMENT",$_POST["departement_id"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_MONNAIE",$_POST["currency"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TEL",$_POST["tel"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FAX",$_POST["fax"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_MAIL",$_POST["mail"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_WEB",$_POST["web"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOTE",$_POST["note"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_GENCOD",$_POST["barcode"],'chaine',0,'',$conf->entity);
+    if ($_FILES["logo"]["tmp_name"])
+    {
+        if (preg_match('/([^\\/:]+)$/i',$_FILES["logo"]["name"],$reg))
+        {
+            $original_file=$reg[1];
+
+            $isimage=image_format_supported($original_file);
+            if ($isimage >= 0)
+            {
+                dol_syslog("Move file ".$_FILES["logo"]["tmp_name"]." to ".$conf->mycompany->dir_output.'/logos/'.$original_file);
+                if (! is_dir($conf->mycompany->dir_output.'/logos/'))
+                {
+                    dol_mkdir($conf->mycompany->dir_output.'/logos/');
+                }
+                $result=dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->mycompany->dir_output.'/logos/'.$original_file,1,0,$_FILES['logo']['error']);
+                if ($result > 0)
+                {
+                    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file,'chaine',0,'',$conf->entity);
+
+                    // Create thumbs of logo (Note that PDF use original file and not thumbs)
+                    if ($isimage > 0)
+                    {
+                        // Create small thumbs for company (Ratio is near 16/9)
+                        // Used on logon for example
+                        $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
+                        if (preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg))
+                        {
+                            $imgThumbSmall = $reg[1];
+                            dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity);
+                        }
+                        else dol_syslog($imgThumbSmall);
+
+                        // Create mini thumbs for company (Ratio is near 16/9)
+                        // Used on menu or for setup page for example
+                        $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
+                        if (preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg))
+                        {
+                            $imgThumbMini = $reg[1];
+                            dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity);
+                        }
+                        else dol_syslog($imgThumbMini);
+                    }
+                    else dol_syslog($langs->trans("ErrorImageFormatNotSupported"),LOG_WARNING);
+                }
+                else if (preg_match('/^ErrorFileIsInfectedWithAVirus/',$result))
+                {
+                    $langs->load("errors");
+                    $tmparray=explode(':',$result);
+                    $message .= '<div class="error">'.$langs->trans('ErrorFileIsInfectedWithAVirus',$tmparray[1]).'</div>';
+                }
+                else
+                {
+                    $message .= '<div class="error">'.$langs->trans("ErrorFailedToSaveFile").'</div>';
+                }
+            }
+            else
+            {
+                $message .= '<div class="error">'.$langs->trans("ErrorOnlyPngJpgSupported").'</div>';
+            }
+        }
+    }
+
+    dolibarr_set_const($db, "MAIN_INFO_CAPITAL",$_POST["capital"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SOCIETE_FORME_JURIDIQUE",$_POST["forme_juridique_code"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SIREN",$_POST["siren"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_SIRET",$_POST["siret"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_TRAINER",$_POST["trainer"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_INFO_PROFID6",$_POST["MAIN_INFO_PROFID6"],'chaine',0,'',$conf->entity);
+
+    dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"],'chaine',0,'',$conf->entity);
+
+    dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"],'chaine',0,'',$conf->entity);
+
+    dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"],'chaine',0,'',$conf->entity);
+
+    // Local taxes
+    dolibarr_set_const($db, "FACTURE_LOCAL_TAX1_OPTION",$_POST["optionlocaltax1"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "FACTURE_LOCAL_TAX2_OPTION",$_POST["optionlocaltax2"],'chaine',0,'',$conf->entity);
+
+    if ($action != 'updateedit' && ! $message)
+    {
+        Header("Location: ".$_SERVER["PHP_SELF"]);
+        exit;
+    }
+}
+
+if ($action == 'addthumb')
+{
+    if (file_exists($conf->mycompany->dir_output.'/logos/'.$_GET["file"]))
+    {
+        $isimage=image_format_supported($_GET["file"]);
+
+        // Create thumbs of logo
+        if ($isimage > 0)
+        {
+            // Create small thumbs for company (Ratio is near 16/9)
+            // Used on logon for example
+            $imgThumbSmall = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthsmall, $maxheightsmall, '_small',$quality);
+            if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbSmall,$reg))
+            {
+                $imgThumbSmall = $reg[1];
+                dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall,'chaine',0,'',$conf->entity);
+            }
+            else dol_syslog($imgThumbSmall);
+
+            // Create mini thumbs for company (Ratio is near 16/9)
+            // Used on menu or for setup page for example
+            $imgThumbMini = vignette($conf->mycompany->dir_output.'/logos/'.$_GET["file"], $maxwidthmini, $maxheightmini, '_mini',$quality);
+            if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i',$imgThumbMini,$reg))
+            {
+                $imgThumbMini = $reg[1];
+                dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$imgThumbMini,'chaine',0,'',$conf->entity);
+            }
+            else dol_syslog($imgThumbMini);
+
+            Header("Location: ".$_SERVER["PHP_SELF"]);
+            exit;
+        }
+        else
+        {
+            $message .= '<div class="error">'.$langs->trans("ErrorImageFormatNotSupported").'</div>';
+            dol_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING);
+        }
+    }
+    else
+    {
+        $message .= '<div class="error">'.$langs->trans("ErrorFileDoesNotExists",$_GET["file"]).'</div>';
+        dol_syslog($langs->transnoentities("ErrorFileDoesNotExists",$_GET["file"]),LOG_WARNING);
+    }
+}
+
+if ($action == 'removelogo')
+{
+    require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+    $logofile=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
+    dol_delete_file($logofile);
+    dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO",$conf->entity);
+    $mysoc->logo='';
+
+    $logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
+    dol_delete_file($logosmallfile);
+    dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity);
+    $mysoc->logo_small='';
+
+    $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini;
+    dol_delete_file($logominifile);
+    dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity);
+    $mysoc->logo_mini='';
+}
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+$form=new Form($db);
+$formother=new FormOther($db);
+$formcompany=new FormCompany($db);
+
+$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
+
+// We define country_id, country_code and country
+if (! empty($conf->global->MAIN_INFO_SOCIETE_PAYS))
+{
+    $tmp=explode(':',$conf->global->MAIN_INFO_SOCIETE_PAYS);
+    $country_id=$tmp[0];
+    if (! empty($tmp[1]))   // If $conf->global->MAIN_INFO_SOCIETE_PAYS is "id:code:label"
+    {
+        $country_code=$tmp[1];
+        $country=$tmp[2];
+    }
+    else
+    {
+        $tmparray=getCountry($country_id,'all');
+        $country_code=$tmparray['code'];
+        $country=$tmparray['label'];
+    }
+}
+else
+{
+    $country_id=0;
+    $country_code='';
+    $country='';
+}
+
+
+print_fiche_titre($langs->trans("CompanyFoundation"),'','setup');
+
+print $langs->trans("CompanyFundationDesc")."<br>\n";
+print "<br>\n";
+
+if ($action == 'edit' || $action == 'updateedit')
+{
+    /**
+     * Edition des parametres
+     */
+    print "\n".'<script type="text/javascript" language="javascript">';
+    print '$(document).ready(function () {
+              $("#selectcountry_id").change(function() {
+                document.form_index.action.value="updateedit";
+                document.form_index.submit();
+              });
+          });';
+    print '</script>'."\n";
+
+    print '<form enctype="multipart/form-data" method="post" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+    $var=true;
+
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td width="35%">'.$langs->trans("CompanyInfo").'</td><td>'.$langs->trans("Value").'</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td class="fieldrequired">'.$langs->trans("CompanyName").'</td><td>';
+    print '<input name="nom" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM:$_POST["nom"]) . '"></td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyAddress").'</td><td>';
+    print '<textarea name="address" cols="80" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADRESSE?$conf->global->MAIN_INFO_SOCIETE_ADRESSE:$_POST["address"]) . '</textarea></td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyZip").'</td><td>';
+    print '<input name="cp" value="'. ($conf->global->MAIN_INFO_SOCIETE_CP?$conf->global->MAIN_INFO_SOCIETE_CP:$_POST["cp"]) . '" size="10"></td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyTown").'</td><td>';
+    print '<input name="ville" size="30" value="'. ($conf->global->MAIN_INFO_SOCIETE_VILLE?$conf->global->MAIN_INFO_SOCIETE_VILLE:$_POST["ville"]) . '"></td></tr>'."\n";
+
+    // Country
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td class="fieldrequired">'.$langs->trans("Country").'</td><td>';
+    $pays_selected=$country_id;
+    //if (empty($pays_selected)) $pays_selected=substr($langs->defaultlang,-2);    // Par defaut, pays de la localisation
+    print $form->select_country($pays_selected,'country_id');
+    if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
+    print '</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
+    $formcompany->select_departement($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT,$country_code,'departement_id');
+    print '</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCurrency").'</td><td>';
+    $form->select_currency($conf->currency,"currency");
+    print '</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("Tel").'</td><td>';
+    print '<input name="tel" value="'. $conf->global->MAIN_INFO_SOCIETE_TEL . '"></td></tr>';
+    print '</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("Fax").'</td><td>';
+    print '<input name="fax" value="'. $conf->global->MAIN_INFO_SOCIETE_FAX . '"></td></tr>';
+    print '</td></tr>'."\n";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("Mail").'</td><td>';
+    print '<input name="mail" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_MAIL . '"></td></tr>';
+    print '</td></tr>'."\n";
+
+    // Web
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("Web").'</td><td>';
+    print '<input name="web" size="60" value="'. $conf->global->MAIN_INFO_SOCIETE_WEB . '"></td></tr>';
+    print '</td></tr>'."\n";
+
+    // Barcode
+    if ($conf->barcode->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td>'.$langs->trans("Gencod").'</td><td>';
+        print '<input name="barcode" size="40" value="'. $conf->global->MAIN_INFO_SOCIETE_GENCOD . '"></td></tr>';
+        print '</td></tr>';
+    }
+
+    // Logo
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("Logo").' (png,jpg)</td><td>';
+    print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
+    print '<input type="file" class="flat" name="logo" size="50">';
+    print '</td><td valign="middle" align="right">';
+    if ($mysoc->logo_mini)
+    {
+        print '<a href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete")).'</a>';
+        if (file_exists($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
+        {
+            print ' &nbsp; ';
+            print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_mini).'">';
+        }
+    }
+    else
+    {
+        print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
+    }
+    print '</td></tr></table>';
+    print '</td></tr>';
+
+    // Note
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td valign="top">'.$langs->trans("Note").'</td><td>';
+    print '<textarea class="flat" name="note" cols="80" rows="'.ROWS_5.'">'.$conf->global->MAIN_INFO_SOCIETE_NOTE.'</textarea></td></tr>';
+    print '</td></tr>';
+
+    print '</table>';
+
+    print '<br>';
+
+    // Identifiants de la societe (propre au pays)
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
+    $var=true;
+
+    $langs->load("companies");
+
+    // Capital
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Capital").'</td><td>';
+    print '<input name="capital" size="20" value="' . $conf->global->MAIN_INFO_CAPITAL . '"></td></tr>';
+
+    // Forme juridique
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("JuridicalStatus").'</td><td>';
+    if ($country_code)
+    {
+        $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$country_code);
+    }
+    else
+    {
+        print $countrynotdefined;
+    }
+    print '</td></tr>';
+
+    // ProfID1
+    if ($langs->transcountry("ProfId1",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId1",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="siren" size="20" value="' . $conf->global->MAIN_INFO_SIREN . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId2
+    if ($langs->transcountry("ProfId2",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId2",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="siret" size="20" value="' . $conf->global->MAIN_INFO_SIRET . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId3
+    if ($langs->transcountry("ProfId3",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId3",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="ape" size="20" value="' . $conf->global->MAIN_INFO_APE . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId4
+    if ($langs->transcountry("ProfId4",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId4",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="rcs" size="20" value="' . $conf->global->MAIN_INFO_RCS . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId5
+    if ($langs->transcountry("ProfId5",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId5",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="trainer" size="20" value="' . $conf->global->MAIN_INFO_TRAINER . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId6
+    if ($langs->transcountry("ProfId6",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId6",$country_code).'</td><td>';
+        if ($country_code)
+        {
+            print '<input name="MAIN_INFO_PROFID6" size="20" value="' . $conf->global->MAIN_INFO_PROFID6 . '">';
+        }
+        else
+        {
+            print $countrynotdefined;
+        }
+        print '</td></tr>';
+    }
+
+    // TVA Intra
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("VATIntra").'</td><td>';
+    print '<input name="tva" size="20" value="' . $conf->global->MAIN_INFO_TVAINTRA . '">';
+    print '</td></tr>';
+
+    print '</table>';
+
+
+    /*
+     *  Debut d'annee fiscale
+     */
+    print '<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td>'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
+    print "</tr>\n";
+    $var=true;
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
+    print $formother->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '</td></tr>';
+
+    print "</table>";
+
+
+    /*
+     *  Options fiscale
+     */
+    print '<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td>'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
+    print '<td align="right">&nbsp;</td>';
+    print "</tr>\n";
+    $var=true;
+
+    $var=!$var;
+    print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"reel\"".($conf->global->FACTURE_TVAOPTION != "franchise"?" checked":"")."> ".$langs->trans("VATIsUsed")."</label></td>";
+    print '<td colspan="2">';
+    print "<table>";
+    print "<tr><td>".$langs->trans("VATIsUsedDesc")."</td></tr>";
+    print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n";
+    print "</table>";
+    print "</td></tr>\n";
+
+    $var=!$var;
+    print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optiontva\" value=\"franchise\"".($conf->global->FACTURE_TVAOPTION == "franchise"?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
+    print '<td colspan="2">';
+    print "<table>";
+    print "<tr><td>".$langs->trans("VATIsNotUsedDesc")."</td></tr>";
+    print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n";
+    print "</table>";
+    print "</td></tr>\n";
+
+    print "</table>";
+
+    /*
+     *  Local Taxes
+     */
+    if ($country_code=='ES')
+    {
+        // Local Tax 1
+        print '<br>';
+        print '<table class="noborder" width="100%">';
+        print '<tr class="liste_titre">';
+        print '<td>'.$langs->transcountry("LocalTax1Management",$country_code).'</td><td>'.$langs->trans("Description").'</td>';
+        print '<td align="right">&nbsp;</td>';
+        print "</tr>\n";
+        $var=true;
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1on\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION != "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax1\" value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax1IsNotUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax1IsNotUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+        print "</table>";
+
+        // Local Tax 2
+        print '<br>';
+        print '<table class="noborder" width="100%">';
+        print '<tr class="liste_titre">';
+        print '<td>'.$langs->transcountry("LocalTax2Management",$country_code).'</td><td>'.$langs->trans("Description").'</td>';
+        print '<td align="right">&nbsp;</td>';
+        print "</tr>\n";
+        $var=true;
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2on\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION != "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input type=\"radio\" name=\"optionlocaltax2\" value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax2IsNotUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+        print "</table>";
+    }
+
+
+    print '<br><center>';
+    print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
+    print ' &nbsp; &nbsp; ';
+    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+    print '</center>';
+    print '<br>';
+
+    print '</form>';
+}
+else
+{
+    /*
+     * Show parameters
+     */
+
+    dol_htmloutput_mesg($message);
+
+    // Actions buttons
+    //print '<div class="tabsAction">';
+    //print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+    //print '</div><br>';
+
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("CompanyInfo").'</td><td>'.$langs->trans("Value").'</td></tr>';
+    $var=true;
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyName").'</td><td>';
+    if (! empty($conf->global->MAIN_INFO_SOCIETE_NOM)) print $conf->global->MAIN_INFO_SOCIETE_NOM;
+    else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyName")).'</font>';
+    print '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyAddress").'</td><td>' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyZip").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_CP . '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyTown").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("CompanyCountry").'</td><td>';
+    if ($country_code)
+    {
+        $img=picto_from_langcode($country_code);
+        print $img?$img.' ':'';
+        print getCountry($country_code,1);
+    }
+    else print img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    print '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("State").'</td><td>';
+    if ($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT) print getState($conf->global->MAIN_INFO_SOCIETE_DEPARTEMENT);
+    else print '&nbsp;';
+    print '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("CompanyCurrency").'</td><td>';
+    print currency_name($conf->currency,1);
+    print ' ('.getCurrencySymbol($conf->currency).')';
+    print '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Tel").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_TEL,$mysoc->country_code) . '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Fax").'</td><td>' . dol_print_phone($conf->global->MAIN_INFO_SOCIETE_FAX,$mysoc->country_code) . '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Mail").'</td><td>' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL,0,0,0,80) . '</td></tr>';
+
+    // Web
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Web").'</td><td>' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB,'_blank',80) . '</td></tr>';
+
+    // Barcode
+    if ($conf->barcode->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Gencod").'</td><td>' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '</td></tr>';
+    }
+
+    // Logo
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Logo").'</td><td>';
+
+    print '<table width="100%" class="nocellnopadd"><tr class="nocellnopadd"><td valign="middle" class="nocellnopadd">';
+    print $mysoc->logo;
+    print '</td><td valign="center" align="right">';
+
+    // On propose la generation de la vignette si elle n'existe pas
+    if (!is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini) && preg_match('/(\.jpg|\.jpeg|\.png)$/i',$mysoc->logo))
+    {
+        print '<a href="'.$_SERVER["PHP_SELF"].'?action=addthumb&amp;file='.urlencode($mysoc->logo).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').'&nbsp;&nbsp;</a>';
+    }
+    else if ($mysoc->logo_mini && is_file($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini))
+    {
+        print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=companylogo&amp;file='.urlencode('/thumbs/'.$mysoc->logo_mini).'">';
+    }
+    else
+    {
+        print '<img height="30" src="'.DOL_URL_ROOT.'/theme/common/nophoto.jpg">';
+    }
+    print '</td></tr></table>';
+
+    print '</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%" valign="top">'.$langs->trans("Note").'</td><td>' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '</td></tr>';
+
+    print '</table>';
+
+
+    print '<br>';
+
+
+    // Identifiants de la societe (propre au pays)
+    print '<form name="formsoc" method="post">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("CompanyIds").'</td><td>'.$langs->trans("Value").'</td></tr>';
+    $var=true;
+
+    // Capital
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("Capital").'</td><td>';
+    print $conf->global->MAIN_INFO_CAPITAL . '</td></tr>';
+
+    // Forme juridique
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("JuridicalStatus").'</td><td>';
+    print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE);
+    print '</td></tr>';
+
+    // ProfId1
+    if ($langs->transcountry("ProfId1",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId1",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId1",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_SIREN;
+            if ($conf->global->MAIN_INFO_SIREN && $country_code == 'FR') print ' &nbsp; <a href="http://avis-situation-sirene.insee.fr/avisitu/jsp/avis.jsp" target="_blank">'.$langs->trans("Check").'</a>';
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId2
+    if ($langs->transcountry("ProfId2",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId2",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId2",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_SIRET;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId3
+    if ($langs->transcountry("ProfId3",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId3",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId3",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_APE;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId4
+    if ($langs->transcountry("ProfId4",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId4",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId4",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_RCS;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId5
+    if ($langs->transcountry("ProfId5",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId5",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId5",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_TRAINER;
+        }
+        print '</td></tr>';
+    }
+
+    // ProfId6
+    if ($langs->transcountry("ProfId6",$country_code) != '-')
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$langs->transcountry("ProfId6",$country_code).'</td><td>';
+        if ($langs->transcountry("ProfId6",$country_code) != '-')
+        {
+            print $conf->global->MAIN_INFO_PROFID6;
+        }
+        print '</td></tr>';
+    }
+
+    // TVA
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("VATIntra").'</td>';
+    print '<td>';
+    if ($conf->global->MAIN_INFO_TVAINTRA)
+    {
+        $s='';
+        $s.=$conf->global->MAIN_INFO_TVAINTRA;
+        $s.='<input type="hidden" name="tva_intra" size="12" maxlength="20" value="'.$conf->global->MAIN_INFO_TVAINTRA.'">';
+        if (empty($conf->global->MAIN_DISABLEVATCHECK))
+        {
+            $s.=' &nbsp; ';
+            if ($conf->use_javascript_ajax)
+            {
+                print "\n";
+                print '<script language="JavaScript" type="text/javascript">';
+                print "function CheckVAT(a) {\n";
+                print "newpopup('".DOL_URL_ROOT."/societe/checkvat/checkVatPopup.php?vatNumber='+a,'".dol_escape_js($langs->trans("VATIntraCheckableOnEUSite"))."',500,285);\n";
+                print "}\n";
+                print '</script>';
+                print "\n";
+                $s.='<a href="#" onClick="javascript: CheckVAT(document.formsoc.tva_intra.value);">'.$langs->trans("VATIntraCheck").'</a>';
+                $s = $form->textwithpicto($s,$langs->trans("VATIntraCheckDesc",$langs->trans("VATIntraCheck")),1);
+            }
+            else
+            {
+                $s.='<a href="'.$langs->transcountry("VATIntraCheckURL",$soc->id_pays).'" target="_blank">'.img_picto($langs->trans("VATIntraCheckableOnEUSite"),'help').'</a>';
+            }
+        }
+        print $s;
+    }
+    else
+    {
+        print '&nbsp;';
+    }
+    print '</td>';
+    print '</tr>';
+
+    print '</table>';
+    print '</form>';
+
+    /*
+     *  Debut d'annee fiscale
+     */
+    print '<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td>'.$langs->trans("FiscalYearInformation").'</td><td>'.$langs->trans("Value").'</td>';
+    print "</tr>\n";
+    $var=true;
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FiscalMonthStart").'</td><td>';
+    $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1;
+    print dol_print_date(dol_mktime(12,0,0,$monthstart,1,2000,1),'%B','gm') . '</td></tr>';
+
+    print "</table>";
+
+    /*
+     *  Options fiscale
+     */
+    print '<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td>'.$langs->trans("VATManagement").'</td><td>'.$langs->trans("Description").'</td>';
+    print '<td align="right">&nbsp;</td>';
+    print "</tr>\n";
+    $var=true;
+
+    $var=!$var;
+    print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" disabled value=\"reel\"".($conf->global->FACTURE_TVAOPTION != "franchise"?" checked":"")."> ".$langs->trans("VATIsUsed")."</label></td>";
+    print '<td colspan="2">';
+    print "<table>";
+    print "<tr><td>".$langs->trans("VATIsUsedDesc")."</td></tr>";
+    print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."</i></td></tr>\n";
+    print "</table>";
+    print "</td></tr>\n";
+
+    $var=!$var;
+    print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optiontva\" disabled value=\"franchise\"".($conf->global->FACTURE_TVAOPTION == "franchise"?" checked":"")."> ".$langs->trans("VATIsNotUsed")."</label></td>";
+    print '<td colspan="2">';
+    print "<table>";
+    print "<tr><td>".$langs->trans("VATIsNotUsedDesc")."</td></tr>";
+    print "<tr><td><i>".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."</i></td></tr>\n";
+    print "</table>";
+    print "</td></tr>\n";
+
+    print "</table>";
+
+
+    /*
+     *  Local Taxes
+     */
+    if ($country_code=='ES')
+    {
+        // Local Tax 1
+        print '<br>';
+        print '<table class="noborder" width="100%">';
+        print '<tr class="liste_titre">';
+        print '<td>'.$langs->transcountry("LocalTax1Management",$country_code).'</td><td>'.$langs->trans("Description").'</td>';
+        print '<td align="right">&nbsp;</td>';
+        print "</tr>\n";
+        $var=true;
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1on\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION != "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax1IsUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example",$country_code).': '.$langs->transcountry("LocalTax1IsUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax1\" disabled value=\"localtax1off\"".($conf->global->FACTURE_LOCAL_TAX1_OPTION == "localtax1off"?" checked":"")."> ".$langs->transcountry("LocalTax1IsNotUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax1IsNotUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example",$country_code).': '.$langs->transcountry("LocalTax1IsNotUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        print "</table>";
+
+        // Local Tax 2
+        print '<br>';
+        print '<table class="noborder" width="100%">';
+        print '<tr class="liste_titre">';
+        print '<td>'.$langs->transcountry("LocalTax2Management",$country_code).'</td><td>'.$langs->trans("Description").'</td>';
+        print '<td align="right">&nbsp;</td>';
+        print "</tr>\n";
+        $var=true;
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2on\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION != "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax2IsUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        $var=!$var;
+        print "<tr ".$bc[$var]."><td width=\"140\"><label><input ".$bc[$var]." type=\"radio\" name=\"optionlocaltax2\" disabled value=\"localtax2off\"".($conf->global->FACTURE_LOCAL_TAX2_OPTION == "localtax2off"?" checked":"")."> ".$langs->transcountry("LocalTax2IsNotUsed",$country_code)."</label></td>";
+        print '<td colspan="2">';
+        print "<table>";
+        print "<tr><td>".$langs->transcountry("LocalTax2IsNotUsedDesc",$country_code)."</td></tr>";
+        print "<tr><td><i>".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsNotUsedExample",$country_code)."</i></td></tr>\n";
+        print "</table>";
+        print "</td></tr>\n";
+
+        print "</table>";
+    }
+
+
+    // Actions buttons
+    print '<div class="tabsAction">';
+    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+    print '</div>';
+
+    print '<br>';
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 208 - 0
dolicloudimages/dolibarr/src/htdocs/admin/compta.php

@@ -0,0 +1,208 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent	    <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/compta.php
+ *	\ingroup    compta
+ *	\brief      Page to setup accountancy module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load('admin');
+$langs->load('compta');
+
+if (!$user->admin)
+accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+$compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES';
+
+if ($action == 'setcomptamode')
+{
+	$compta_mode = GETPOST('compta_mode','alpha');
+	
+	$res = dolibarr_set_const($db, 'COMPTA_MODE', $compta_mode,'chaine',0,'',$conf->entity);
+	
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+
+}
+
+if ($action == 'update' || $action == 'add')
+{
+	$constname = GETPOST('constname','alpha');
+	$constvalue = GETPOST('constvalue','alpha');
+	$consttype = GETPOST('consttype','alpha');
+	$constnote = GETPOST('constnote','alpha');
+	
+	$res = dolibarr_set_const($db, $constname, $constvalue, $consttype, 0, $constnote, $conf->entity);
+	
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*if ($action == 'delete')
+{
+	if (! dolibarr_del_const($db, $_GET['constname'],$conf->entity));
+	{
+		print $db->error();
+	}
+}*/
+
+/*
+ * Affichage page
+ */
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup');
+
+
+print '<br>';
+
+print '<table class="noborder" width="100%">';
+
+// Cas du parametre COMPTA_MODE
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setcomptamode">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
+print '<td align="right"><input class="button" type="submit" value="'.$langs->trans('Modify').'"></td>';
+print "</tr>\n";
+print '<tr '.$bc[false].'><td width="200"><input type="radio" name="compta_mode" value="RECETTES-DEPENSES"'.($compta_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
+print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
+// Write info on way to count VAT
+if ($conf->global->MAIN_MODULE_COMPTABILITE)
+{
+	//	print "<br>\n";
+	//	print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
+}
+else
+{
+	//	print "<br>\n";
+	//	print nl2br($langs->trans('OptionModeTrueInfoExpert'));
+}
+print "</td></tr>\n";
+print '<tr '.$bc[true].'><td width="200"><input type="radio" name="compta_mode" value="CREANCES-DETTES"'.($compta_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
+print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
+print '</form>';
+
+print "</table>\n";
+
+print "<br>\n";
+
+// Cas des autres parametres COMPTA_*
+$list=array('COMPTA_PRODUCT_BUY_ACCOUNT','COMPTA_PRODUCT_SOLD_ACCOUNT','COMPTA_SERVICE_BUY_ACCOUNT','COMPTA_SERVICE_SOLD_ACCOUNT',
+'COMPTA_VAT_ACCOUNT','COMPTA_ACCOUNT_CUSTOMER','COMPTA_ACCOUNT_SUPPLIER'
+);
+
+/*$sql = "SELECT rowid, name, value, type, note";
+$sql.= " FROM ".MAIN_DB_PREFIX."const";
+$sql.= " WHERE name LIKE 'COMPTA_%'";
+$sql.= " AND name NOT IN ('COMPTA_MODE')";
+$sql.= " AND entity = ".$conf->entity;
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+
+	while ($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$var=!$var;
+		$list[$obj->name]=$obj->value;
+		$i++;
+	}
+}*/
+
+$num=count($list);
+if ($num)
+{
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre">';
+	print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
+	print "</tr>\n";
+}
+
+foreach ($list as $key)
+{
+	$var=!$var;
+
+	print '<form action="compta.php" method="POST">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="update">';
+	print '<input type="hidden" name="consttype" value="string">';
+	print '<input type="hidden" name="constname" value="'.$key.'">';
+	
+	print '<tr '.$bc[$var].' class="value">';
+
+	// Param
+	$libelle = $langs->trans($key); 
+	print '<td>'.$libelle;
+	//print ' ('.$key.')';
+	print "</td>\n";
+
+	// Value
+	print '<td>';
+	print '<input type="text" size="20" name="constvalue" value="'.$conf->global->$key.'">';
+	print '</td><td>';
+	print '<input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"> &nbsp; ';
+	print "</td></tr>\n";
+	print '</form>';
+	
+	$i++;
+}
+
+if ($num)
+{
+	print "</table>\n";
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 164 - 0
dolicloudimages/dolibarr/src/htdocs/admin/confexped.php

@@ -0,0 +1,164 @@
+<?php
+/* Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006      Andre Cianfarani     <acianfa@free.fr>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/confexped.php
+ *		\ingroup    produit
+ *		\brief      Page to setup sending module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+$langs->load("sendings");
+$langs->load("deliveries");
+
+if (!$user->admin)
+  accessforbidden();
+
+$action=GETPOST('action','alpha');
+
+// Shipment note
+if ($action == 'activate_sending')
+{
+    dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
+    Header("Location: confexped.php");
+    exit;
+}
+else if ($action == 'disable_sending')
+{
+	dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
+    Header("Location: confexped.php");
+    exit;
+}
+// Delivery note
+else if ($action == 'activate_delivery')
+{
+    dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);    // We must also enable this
+    dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity);
+	Header("Location: confexped.php");
+	exit;
+}
+else if ($action == 'disable_delivery')
+{
+	dolibarr_del_const($db, "MAIN_SUBMODULE_LIVRAISON",$conf->entity);
+    Header("Location: confexped.php");
+    exit;
+}
+
+
+/*
+ * Affiche page
+ */
+$dir = DOL_DOCUMENT_ROOT."/core/modules/expedition/";
+$form=new Form($db);
+
+llxHeader("","");
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
+print '<br>';
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
+$head[$h][1] = $langs->trans("Setup");
+$hselected=$h;
+$h++;
+
+if ($conf->global->MAIN_SUBMODULE_EXPEDITION)
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
+	$head[$h][1] = $langs->trans("Sending");
+	$h++;
+}
+
+if ($conf->global->MAIN_SUBMODULE_LIVRAISON)
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
+	$head[$h][1] = $langs->trans("Receivings");
+	$h++;
+}
+
+dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
+
+/*
+ * Formulaire parametres divers
+ */
+
+$var=true;
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Feature").'</td>';
+print '<td align="center" width="20">&nbsp;</td>';
+print '<td align="center" width="100">'.$langs->trans("Status").'</td>';
+print '</tr>'."\n";
+
+// expedition activation/desactivation
+$var=!$var;
+print "<tr ".$bc[$var].">";
+print '<td>'.$langs->trans("SendingsAbility").'</td>';
+print '<td align="center" width="20">';
+print '</td>';
+print '<td align="center" width="100">';
+
+if($conf->global->MAIN_SUBMODULE_EXPEDITION == 0)
+{
+	print '<a href="confexped.php?action=activate_sending">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+}
+else if($conf->global->MAIN_SUBMODULE_EXPEDITION == 1)
+{
+	print '<a href="confexped.php?action=disable_sending">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
+}
+
+print "</td>";
+print '</tr>';
+
+// Bon de livraison activation/desactivation
+$var=!$var;
+print '<tr '.$bc[$var].'>';
+print '<td>'.$langs->trans("DeliveriesOrderAbility").'</td>';
+print '<td align="center" width="20">';
+print '</td>';
+print '<td align="center" width="100">';
+
+if($conf->global->MAIN_SUBMODULE_LIVRAISON == 0)
+{
+	print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+}
+else if($conf->global->MAIN_SUBMODULE_LIVRAISON == 1)
+{
+	print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
+}
+
+print "</td>";
+print '</tr>';
+print '</table>';
+
+print '</div>';
+
+print info_admin($langs->trans("NoNeedForDeliveryReceipts"));
+
+$db->close();
+
+llxFooter();
+?>

+ 283 - 0
dolicloudimages/dolibarr/src/htdocs/admin/const.php

@@ -0,0 +1,283 @@
+<?php
+/* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2012	Regis Houssin			<regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/const.php
+ *	\ingroup    setup
+ *	\brief      Admin page to define miscellaneous constants
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action');
+$debug = GETPOST('debug');
+
+$typeconst=array('yesno','texte','chaine');
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'add')
+{
+	$error=0;
+
+	if (empty($_POST["constname"]))
+	{
+		$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")).'</div>';
+		$error++;
+	}
+	if ($_POST["constvalue"]=='')
+	{
+		$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Value")).'</div>';
+		$error++;
+	}
+
+	if (! $error)
+	{
+		if (dolibarr_set_const($db, $_POST["constname"],$_POST["constvalue"],$typeconst[$_POST["consttype"]],1,isset($_POST["constnote"])?$_POST["constnote"]:'',$_POST["entity"]) < 0)
+		{
+			dol_print_error($db);
+		}
+	}
+}
+
+if (($_POST["const"] && isset($_POST["update"]) && $_POST["update"] == $langs->trans("Modify")))
+{
+	foreach($_POST["const"] as $const)
+	{
+		if ($const["check"])
+		{
+			if (dolibarr_set_const($db, $const["name"],$const["value"],$const["type"],1,$const["note"],$const["entity"]) < 0)
+			{
+				dol_print_error($db);
+			}
+		}
+	}
+}
+
+// Delete several lines at once
+if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("Delete"))
+{
+	foreach($_POST["const"] as $const)
+	{
+		if ($const["check"])	// Is checkbox checked
+		{
+			if (dolibarr_del_const($db, $const["rowid"], -1) < 0)
+			{
+				dol_print_error($db);
+			}
+		}
+	}
+}
+
+// Delete line from delete picto
+if ($action == 'delete')
+{
+	if (dolibarr_del_const($db, $_GET["rowid"], $_GET["entity"]) < 0)
+	{
+		dol_print_error($db);
+	}
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("OtherSetup"));
+
+// Add logic to show/hide buttons
+if ($conf->use_javascript_ajax)
+{
+?>
+<script type="text/javascript">
+jQuery(document).ready(function() {
+	jQuery("#updateconst").hide();
+	jQuery("#delconst").hide();
+	jQuery(".checkboxfordelete").click(function() {
+		jQuery("#delconst").show();
+	});
+	jQuery(".inputforupdate").keypress(function() {
+		var field_id = jQuery(this).attr("id");
+		var row_num = field_id.split("_");
+		jQuery("#updateconst").show();
+		jQuery("#check_" + row_num[1]).attr("checked",true);
+	});
+});
+</script>
+<?php
+}
+
+print_fiche_titre($langs->trans("OtherSetup"),'','setup');
+
+print $langs->trans("ConstDesc")."<br>\n";
+print "<br>\n";
+
+if ($mesg) print $mesg;
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print '<td>'.$langs->trans("Comment").'</td>';
+if (! empty($conf->multicompany->enabled) && !$user->entity) print '<td>'.$langs->trans("Entity").'</td>';
+print '<td align="center">'.$langs->trans("Action").'</td>';
+print "</tr>\n";
+
+
+$form = new Form($db);
+
+
+// Line to add new record
+$var=false;
+print "\n";
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="add">';
+
+print '<tr '.$bc[$var].'><td><input type="text" class="flat" size="24" name="constname" value=""></td>'."\n";
+print '<td>';
+print '<input type="text" class="flat" size="30" name="constvalue" value="">';
+print '</td><td>';
+print '<input type="text" class="flat" size="40" name="constnote" value="">';
+print '</td>';
+// Limit to superadmin
+if (! empty($conf->multicompany->enabled) && !$user->entity)
+{
+	print '<td>';
+	print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
+	print '</td>';
+}
+else
+{
+	print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
+}
+print '<td align="center">';
+print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="Button">';
+print "</td>\n";
+print '</tr>';
+
+print '</form>';
+print "\n";
+
+print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+// Show constants
+$sql = "SELECT";
+$sql.= " rowid";
+$sql.= ", ".$db->decrypt('name')." as name";
+$sql.= ", ".$db->decrypt('value')." as value";
+$sql.= ", type";
+$sql.= ", note";
+$sql.= ", entity";
+$sql.= " FROM ".MAIN_DB_PREFIX."const";
+$sql.= " WHERE entity IN (".$user->entity.",".$conf->entity.")";
+if (empty($user->entity) && $debug) {} // to force for superadmin
+elseif ($user->entity || empty($conf->multicompany->enabled)) $sql.= " AND visible = 1";
+$sql.= " ORDER BY entity, name ASC";
+
+dol_syslog("Const::listConstant sql=".$sql);
+$result = $db->query($sql);
+if ($result)
+{
+	$num = $db->num_rows($result);
+	$i = 0;
+	$var=false;
+
+	while ($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$var=!$var;
+
+		print "\n";
+		print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
+		print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->name.'">';
+		print '<input type="hidden" name="const['.$i.'][type]" value="'.$obj->type.'">';
+
+		print '<tr '.$bc[$var].'><td>'.$obj->name.'</td>'."\n";
+
+		// Value
+		print '<td>';
+		print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.htmlspecialchars($obj->value).'"';
+		print '>';
+		print '</td><td>';
+
+		// Note
+		print '<input type="text" id="note_'.$i.'"class="flat inputforupdate" size="40" name="const['.$i.'][note]" value="'.htmlspecialchars($obj->note,1).'"';
+		print '>';
+		print '</td>';
+
+		// Entity limit to superadmin
+		if (! empty($conf->multicompany->enabled) && !$user->entity)
+		{
+			print '<td>';
+			print '<input type="text" class="flat" size="1" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
+			print '</td>';
+		}
+		else
+		{
+			print '<input type="hidden" name="const['.$i.'][entity]" value="'.$obj->entity.'">';
+		}
+
+		print '<td align="center">';
+		if ($conf->use_javascript_ajax)
+		{
+			print '<input type="checkbox" class="flat checkboxfordelete" id="check_'.$i.'" name="const['.$i.'][check]" value="1">';
+			print ' &nbsp; ';
+		}
+		else
+		{
+			print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
+		}
+
+		print "</td></tr>\n";
+
+		print "\n";
+		$i++;
+	}
+}
+
+
+print '</table>';
+
+if ($conf->use_javascript_ajax)
+{
+	print '<br>';
+	print '<div id="updateconst" align="right">';
+	print '<input type="submit" name="update" class="button" value="'.$langs->trans("Modify").'">';
+	print '</div>';
+	print '<div id="delconst" align="right">';
+	print '<input type="submit" name="delete" class="button" value="'.$langs->trans("Delete").'">';
+	print '</div>';
+}
+
+print "</form>\n";
+
+llxFooter();
+
+$db->close();
+?>

+ 192 - 0
dolicloudimages/dolibarr/src/htdocs/admin/contract.php

@@ -0,0 +1,192 @@
+<?php
+/* Copyright (C) 2011-2012      Juanjo Menent	    <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/contract.php
+ *	\ingroup    contract
+ *	\brief      Setup page of module Contracts
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php');
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+
+if (empty($conf->global->CONTRACT_ADDON))
+{
+    $conf->global->CONTRACT_ADDON='mod_contract_serpis';
+}
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'updateMask')
+{
+    $maskconst = GETPOST('maskconstcontract','alpha');
+    $maskvalue =  GETPOST('maskcontract','alpha');
+    if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
+
+    if (! $res > 0) $error++;
+
+    if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'setmod')
+{
+    dolibarr_set_const($db, "CONTRACT_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+/*
+ // constants of magre model
+ if ($action == 'updateMatrice') dolibarr_set_const($db, "CONTRACT_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity);
+ if ($action == 'updatePrefix') dolibarr_set_const($db, "CONTRACT_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity);
+ if ($action == 'setOffset') dolibarr_set_const($db, "CONTRACT_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity);
+ if ($action == 'setNumRestart') dolibarr_set_const($db, "CONTRACT_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity);
+ */
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$dir=DOL_DOCUMENT_ROOT."/core/modules/contract/";
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup');
+
+print "<br>";
+
+print_titre($langs->trans("ContractsNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$dir = "../core/modules/contract/";
+$handle = opendir($dir);
+if (is_resource($handle))
+{
+    $var=true;
+
+    while (($file = readdir($handle))!==false)
+    {
+        if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+        {
+            $file = substr($file, 0, dol_strlen($file)-4);
+
+            require_once(DOL_DOCUMENT_ROOT ."/core/modules/contract/".$file.".php");
+
+            $module = new $file;
+
+            // 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())
+            {
+                $var=!$var;
+                print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
+                print '<td>';
+                print $module->info();
+                print '</td>';
+
+                // Show example of numbering module
+                print '<td nowrap="nowrap">';
+                $tmp=$module->getExample();
+                if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                else print $tmp;
+                print '</td>'."\n";
+
+                print '<td align="center">';
+                if ($conf->global->CONTRACT_ADDON == "$file")
+                {
+                    print img_picto($langs->trans("Activated"),'switch_on');
+                }
+                else
+                {
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
+                    print img_picto($langs->trans("Disabled"),'switch_off');
+                    print '</a>';
+                }
+                print '</td>';
+
+                $contract=new Contrat($db);
+                $contract->initAsSpecimen();
+
+                // Info
+                $htmltooltip='';
+                $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+                $facture->type=0;
+                $nextval=$module->getNextValue($mysoc,$contract);
+                if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+                {
+                    $htmltooltip.=''.$langs->trans("NextValue").': ';
+                    if ($nextval)
+                    {
+                        $htmltooltip.=$nextval.'<br>';
+                    }
+                    else
+                    {
+                        $htmltooltip.=$langs->trans($module->error).'<br>';
+                    }
+                }
+
+                print '<td align="center">';
+                print $form->textwithpicto('',$htmltooltip,1,0);
+                print '</td>';
+
+                print '</tr>';
+            }
+        }
+    }
+    closedir($handle);
+}
+
+print '</table><br>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 374 - 0
dolicloudimages/dolibarr/src/htdocs/admin/delais.php

@@ -0,0 +1,374 @@
+<?php
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005      Simon Tosser         <simon@kornog-computing.com>
+ * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/delais.php
+ *		\brief      Page to setup late delays
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+$langs->load("orders");
+$langs->load("propal");
+$langs->load("contracts");
+$langs->load("bills");
+$langs->load("banks");
+
+if (!$user->admin) accessforbidden();
+
+if ( (isset($_POST["action"]) && $_POST["action"] == 'update'))
+{
+    //Conversion des jours en secondes
+    if ($_POST["ActionsToDo"]) dolibarr_set_const($db, "MAIN_DELAY_ACTIONS_TODO",$_POST["ActionsToDo"],'chaine',0,'',$conf->entity);
+    if ($_POST["OrdersToProcess"]) dolibarr_set_const($db, "MAIN_DELAY_ORDERS_TO_PROCESS",$_POST["OrdersToProcess"],'chaine',0,'',$conf->entity);
+    if ($_POST["SuppliersOrdersToProcess"]) dolibarr_set_const($db, "MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS",$_POST["SuppliersOrdersToProcess"],'chaine',0,'',$conf->entity);
+    if ($_POST["PropalsToClose"]) dolibarr_set_const($db, "MAIN_DELAY_PROPALS_TO_CLOSE",$_POST["PropalsToClose"],'chaine',0,'',$conf->entity);
+    if ($_POST["PropalsToBill"]) dolibarr_set_const($db, "MAIN_DELAY_PROPALS_TO_BILL",$_POST["PropalsToBill"],'chaine',0,'',$conf->entity);
+    if ($_POST["BoardNotActivatedServices"]) dolibarr_set_const($db, "MAIN_DELAY_NOT_ACTIVATED_SERVICES",$_POST["BoardNotActivatedServices"],'chaine',0,'',$conf->entity);
+    if ($_POST["BoardRunningServices"]) dolibarr_set_const($db, "MAIN_DELAY_RUNNING_SERVICES",$_POST["BoardRunningServices"],'chaine',0,'',$conf->entity);
+    if ($_POST["CustomerBillsUnpaid"]) dolibarr_set_const($db, "MAIN_DELAY_CUSTOMER_BILLS_UNPAYED",$_POST["CustomerBillsUnpaid"],'chaine',0,'',$conf->entity);
+    if ($_POST["SupplierBillsToPay"]) dolibarr_set_const($db, "MAIN_DELAY_SUPPLIER_BILLS_TO_PAY",$_POST["SupplierBillsToPay"],'chaine',0,'',$conf->entity);
+    if ($_POST["TransactionsToConciliate"]) dolibarr_set_const($db, "MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE",$_POST["TransactionsToConciliate"],'chaine',0,'',$conf->entity);
+    if ($_POST["ChequesToDeposit"]) dolibarr_set_const($db, "MAIN_DELAY_CHEQUES_TO_DEPOSIT",$_POST["ChequesToDeposit"],'chaine',0,'',$conf->entity);
+    if ($_POST["Members"]) dolibarr_set_const($db, "MAIN_DELAY_MEMBERS",$_POST["Members"],'chaine',0,'',$conf->entity);
+
+    dolibarr_set_const($db, "MAIN_DISABLE_METEO",$_POST["MAIN_DISABLE_METEO"],'chaine',0,'',$conf->entity);
+}
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+print_fiche_titre($langs->trans("DelaysOfToleranceBeforeWarning"),'','setup');
+
+print $langs->transnoentities("DelaysOfToleranceDesc",img_warning());
+print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
+print "<br>\n";
+
+$form = new Form($db);
+$countrynotdefined='<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
+
+
+if ((isset($_GET["action"]) && $_GET["action"] == 'edit'))
+{
+    print '<form method="post" action="delais.php" name="form_index">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+    $var=true;
+
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
+
+    //
+    if ($conf->agenda->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','action').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceActionsToDo").'</td><td>';
+        print '<input size="5" name="ActionsToDo" value="'. ($conf->global->MAIN_DELAY_ACTIONS_TODO+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->commande->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','order').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceOrdersToProcess").'</td><td>';
+        print '<input size="5" name="OrdersToProcess" value="'. ($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->fournisseur->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','order').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceSuppliersOrdersToProcess").'</td><td>';
+        print '<input size="5" name="SuppliersOrdersToProcess" value="'. ($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->propal->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','propal').'</td>';
+        print '<td>'.$langs->trans("DelaysOfTolerancePropalsToClose").'</td><td>';
+        print '<input size="5" name="PropalsToClose" value="'. ($conf->global->MAIN_DELAY_PROPALS_TO_CLOSE+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->propal->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','propal').'</td>';
+        print '<td>'.$langs->trans("DelaysOfTolerancePropalsToBill").'</td><td>';
+        print '<input size="5" name="PropalsToBill" value="'. ($conf->global->MAIN_DELAY_PROPALS_TO_BILL+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->service->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','service').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceNotActivatedServices").'</td><td>';
+        print '<input size="5" name="BoardNotActivatedServices" value="'. ($conf->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->service->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','service').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceRunningServices").'</td><td>';
+        print '<input size="5" name="BoardRunningServices" value="'. ($conf->global->MAIN_DELAY_RUNNING_SERVICES +0). '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->facture->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','bill').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceCustomerBillsUnpaid").'</td><td>';
+        print '<input size="5" name="CustomerBillsUnpaid" value="'. ($conf->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->fournisseur->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','bill').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceSupplierBillsToPay").'</td><td>';
+        print '<input size="5" name="SupplierBillsToPay" value="'. ($conf->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->banque->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','account').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceTransactionsToConciliate").'</td><td>';
+        print '<input size="5" name="TransactionsToConciliate" value="'. ($conf->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','account').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceChequesToDeposit").'</td><td>';
+        print '<input size="5" name="ChequesToDeposit" value="'. ($conf->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT+0) . '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+    if ($conf->adherent->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','user').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceMembers").'</td><td>';
+        print '<input size="5" name="Members" value="'. ($conf->global->MAIN_DELAY_MEMBERS+0). '"> ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    print '</table>';
+
+    print '<br>';
+
+	// Show if meteo is enabled
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
+
+	$var=!$var;
+	print '<tr '.$bc[$var].'>';
+	print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' .$form->selectyesno('MAIN_DISABLE_METEO',$conf->global->MAIN_DISABLE_METEO,1) . '</td></tr>';
+
+	print '</table>';
+
+	print '<br>';
+
+    print '<br><center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
+    print '<br>';
+
+    print '</form>';
+}
+else
+{
+    /*
+     * Affichage des parametres
+     */
+
+	print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("DelaysOfToleranceBeforeWarning").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
+    $var=true;
+
+    $var=!$var;
+
+    if ($conf->agenda->enabled)
+    {
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','action').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceActionsToDo").'</td><td>' . ($conf->global->MAIN_DELAY_ACTIONS_TODO+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->commande->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','order').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceOrdersToProcess").'</td><td>' . ($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->fournisseur->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','order').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceSuppliersOrdersToProcess").'</td><td>' . ($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->propal->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','propal').'</td>';
+        print '<td>'.$langs->trans("DelaysOfTolerancePropalsToClose").'</td><td>' . ($conf->global->MAIN_DELAY_PROPALS_TO_CLOSE+0). ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->propal->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','propal').'</td>';
+        print '<td>'.$langs->trans("DelaysOfTolerancePropalsToBill").'</td><td>' . ($conf->global->MAIN_DELAY_PROPALS_TO_BILL+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->service->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','service').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceNotActivatedServices").'</td><td>' . ($conf->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->service->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','service').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceRunningServices").'</td><td>' . ($conf->global->MAIN_DELAY_RUNNING_SERVICES+0). ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->facture->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','bill').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceCustomerBillsUnpaid").'</td><td>' . ($conf->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->fournisseur->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','bill').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceSupplierBillsToPay").'</td><td>' . ($conf->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->banque->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','account').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceTransactionsToConciliate").'</td><td>' . ($conf->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE+0) . ' ' . $langs->trans("days") . '</td></tr>';
+
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','account').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceChequesToDeposit").'</td><td>' . ($conf->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    if ($conf->adherent->enabled)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'>';
+        print '<td width="20px">'.img_object('','user').'</td>';
+        print '<td>'.$langs->trans("DelaysOfToleranceMembers").'</td><td>' . ($conf->global->MAIN_DELAY_MEMBERS+0) . ' ' . $langs->trans("days") . '</td></tr>';
+    }
+
+    print '</table>';
+
+	print '<br>';
+
+	// Show if meteo is enabled
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="120px">'.$langs->trans("Value").'</td></tr>';
+
+	$var=!$var;
+	print '<tr '.$bc[$var].'>';
+	print '<td>'.$langs->trans("MAIN_DISABLE_METEO").'</td><td>' . yn($conf->global->MAIN_DISABLE_METEO) . '</td></tr>';
+
+	print '</table>';
+
+	print '<br>';
+
+    // Boutons d'action
+    print '<div class="tabsAction">';
+    print '<a class="butAction" href="delais.php?action=edit">'.$langs->trans("Modify").'</a>';
+    print '</div>';
+
+}
+
+print '<br>';
+
+
+// Show logo for weather
+print $langs->trans("DescWeather").'<br>';
+
+$offset=0;
+$cursor=10; // By default
+//if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET;
+//if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP;
+$level0=$offset;           if (! empty($conf->global->MAIN_METEO_LEVEL0)) $level0=$conf->global->MAIN_METEO_LEVEL0;
+$level1=$offset+1*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL1)) $level1=$conf->global->MAIN_METEO_LEVEL1;
+$level2=$offset+2*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL2)) $level2=$conf->global->MAIN_METEO_LEVEL2;
+$level3=$offset+3*$cursor; if (! empty($conf->global->MAIN_METEO_LEVEL3)) $level3=$conf->global->MAIN_METEO_LEVEL3;
+$text=''; $options='height="60px"';
+print '<table>';
+print '<tr>';
+print '<td>';
+print img_picto_common($text,'weather/weather-clear.png',$options);
+print '</td><td>= '.$level0.'</td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '<td>';
+print img_picto_common($text,'weather/weather-few-clouds.png',$options);
+print '</td><td>&lt;= '.$level1.'</td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '<td>';
+print img_picto_common($text,'weather/weather-clouds.png',$options);
+print '</td><td>&lt;= '.$level2.'</td>';
+print '</tr>';
+
+print '<tr><td>';
+print img_picto_common($text,'weather/weather-many-clouds.png',$options);
+print '</td><td>&lt;= '.$level3.'</td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '<td>';
+print img_picto_common($text,'weather/weather-storm.png',$options);
+print '</td><td>&gt; '.$level3.'</td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '<td> &nbsp; &nbsp; &nbsp; &nbsp; </td>';
+print '</tr>';
+
+print '</table>';
+
+$db->close();
+
+llxFooter();
+?>

+ 1080 - 0
dolicloudimages/dolibarr/src/htdocs/admin/dict.php

@@ -0,0 +1,1080 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2010-2011 Juanjo Menent        <jmenent@2byte.es>
+ * Copyright (C) 2011      Philippe Grand       <philippe.grand@atoo-net.com>
+ * Copyright (C) 2011      Remy Younes          <ryounes@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/dict.php
+ *		\ingroup    setup
+ *		\brief      Page to administer data tables
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("errors");
+$langs->load("admin");
+$langs->load("companies");
+
+$action=GETPOST('action','alpha')?GETPOST('action','alpha'):'view';
+$confirm=GETPOST('confirm','alpha');
+$id=GETPOST('id','int');
+$rowid=GETPOST('rowid','alpha');
+
+if (!$user->admin) accessforbidden();
+
+$acts[0] = "activate";
+$acts[1] = "disable";
+$actl[0] = img_picto($langs->trans("Disabled"),'switch_off');
+$actl[1] = img_picto($langs->trans("Activated"),'switch_on');
+
+$listoffset=GETPOST('listoffset');
+$listlimit=GETPOST('listlimit')>0?GETPOST('listlimit'):1000;
+$active = 1;
+
+$sortfield = GETPOST("sortfield",'alpha');
+$sortorder = GETPOST("sortorder",'alpha');
+$page = GETPOST("page",'int');
+if ($page == -1) { $page = 0 ; }
+$offset = $listlimit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
+include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
+$hookmanager=new HookManager($db);
+$hookmanager->initHooks(array('admin'));
+
+// Thi page is a generic page to edit dictionnaries
+// Put here delacaration of dictionnaries properties
+
+// Sort order to show dictionnary (0 is space). All other dictionnaries (added by modules) will be at end of this.
+$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,12,13,0,14,0,7,17,0,22,20,18,21,0,15);
+
+// Name of SQL tables of dictionnaries
+$tabname[1] = MAIN_DB_PREFIX."c_forme_juridique";
+$tabname[2] = MAIN_DB_PREFIX."c_departements";
+$tabname[3] = MAIN_DB_PREFIX."c_regions";
+$tabname[4] = MAIN_DB_PREFIX."c_pays";
+$tabname[5] = MAIN_DB_PREFIX."c_civilite";
+$tabname[6] = MAIN_DB_PREFIX."c_actioncomm";
+$tabname[7] = MAIN_DB_PREFIX."c_chargesociales";
+$tabname[8] = MAIN_DB_PREFIX."c_typent";
+$tabname[9] = MAIN_DB_PREFIX."c_currencies";
+$tabname[10]= MAIN_DB_PREFIX."c_tva";
+$tabname[11]= MAIN_DB_PREFIX."c_type_contact";
+$tabname[12]= MAIN_DB_PREFIX."c_payment_term";
+$tabname[13]= MAIN_DB_PREFIX."c_paiement";
+$tabname[14]= MAIN_DB_PREFIX."c_ecotaxe";
+$tabname[15]= MAIN_DB_PREFIX."c_paper_format";
+$tabname[16]= MAIN_DB_PREFIX."c_prospectlevel";
+$tabname[17]= MAIN_DB_PREFIX."c_type_fees";
+$tabname[18]= MAIN_DB_PREFIX."c_shipment_mode";
+$tabname[19]= MAIN_DB_PREFIX."c_effectif";
+$tabname[20]= MAIN_DB_PREFIX."c_input_method";
+$tabname[21]= MAIN_DB_PREFIX."c_availability";
+$tabname[22]= MAIN_DB_PREFIX."c_input_reason";
+
+// Dictionary labels
+$tablib[1] = "DictionnaryCompanyJuridicalType";
+$tablib[2] = "DictionnaryCanton";
+$tablib[3] = "DictionnaryRegion";
+$tablib[4] = "DictionnaryCountry";
+$tablib[5] = "DictionnaryCivility";
+$tablib[6] = "DictionnaryActions";
+$tablib[7] = "DictionnarySocialContributions";
+$tablib[8] = "DictionnaryCompanyType";
+$tablib[9] = "DictionnaryCurrency";
+$tablib[10]= "DictionnaryVAT";
+$tablib[11]= "DictionnaryTypeContact";
+$tablib[12]= "DictionnaryPaymentConditions";
+$tablib[13]= "DictionnaryPaymentModes";
+$tablib[14]= "DictionnaryEcotaxe";
+$tablib[15]= "DictionnaryPaperFormat";
+$tablib[16]= "DictionnaryProspectLevel";
+$tablib[17]= "DictionnaryFees";
+$tablib[18]= "DictionnarySendingMethods";
+$tablib[19]= "DictionnaryStaff";
+$tablib[20]= "DictionnaryOrderMethods";
+$tablib[21]= "DictionnaryAvailability";
+$tablib[22]= "DictionnarySource";
+
+// Requete pour extraction des donnees des dictionnaires
+$tabsql[1] = "SELECT f.rowid as rowid, f.code, f.libelle, p.code as pays_code, p.libelle as pays, f.active FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_pays as p WHERE f.fk_pays=p.rowid";
+$tabsql[2] = "SELECT d.rowid as rowid, d.code_departement as code, d.nom as libelle, d.fk_region as region_id, r.nom as region, p.code as pays_code, p.libelle as pays, d.active FROM ".MAIN_DB_PREFIX."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid and r.active=1 and p.active=1";
+$tabsql[3] = "SELECT r.rowid as rowid, code_region as code, nom as libelle, r.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, r.active FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p WHERE r.fk_pays=p.rowid and p.active=1";
+$tabsql[4] = "SELECT rowid   as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_pays";
+$tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.civilite AS libelle, c.active FROM ".MAIN_DB_PREFIX."c_civilite AS c";
+$tabsql[6] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
+$tabsql[7] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.deductible, p.code as pays_code, p.libelle as pays, a.fk_pays as pays_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_pays as p WHERE a.fk_pays=p.rowid and p.active=1";
+$tabsql[8] = "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_typent";
+$tabsql[9] = "SELECT code_iso as code, label as libelle, unicode, active FROM ".MAIN_DB_PREFIX."c_currencies";
+$tabsql[10]= "SELECT t.rowid, t.taux, t.localtax1, t.localtax2, p.libelle as pays, p.code as pays_code, t.fk_pays as pays_id, t.recuperableonly, t.note, t.active, t.accountancy_code FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
+$tabsql[11]= "SELECT t.rowid as rowid, element, source, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_contact AS t";
+$tabsql[12]= "SELECT c.rowid as rowid, code, sortorder, c.libelle, c.libelle_facture, nbjour, fdm, decalage, active FROM ".MAIN_DB_PREFIX.'c_payment_term AS c';
+$tabsql[13]= "SELECT id      as rowid, code, c.libelle, type, active FROM ".MAIN_DB_PREFIX."c_paiement AS c";
+$tabsql[14]= "SELECT e.rowid as rowid, e.code as code, e.libelle, e.price, e.organization, e.fk_pays as pays_id, p.code as pays_code, p.libelle as pays, e.active FROM ".MAIN_DB_PREFIX."c_ecotaxe AS e, ".MAIN_DB_PREFIX."c_pays as p WHERE e.fk_pays=p.rowid and p.active=1";
+$tabsql[15]= "SELECT rowid   as rowid, code, label as libelle, width, height, unit, active FROM ".MAIN_DB_PREFIX."c_paper_format";
+$tabsql[16]= "SELECT code, label as libelle, active FROM ".MAIN_DB_PREFIX."c_prospectlevel";
+$tabsql[17]= "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_type_fees";
+$tabsql[18]= "SELECT rowid   as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_shipment_mode";
+$tabsql[19]= "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_effectif";
+$tabsql[20]= "SELECT rowid   as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_input_method";
+$tabsql[21]= "SELECT c.rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_availability AS c";
+$tabsql[22]= "SELECT rowid   as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_input_reason";
+
+// Critere de tri du dictionnaire
+$tabsqlsort[1] ="pays ASC, code ASC";
+$tabsqlsort[2] ="pays ASC, code ASC";
+$tabsqlsort[3] ="pays ASC, code ASC";
+$tabsqlsort[4] ="code ASC";
+$tabsqlsort[5] ="libelle ASC";
+$tabsqlsort[6] ="a.type ASC, a.module, a.position, a.code ASC";
+$tabsqlsort[7] ="pays ASC, code ASC, a.libelle ASC";
+$tabsqlsort[8] ="libelle ASC";
+$tabsqlsort[9] ="libelle ASC";
+$tabsqlsort[10]="pays ASC, taux ASC, recuperableonly ASC, localtax1 ASC, localtax2 ASC";
+$tabsqlsort[11]="element ASC, source ASC, code ASC";
+$tabsqlsort[12]="sortorder ASC, code ASC";
+$tabsqlsort[13]="code ASC";
+$tabsqlsort[14]="pays ASC, e.organization ASC, code ASC";
+$tabsqlsort[15]="rowid ASC";
+$tabsqlsort[16]="sortorder ASC";
+$tabsqlsort[17]="code ASC";
+$tabsqlsort[18]="code ASC, libelle ASC";
+$tabsqlsort[19]="id ASC";
+$tabsqlsort[20]="code ASC, libelle ASC";
+$tabsqlsort[21]="code ASC, label ASC";
+$tabsqlsort[22]="code ASC, label ASC";
+
+// Nom des champs en resultat de select pour affichage du dictionnaire
+$tabfield[1] = "code,libelle,pays";
+$tabfield[2] = "code,libelle,region_id,region,pays";   // "code,libelle,region,pays_code-pays"
+$tabfield[3] = "code,libelle,pays_id,pays";
+$tabfield[4] = "code,libelle";
+$tabfield[5] = "code,libelle";
+$tabfield[6] = "code,libelle,type,position";
+$tabfield[7] = "code,libelle,pays_id,pays,deductible";
+$tabfield[8] = "code,libelle";
+$tabfield[9] = "code,libelle,unicode";
+$tabfield[10]= "pays_id,pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
+$tabfield[11]= "element,source,code,libelle";
+$tabfield[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
+$tabfield[13]= "code,libelle,type";
+$tabfield[14]= "code,libelle,price,organization,pays_id,pays";
+$tabfield[15]= "code,libelle,width,height,unit";
+$tabfield[16]= "code,libelle";
+$tabfield[17]= "code,libelle";
+$tabfield[18]= "code,libelle";
+$tabfield[19]= "code,libelle";
+$tabfield[20]= "code,libelle";
+$tabfield[21]= "code,label";
+$tabfield[22]= "code,label";
+
+// Nom des champs d'edition pour modification d'un enregistrement
+$tabfieldvalue[1] = "code,libelle,pays";
+$tabfieldvalue[2] = "code,libelle,region";   // "code,libelle,region"
+$tabfieldvalue[3] = "code,libelle,pays";
+$tabfieldvalue[4] = "code,libelle";
+$tabfieldvalue[5] = "code,libelle";
+$tabfieldvalue[6] = "code,libelle,type,position";
+$tabfieldvalue[7] = "code,libelle,pays,deductible";
+$tabfieldvalue[8] = "code,libelle";
+$tabfieldvalue[9] = "code,libelle,unicode";
+$tabfieldvalue[10]= "pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
+$tabfieldvalue[11]= "element,source,code,libelle";
+$tabfieldvalue[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
+$tabfieldvalue[13]= "code,libelle,type";
+$tabfieldvalue[14]= "code,libelle,price,organization,pays";
+$tabfieldvalue[15]= "code,libelle,width,height,unit";
+$tabfieldvalue[16]= "code,libelle";
+$tabfieldvalue[17]= "code,libelle";
+$tabfieldvalue[18]= "code,libelle";
+$tabfieldvalue[19]= "code,libelle";
+$tabfieldvalue[20]= "code,libelle";
+$tabfieldvalue[21]= "code,label";
+$tabfieldvalue[22]= "code,label";
+
+// Nom des champs dans la table pour insertion d'un enregistrement
+$tabfieldinsert[1] = "code,libelle,fk_pays";
+$tabfieldinsert[2] = "code_departement,nom,fk_region";
+$tabfieldinsert[3] = "code_region,nom,fk_pays";
+$tabfieldinsert[4] = "code,libelle";
+$tabfieldinsert[5] = "code,civilite";
+$tabfieldinsert[6] = "code,libelle,type,position";
+$tabfieldinsert[7] = "code,libelle,fk_pays,deductible";
+$tabfieldinsert[8] = "code,libelle";
+$tabfieldinsert[9] = "code_iso,label,unicode";
+$tabfieldinsert[10]= "fk_pays,taux,recuperableonly,localtax1,localtax2,accountancy_code,note";
+$tabfieldinsert[11]= "element,source,code,libelle";
+$tabfieldinsert[12]= "code,libelle,libelle_facture,nbjour,fdm,decalage";
+$tabfieldinsert[13]= "code,libelle,type";
+$tabfieldinsert[14]= "code,libelle,price,organization,fk_pays";
+$tabfieldinsert[15]= "code,label,width,height,unit";
+$tabfieldinsert[16]= "code,label";
+$tabfieldinsert[17]= "code,libelle";
+$tabfieldinsert[18]= "code,libelle";
+$tabfieldinsert[19]= "code,libelle";
+$tabfieldinsert[20]= "code,libelle";
+$tabfieldinsert[21]= "code,label";
+$tabfieldinsert[22]= "code,label";
+
+// Nom du rowid si le champ n'est pas de type autoincrement
+// Example: "" if id field is "rowid" and has autoincrement on
+//          "nameoffield" if id field is not "rowid" or has not autoincrement on
+$tabrowid[1] = "";
+$tabrowid[2] = "";
+$tabrowid[3] = "";
+$tabrowid[4] = "rowid";
+$tabrowid[5] = "rowid";
+$tabrowid[6] = "id";
+$tabrowid[7] = "id";
+$tabrowid[8] = "id";
+$tabrowid[9] = "code_iso";
+$tabrowid[10]= "";
+$tabrowid[11]= "rowid";
+$tabrowid[12]= "rowid";
+$tabrowid[13]= "id";
+$tabrowid[14]= "";
+$tabrowid[15]= "";
+$tabrowid[16]= "code";
+$tabrowid[17]= "id";
+$tabrowid[18]= "rowid";
+$tabrowid[19]= "id";
+$tabrowid[20]= "";
+$tabrowid[21]= "rowid";
+$tabrowid[22]= "rowid";
+
+// Condition to show dictionnary in setup page
+$tabcond[1] = true;
+$tabcond[2] = true;
+$tabcond[3] = true;
+$tabcond[4] = true;
+$tabcond[5] = $conf->societe->enabled||$conf->adherent->enabled;
+$tabcond[6] = $conf->agenda->enabled;
+$tabcond[7] = $conf->tax->enabled;
+$tabcond[8] = $conf->societe->enabled;
+$tabcond[9] = true;
+$tabcond[10]= true;
+$tabcond[11]= true;
+$tabcond[12]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
+$tabcond[13]= $conf->commande->enabled||$conf->propal->enabled||$conf->facture->enabled||$conf->fournisseur->enabled;
+$tabcond[14]= $conf->product->enabled&&$conf->ecotax->enabled;
+$tabcond[15]= true;
+$tabcond[16]= $conf->societe->enabled && empty($conf->global->SOCIETE_DISABLE_PROSPECTS);
+$tabcond[17]= $conf->deplacement->enabled;
+$tabcond[18]= $conf->expedition->enabled;
+$tabcond[19]= $conf->societe->enabled;
+$tabcond[20]= $conf->fournisseur->enabled;
+$tabcond[21]= $conf->propal->enabled;
+$tabcond[22]= $conf->commande->enabled||$conf->propal->enabled;
+
+
+complete_dictionnary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond);
+
+// Define elementList and sourceList (used for dictionnary "type of contacts")
+$elementList = array();
+$sourceList=array();
+if ($id == 11)
+{
+    $langs->load("orders");
+    $langs->load("contracts");
+    $langs->load("projects");
+    $langs->load("propal");
+    $langs->load("bills");
+    $langs->load("interventions");
+    $elementList = array("commande"=>$langs->trans("Order"),
+    "order_supplier"=>$langs->trans("SupplierOrder"),
+    "contrat"=>$langs->trans("Contract"),
+    "project"=>$langs->trans("Project"),
+    "project_task"=>$langs->trans("Task"),
+    "propal"=>$langs->trans("Propal"),
+    "facture"=>$langs->trans("Bill"),
+    "facture_fourn"=>$langs->trans("SupplierBill"),
+    "fichinter"=>$langs->trans("InterventionCard"));
+    if ($conf->global->MAIN_SUPPORT_CONTACT_TYPE_FOR_THIRDPARTIES) $elementList["societe"]=$langs->trans("ThirdParty");
+    $sourceList = array("internal"=>$langs->trans("Internal"),
+    "external"=>$langs->trans("External"));
+}
+
+$msg='';
+
+
+/*
+ * Actions ajout ou modification d'une entree dans un dictionnaire de donnee
+ */
+if ($_POST["actionadd"] || $_POST["actionmodify"])
+{
+    $listfield=explode(',',$tabfield[$id]);
+    $listfieldinsert=explode(',',$tabfieldinsert[$id]);
+    $listfieldmodify=explode(',',$tabfieldinsert[$id]);
+    $listfieldvalue=explode(',',$tabfieldvalue[$id]);
+
+    // Check that all fields are filled
+    $ok=1;
+    foreach ($listfield as $f => $value)
+    {
+        if ($value == 'pays')
+        {
+            if (in_array('region_id',$listfield)) { continue; }		// For region page, we do not require the country input
+        }
+        if ((! isset($_POST[$value]) || $_POST[$value]=='')
+        && $listfield[$f] != 'decalage'  // Fields that are not mandatory
+        && $listfield[$f] != 'module'   // Fields that are not mandatory
+        && $listfield[$f] != 'accountancy_code')   // Fields that are not mandatory
+        {
+            $ok=0;
+            $fieldnamekey=$listfield[$f];
+            // We take translate key of field
+            if ($fieldnamekey == 'libelle')  $fieldnamekey='Label';
+            if ($fieldnamekey == 'nbjour')   $fieldnamekey='NbOfDays';
+            if ($fieldnamekey == 'decalage') $fieldnamekey='Offset';
+            if ($fieldnamekey == 'module')   $fieldnamekey='Module';
+            $msg.=$langs->trans("ErrorFieldRequired",$langs->transnoentities($fieldnamekey)).'<br>';
+        }
+    }
+    // Autres verif
+    if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && isset($_POST["type"]) && $_POST["type"]=='system') {
+        $ok=0;
+        $msg.="Value 'system' for type is reserved. You can use 'user' as value to add your own record.<br>";
+    }
+    if (isset($_POST["code"]) && $_POST["code"]=='0') {
+        $ok=0;
+        $msg.="Code can't contains value 0<br>";
+    }
+    if (isset($_POST["pays"]) && $_POST["pays"]=='0') {
+        $ok=0;
+        $msg.=$langs->trans("ErrorFieldRequired",$langs->trans("Country")).'<br>';
+    }
+
+    // Si verif ok et action add, on ajoute la ligne
+    if ($ok && $_POST["actionadd"])
+    {
+        if ($tabrowid[$id])
+        {
+            // Recupere id libre pour insertion
+            $newid=0;
+            $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
+            $result = $db->query($sql);
+            if ($result)
+            {
+                $obj = $db->fetch_object($result);
+                $newid=($obj->newid + 1);
+
+            } else {
+                dol_print_error($db);
+            }
+        }
+
+        // Add new entry
+        $sql = "INSERT INTO ".$tabname[$id]." (";
+        // List of fields
+        if ($tabrowid[$id] &&
+        ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $tabrowid[$id].",";
+        $sql.= $tabfieldinsert[$id];
+        $sql.=",active)";
+        $sql.= " VALUES(";
+        // List of values
+        if ($tabrowid[$id] &&
+        ! in_array($tabrowid[$id],$listfieldinsert)) $sql.= $newid.",";
+        $i=0;
+        foreach ($listfieldinsert as $f => $value)
+        {
+            if ($value == 'price' || preg_match('/^amount/i',$value)) {
+            	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+            }
+            else if ($value == 'entity') {
+            	$_POST[$listfieldvalue[$i]] = $conf->entity;
+            }
+            if ($i) $sql.=",";
+            if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
+            else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+            $i++;
+        }
+        $sql.=",1)";
+
+        dol_syslog("actionadd sql=".$sql);
+        $result = $db->query($sql);
+        if ($result)	// Add is ok
+        {
+            $oldid=$id;
+            $_POST=array('id'=>$oldid);	// Clean $_POST array, we keep only
+            $_GET["id"]=$_POST["id"];   // Force affichage dictionnaire en cours d'edition
+        }
+        else
+        {
+            if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
+                $msg=$langs->trans("ErrorRecordAlreadyExists").'<br>';
+            }
+            else {
+                dol_print_error($db);
+            }
+        }
+    }
+
+    // Si verif ok et action modify, on modifie la ligne
+    if ($ok && $_POST["actionmodify"])
+    {
+        if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+        else { $rowidcol="rowid"; }
+
+        // Modify entry
+        $sql = "UPDATE ".$tabname[$id]." SET ";
+        // Modifie valeur des champs
+        if ($tabrowid[$id] && !in_array($tabrowid[$id],$listfieldmodify))
+        {
+            $sql.= $tabrowid[$id]."=";
+            $sql.= "'".$db->escape($rowid)."', ";
+        }
+        $i = 0;
+        foreach ($listfieldmodify as $field)
+        {
+            if ($field == 'price' || preg_match('/^amount/i',$field)) {
+            	$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]],'MU');
+            }
+            else if ($field == 'entity') {
+            	$_POST[$listfieldvalue[$i]] = $conf->entity;
+            }
+            if ($i) $sql.=",";
+            $sql.= $field."=";
+            if ($_POST[$listfieldvalue[$i]] == '') $sql.="null";
+            else $sql.="'".$db->escape($_POST[$listfieldvalue[$i]])."'";
+            $i++;
+        }
+        $sql.= " WHERE ".$rowidcol." = '".$rowid."'";
+
+        dol_syslog("actionmodify sql=".$sql);
+        //print $sql;
+        $resql = $db->query($sql);
+        if (! $resql)
+        {
+            $msg=$db->error();
+        }
+    }
+
+    if ($msg) $msg='<div class="error">'.$msg.'</div>';
+    $_GET["id"]=$_POST["id"];       // Force affichage dictionnaire en cours d'edition
+}
+
+if ($_POST["actioncancel"])
+{
+    $_GET["id"]=$_POST["id"];       // Force affichage dictionnaire en cours d'edition
+}
+
+if ($action == 'confirm_delete' && $confirm == 'yes')       // delete
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    $sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol."='".$rowid."'";
+
+    dol_syslog("delete sql=".$sql);
+    $result = $db->query($sql);
+    if (! $result)
+    {
+        if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
+        {
+            $msg='<div class="error">'.$langs->trans("ErrorRecordIsUsedByChild").'</div>';
+        }
+        else
+        {
+            dol_print_error($db);
+        }
+    }
+}
+
+if ($action == $acts[0])       // activate
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+if ($action == $acts[1])       // disable
+{
+    if ($tabrowid[$id]) { $rowidcol=$tabrowid[$id]; }
+    else { $rowidcol="rowid"; }
+
+    if ($rowid) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."='".$rowid."'";
+    }
+    elseif ($_GET["code"]) {
+        $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE code='".$_GET["code"]."'";
+    }
+
+    $result = $db->query($sql);
+    if (!$result)
+    {
+        dol_print_error($db);
+    }
+}
+
+
+/*
+ * View
+ */
+
+$form = new Form($db);
+$formadmin=new FormAdmin($db);
+
+llxHeader();
+
+$titre=$langs->trans("DictionnarySetup");
+$linkback='';
+if ($id)
+{
+    $titre.=' - '.$langs->trans($tablib[$id]);
+    $linkback='<a href="'.DOL_URL_ROOT.'/admin/dict.php">'.$langs->trans("BackToDictionnaryList").'</a>';
+}
+print_fiche_titre($titre,$linkback,'setup');
+
+if (empty($id))
+{
+    print $langs->trans("DictionnaryDesc");
+    print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
+}
+print "<br>\n";
+
+
+/*
+ * Confirmation de la suppression de la ligne
+ */
+if ($action == 'delete')
+{
+    $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$_GET["code"].'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete','',0,1);
+    if ($ret == 'html') print '<br>';
+}
+
+/*
+ * Show a dictionnary
+ */
+if ($id)
+{
+    dol_htmloutput_mesg($msg);
+
+    // Complete requete recherche valeurs avec critere de tri
+    $sql=$tabsql[$id];
+    if ($_GET["sortfield"])
+    {
+        // If sort order is "pays", we use pays_code instead
+        if ($_GET["sortfield"] == 'pays') $_GET["sortfield"]='pays_code';
+        $sql.= " ORDER BY ".$_GET["sortfield"];
+        if ($_GET["sortorder"])
+        {
+            $sql.=" ".strtoupper($_GET["sortorder"]);
+        }
+        $sql.=", ";
+        // Remove from default sort order the choosed order
+        $tabsqlsort[$id]=preg_replace('/'.$_GET["sortfield"].' '.$_GET["sortorder"].',/i','',$tabsqlsort[$id]);
+        $tabsqlsort[$id]=preg_replace('/'.$_GET["sortfield"].',/i','',$tabsqlsort[$id]);
+    }
+    else {
+        $sql.=" ORDER BY ";
+    }
+    $sql.=$tabsqlsort[$id];
+    $sql.=$db->plimit($listlimit+1,$offset);
+    //print $sql;
+
+    $fieldlist=explode(',',$tabfield[$id]);
+
+    print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="noborder" width="100%">';
+
+    // Form to add a new line
+    if ($tabname[$id])
+    {
+        $alabelisused=0;
+        $var=false;
+
+        $fieldlist=explode(',',$tabfield[$id]);
+        //        print '<table class="noborder" width="100%">';
+
+        // Line for title
+        print '<tr class="liste_titre">';
+        foreach ($fieldlist as $field => $value)
+        {
+            // Determine le nom du champ par rapport aux noms possibles
+            // dans les dictionnaires de donnees
+            $valuetoshow=ucfirst($fieldlist[$field]);   // Par defaut
+            $valuetoshow=$langs->trans($valuetoshow);   // try to translate
+            if ($fieldlist[$field]=='source')          { $valuetoshow=$langs->trans("Contact"); }
+            if ($fieldlist[$field]=='price')           { $valuetoshow=$langs->trans("PriceUHT"); }
+            if ($fieldlist[$field]=='taux')            { $valuetoshow=$langs->trans("Rate"); }
+            if ($fieldlist[$field]=='organization')    { $valuetoshow=$langs->trans("Organization"); }
+            if ($fieldlist[$field]=='lang')            { $valuetoshow=$langs->trans("Language"); }
+            if ($fieldlist[$field]=='type')            { $valuetoshow=$langs->trans("Type"); }
+            if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
+            if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*"; }
+            if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
+            if ($fieldlist[$field]=='pays')            {
+                if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; }		// For region page, we do not show the country input
+                $valuetoshow=$langs->trans("Country");
+            }
+            if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
+            if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
+            if ($fieldlist[$field]=='fdm')             { $valuetoshow=$langs->trans("AtEndOfMonth"); }
+            if ($fieldlist[$field]=='decalage')        { $valuetoshow=$langs->trans("Offset"); }
+            if ($fieldlist[$field]=='width')           { $valuetoshow=$langs->trans("Width"); }
+            if ($fieldlist[$field]=='height')          { $valuetoshow=$langs->trans("Height"); }
+            if ($fieldlist[$field]=='unit')            { $valuetoshow=$langs->trans("MeasuringUnit"); }
+            if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $valuetoshow=''; }
+            if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
+            if ($valuetoshow != '')
+            {
+            	print '<td>';
+            	print $valuetoshow;
+                print '</td>';
+             }
+             if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
+        }
+        print '<td colspan="3">';
+        print '<input type="hidden" name="id" value="'.$id.'">';
+        print '&nbsp;</td>';
+        print '</tr>';
+
+        // Line to type new values
+        print "<tr ".$bc[$var].">";
+
+        $obj='';
+        // If data was already input, we define them in obj to populate input fields.
+        if ($_POST["actionadd"])
+        {
+            foreach ($fieldlist as $key=>$val)
+            {
+                if (! empty($_POST[$val])) $obj->$val=$_POST[$val];
+
+            }
+        }
+        
+        $tmpaction = 'create';
+        $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$_GET["id"]]);
+        $reshook=$hookmanager->executeHooks('createDictionaryFieldlist',$parameters, $obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+        $error=$hookmanager->error; $errors=$hookmanager->errors;
+
+        if (empty($reshook)) fieldList($fieldlist,$obj);
+
+        print '<td colspan="3" align="right"><input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'"></td>';
+        print "</tr>";
+
+        if ($alabelisused)  // Si un des champs est un libelle
+        {
+            print '<tr><td colspan="'.(count($fieldlist)+2).'">* '.$langs->trans("LabelUsedByDefault").'.</td></tr>';
+        }
+        print '<tr><td colspan="'.(count($fieldlist)+2).'">&nbsp;</td></tr>';
+    }
+
+
+    // List of available values in database
+    dol_syslog("htdocs/admin/dict sql=".$sql, LOG_DEBUG);
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $num = $db->num_rows($resql);
+        $i = 0;
+        $var=true;
+        if ($num)
+        {
+            // There is several pages
+            if ($num > $listlimit)
+            {
+                print '<tr class="none"><td align="right" colspan="'.(3+count($fieldlist)).'">';
+                print_fleche_navigation($page,$_SERVER["PHP_SELF"],'&id='.$id,($num > $listlimit),$langs->trans("Page").' '.($page+1));
+                print '</td></tr>';
+            }
+
+            // Title of lines
+            print '<tr class="liste_titre">';
+            foreach ($fieldlist as $field => $value)
+            {
+                // Determine le nom du champ par rapport aux noms possibles
+                // dans les dictionnaires de donnees
+                $showfield=1;							  	// Par defaut
+                $valuetoshow=ucfirst($fieldlist[$field]);   // Par defaut
+                $valuetoshow=$langs->trans($valuetoshow);   // try to translate
+                if ($fieldlist[$field]=='source')          { $valuetoshow=$langs->trans("Contact"); }
+                if ($fieldlist[$field]=='price')           { $valuetoshow=$langs->trans("PriceUHT"); }
+                if ($fieldlist[$field]=='taux')            { $valuetoshow=$langs->trans("Rate"); }
+                if ($fieldlist[$field]=='organization')    { $valuetoshow=$langs->trans("Organization"); }
+                if ($fieldlist[$field]=='lang')            { $valuetoshow=$langs->trans("Language"); }
+                if ($fieldlist[$field]=='type')            { $valuetoshow=$langs->trans("Type"); }
+                if ($fieldlist[$field]=='code')            { $valuetoshow=$langs->trans("Code"); }
+                if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') { $valuetoshow=$langs->trans("Label")."*";  }
+                if ($fieldlist[$field]=='libelle_facture') { $valuetoshow=$langs->trans("LabelOnDocuments")."*"; }
+                if ($fieldlist[$field]=='pays')            { $valuetoshow=$langs->trans("Country"); }
+                if ($fieldlist[$field]=='recuperableonly') { $valuetoshow=MAIN_LABEL_MENTION_NPR; }
+                if ($fieldlist[$field]=='nbjour')          { $valuetoshow=$langs->trans("NbOfDays"); }
+                if ($fieldlist[$field]=='fdm')             { $valuetoshow=$langs->trans("AtEndOfMonth"); }
+                if ($fieldlist[$field]=='decalage')        { $valuetoshow=$langs->trans("Offset"); }
+                if ($fieldlist[$field]=='width')           { $valuetoshow=$langs->trans("Width"); }
+                if ($fieldlist[$field]=='height')          { $valuetoshow=$langs->trans("Height"); }
+                if ($fieldlist[$field]=='unit')            { $valuetoshow=$langs->trans("MeasuringUnit"); }
+                if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') { $showfield=0; }
+                if ($fieldlist[$field]=='accountancy_code'){ $valuetoshow=$langs->trans("AccountancyCode"); }
+                // Affiche nom du champ
+                if ($showfield)
+                {
+                    print_liste_field_titre($valuetoshow,"dict.php",$fieldlist[$field],($page?'page='.$page.'&':'').'&id='.$id,"","",$sortfield,$sortorder);
+                }
+            }
+            print_liste_field_titre($langs->trans("Status"),"dict.php","active",($page?'page='.$page.'&':'').'&id='.$id,"",'align="center"',$sortfield,$sortorder);
+            print '<td colspan="2"  class="liste_titre">&nbsp;</td>';
+            print '</tr>';
+
+            // Lines with values
+            while ($i < $num)
+            {
+                $obj = $db->fetch_object($resql);
+                $var=!$var;
+                //print_r($obj);
+                print "<tr ".$bc[$var].">";
+
+                if ($action == 'edit' && ($rowid == ($obj->rowid?$obj->rowid:$obj->code)))
+                {
+                    print '<form action="dict.php" method="post">';
+                    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+                    print '<input type="hidden" name="id" value="'.$id.'">';
+                    print '<input type="hidden" name="page" value="'.$page.'">';
+                    print '<input type="hidden" name="rowid" value="'.$rowid.'">';
+                    
+                    $tmpaction='edit';
+                    $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
+                    $reshook=$hookmanager->executeHooks('editDictionaryFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+                    $error=$hookmanager->error; $errors=$hookmanager->errors;
+                    
+                    if (empty($reshook)) fieldList($fieldlist,$obj,$tabname[$id]);
+                    
+                    print '<td colspan="3" align="right"><a name="'.($obj->rowid?$obj->rowid:$obj->code).'">&nbsp;</a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
+                    print '&nbsp;<input type="submit" class="button" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
+                }
+                else
+                {
+                    $tmpaction = 'view';
+                    $parameters=array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
+                    $reshook=$hookmanager->executeHooks('viewDictionaryFieldlist',$parameters,$obj, $tmpaction);    // Note that $action and $object may have been modified by some hooks
+                    
+                    $error=$hookmanager->error; $errors=$hookmanager->errors;
+
+                    if (empty($reshook))
+                    {
+                        foreach ($fieldlist as $field => $value)
+                        {
+                            $showfield=1;
+                            $valuetoshow=$obj->$fieldlist[$field];
+                            if ($valuetoshow=='all') {
+                                $valuetoshow=$langs->trans('All');
+                            }
+                            else if ($fieldlist[$field]=='pays') {
+                                if (empty($obj->pays_code))
+                                {
+                                    $valuetoshow='-';
+                                }
+                                else
+                                {
+                                    $key=$langs->trans("Country".strtoupper($obj->pays_code));
+                                    $valuetoshow=($key != "Country".strtoupper($obj->pays_code))?$obj->pays_code." - ".$key:$obj->pays;
+                                }
+                            }
+                            else if ($fieldlist[$field]=='recuperableonly' || $fieldlist[$field]=='fdm') {
+                                $valuetoshow=yn($valuetoshow);
+                            }
+                            else if ($fieldlist[$field]=='price' || preg_match('/^amount/i',$fieldlist[$field])) {
+                                $valuetoshow=price($valuetoshow);
+                            }
+                            else if ($fieldlist[$field]=='libelle_facture') {
+                                $langs->load("bills");
+                                $key=$langs->trans("PaymentCondition".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "PaymentCondition".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                                $valuetoshow=nl2br($valuetoshow);
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_pays') {
+                                $key=$langs->trans("Country".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "Country".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_availability') {
+                                $langs->load("propal");
+                                $key=$langs->trans("AvailabilityType".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "AvailabilityType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_actioncomm') {
+                                $key=$langs->trans("Action".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "Action".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_currencies') {
+                                $key=$langs->trans("Currency".strtoupper($obj->code_iso));
+                                $valuetoshow=($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_typent') {
+                                $key=$langs->trans(strtoupper($obj->code));
+                                $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_prospectlevel') {
+                                $key=$langs->trans(strtoupper($obj->code));
+                                $valuetoshow=($key != strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_civilite') {
+                                $key=$langs->trans("Civility".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "Civility".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_type_contact') {
+                                $key=$langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_payment_term') {
+                                $langs->load("bills");
+                                $key=$langs->trans("PaymentConditionShort".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_paiement') {
+                                $langs->load("bills");
+                                $key=$langs->trans("PaymentType".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "PaymentType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='label' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_reason') {
+                                $key=$langs->trans("DemandReasonType".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "DemandReasonType".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_input_method') {
+                                $langs->load("orders");
+                                $key=$langs->trans($obj->code);
+                                $valuetoshow=($obj->code && $key != $obj->code)?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='libelle' && $tabname[$_GET["id"]]==MAIN_DB_PREFIX.'c_shipment_mode') {
+                                $langs->load("sendings");
+                                $key=$langs->trans("SendingMethod".strtoupper($obj->code));
+                                $valuetoshow=($obj->code && $key != "SendingMethod".strtoupper($obj->code))?$key:$obj->$fieldlist[$field];
+                            }
+                            else if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='pays_id') {
+                                $showfield=0;
+                            }
+                            else if ($fieldlist[$field]=='unicode') {
+                            	$valuetoshow = getCurrencySymbol($obj->code);
+                            }
+                            if ($showfield) print '<td>'.$valuetoshow.'</td>';
+                        }
+                    }
+
+                    print '<td align="center" nowrap="nowrap">';
+                    // Est-ce une entree du dictionnaire qui peut etre desactivee ?
+                    $iserasable=1;  // Oui par defaut
+                    if (isset($obj->code) && ($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i',$obj->code))) $iserasable=0;
+                    if (isset($obj->code) && $obj->code == 'RECEP') $iserasable=0;
+                    if (isset($obj->code) && $obj->code == 'EF0') $iserasable=0;
+                    if ($obj->type && $obj->type == 'system') $iserasable=0;
+
+                    if ($iserasable) print '<a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$id.'&amp;action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
+                    else print $langs->trans("AlwaysActive");
+                    print "</td>";
+
+                    // Modify link
+                    if ($iserasable) print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$id.'&amp;action=edit#'.($obj->rowid?$obj->rowid:$obj->code).'">'.img_edit().'</a></td>';
+                    else print '<td>&nbsp;</td>';
+                    
+                    // Delete link
+                    if ($iserasable) print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?'.($page?'page='.$page.'&':'').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.($obj->rowid?$obj->rowid:$obj->code).'&amp;code='.$obj->code.'&amp;id='.$id.'&amp;action=delete">'.img_delete().'</a></td>';
+                    else print '<td>&nbsp;</td>';
+
+                    print "</tr>\n";
+                }
+                $i++;
+            }
+        }
+    }
+    else {
+        dol_print_error($db);
+    }
+
+    print '</table>';
+
+    print '</form>';
+}
+else
+{
+    /*
+     * Show list of dictionnary to show
+     */
+
+    $var=true;
+    $lastlineisempty=false;
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    //print '<td>'.$langs->trans("Module").'</td>';
+    print '<td colspan="2">'.$langs->trans("Dictionnary").'</td>';
+    print '<td>'.$langs->trans("Table").'</td>';
+    print '</tr>';
+
+    foreach ($taborder as $i)
+    {
+        if ($tabname[$i] && empty($tabcond[$i])) continue;
+
+        if ($i)
+        {
+            $var=!$var;
+            $value=$tabname[$i];
+            print '<tr '.$bc[$var].'><td width="30%">';
+            if (! empty($tabcond[$i]))
+            {
+                print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">'.$langs->trans($tablib[$i]).'</a>';
+            }
+            else
+            {
+                print $langs->trans($tablib[$i]);
+            }
+            print '</td>';
+            print '<td>';
+            /*if (empty($tabcond[$i]))
+             {
+             print info_admin($langs->trans("DictionnaryDisabledSinceNoModuleNeedIt"),1);
+             }*/
+            print '</td>';
+            print '<td>'.$tabname[$i].'</td></tr>';
+            $lastlineisempty=false;
+        }
+        else
+        {
+            if (! $lastlineisempty)
+            {
+                $var=!$var;
+                print '<tr '.$bc[$var].'><td width="30%">&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
+                $lastlineisempty=true;
+            }
+        }
+    }
+    print '</table>';
+}
+
+print '<br>';
+
+$db->close();
+
+llxFooter();
+
+
+/**
+ *	Show field
+ *
+ * 	@param		array	$fieldlist		Array of fields
+ * 	@param		Object	$obj			If we show a particular record, obj is filled with record fields
+ *  @param		string	$tabname		Name of SQL table
+ *	@return		void
+ */
+function fieldList($fieldlist,$obj='',$tabname='')
+{
+    global $conf,$langs,$db;
+    global $form;
+    global $region_id;
+    global $elementList,$sourceList;
+
+    $formadmin = new FormAdmin($db);
+    $formcompany = new FormCompany($db);
+
+    foreach ($fieldlist as $field => $value)
+    {
+    	if ($fieldlist[$field] == 'pays') {
+    		if (in_array('region_id',$fieldlist)) { print '<td>&nbsp;</td>'; continue; }	// For region page, we do not show the country input
+            print '<td>';
+            print $form->select_country(($obj->pays_code?$obj->pays_code:$obj->pays),'pays');
+            print '</td>';
+        }
+        elseif ($fieldlist[$field] == 'pays_id') {
+            $pays_id = (! empty($obj->$fieldlist[$field])) ? $obj->$fieldlist[$field] : 0;
+            print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$pays_id.'">';
+        }
+        elseif ($fieldlist[$field] == 'region') {
+            print '<td>';
+            $formcompany->select_region($region_id,'region');
+            print '</td>';
+        }
+        elseif ($fieldlist[$field] == 'region_id') {
+            $region_id = $obj->$fieldlist[$field]?$obj->$fieldlist[$field]:0;
+            print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$region_id.'">';
+        }
+        elseif ($fieldlist[$field] == 'lang') {
+            print '<td>';
+            print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'lang');
+            print '</td>';
+        }
+        // Le type de l'element (pour les type de contact).'
+        elseif ($fieldlist[$field] == 'element')
+        {
+            print '<td>';
+            print $form->selectarray('element', $elementList,$obj->$fieldlist[$field]);
+            print '</td>';
+        }
+        // La source de l'element (pour les type de contact).'
+        elseif ($fieldlist[$field] == 'source')
+        {
+            print '<td>';
+            print $form->selectarray('source', $sourceList,$obj->$fieldlist[$field]);
+            print '</td>';
+        }
+        elseif ($fieldlist[$field] == 'type' && $tabname == MAIN_DB_PREFIX."c_actioncomm")
+        {
+            print '<td>';
+            print 'user<input type="hidden" name="type" value="user">';
+            print '</td>';
+        }
+        elseif ($fieldlist[$field] == 'recuperableonly' || $fieldlist[$field] == 'fdm') {
+            print '<td>';
+            print $form->selectyesno($fieldlist[$field],$obj->$fieldlist[$field],1);
+            print '</td>';
+        }
+        elseif (in_array($fieldlist[$field],array('nbjour','decalage','taux','localtax1','localtax2'))) {
+            print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="3" name="'.$fieldlist[$field].'"></td>';
+        }
+        elseif ($fieldlist[$field] == 'libelle_facture') {
+            print '<td><textarea cols="30" rows="'.ROWS_2.'" class="flat" name="'.$fieldlist[$field].'">'.$obj->$fieldlist[$field].'</textarea></td>';
+        }
+        elseif ($fieldlist[$field] == 'price' || preg_match('/^amount/i',$fieldlist[$field])) {
+            print '<td><input type="text" class="flat" value="'.price($obj->$fieldlist[$field]).'" size="8" name="'.$fieldlist[$field].'"></td>';
+        }
+        elseif ($fieldlist[$field] == 'code') {
+            print '<td><input type="text" class="flat" value="'.$obj->$fieldlist[$field].'" size="10" name="'.$fieldlist[$field].'"></td>';
+        }
+        elseif ($fieldlist[$field]=='unit') {
+            print '<td>';
+            print $form->selectarray('unit',array('mm','cm','point','inch'),$obj->$fieldlist[$field],0,0,1);
+            print '</td>';
+        }
+        else
+        {
+            print '<td>';
+            print '<input type="text" '.($fieldlist[$field]=='libelle'?'size="32" ':'').' class="flat" value="'.$obj->$fieldlist[$field].'" name="'.$fieldlist[$field].'">';
+            print '</td>';
+        }
+    }
+}
+
+?>

+ 284 - 0
dolicloudimages/dolibarr/src/htdocs/admin/dons.php

@@ -0,0 +1,284 @@
+<?php
+/* Copyright (C) 2005-2010  Laurent Destailleur  	<eldy@users.sourceforge.net>
+ * Copyright (C) 2012		Juanjo Menent			<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/dons.php
+ *		\ingroup    dons
+ *		\brief      Page d'administration/configuration du module Dons
+ */
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php");
+
+$langs->load("admin");
+$langs->load("donations");
+
+if (!$user->admin) accessforbidden();
+
+$typeconst=array('yesno','texte','chaine');
+
+$action = GETPOST('action','alpha');
+
+
+/*
+ * Action
+ */
+
+if ($action == 'specimen')
+{
+    $modele=GETPOST('module','alpha');
+
+    $don = new Don($db);
+    $don->initAsSpecimen();
+
+    // Charge le modele
+    $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/";
+    $file = $modele.".modules.php";
+    if (file_exists($dir.$file))
+    {
+        $classname = $modele;
+        require_once($dir.$file);
+
+        $obj = new $classname($db);
+
+        if ($obj->write_file($don,$langs) > 0)
+        {
+            header("Location: ".DOL_URL_ROOT."/document.php?modulepart=donation&file=SPECIMEN.html");
+            return;
+        }
+        else
+        {
+            $mesg='<div class="error">'.$obj->error.'</div>';
+            dol_syslog($obj->error, LOG_ERR);
+        }
+    }
+    else
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>';
+        dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+    }
+}
+
+if ($action == 'setdoc')
+{
+	$value = GETPOST('value','alpha');
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+	
+    $db->begin();
+
+    if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity))
+    {
+        $conf->global->DON_ADDON_MODEL = $value;
+    }
+
+    // On active le modele
+    $type='donation';
+    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql_del.= " WHERE nom = '".$db->escape($value)."' AND type = '".$type."'";
+    $result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $result2=$db->query($sql);
+    if ($result1 && $result2)
+    {
+        $db->commit();
+    }
+    else
+    {
+        $db->rollback();
+    }
+}
+
+if ($action == 'set')
+{
+	$value = GETPOST('value','alpha');
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+	
+    $type='donation';
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $resql=$db->query($sql);
+}
+
+if ($action == 'del')
+{
+	$value = GETPOST('value','alpha');
+	
+    $type='donation';
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql .= "  WHERE nom = '".$value."' AND type = '".$type."'";
+    $resql=$db->query($sql);
+}
+
+
+/*
+ * View
+ */
+
+$dir = "../core/modules/dons/";
+$form=new Form($db);
+
+llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup');
+
+
+// Document templates
+print '<br>';
+print_titre($langs->trans("DonationsModels"));
+
+// Defini tableau def de modele
+$type='donation';
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$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%\">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Activated").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$handle=opendir($dir);
+
+$var=True;
+if (is_resource($handle))
+{
+    while (($file = readdir($handle))!==false)
+    {
+        if (preg_match('/\.modules\.php$/i',$file))
+        {
+            $var = !$var;
+            $name = substr($file, 0, dol_strlen($file) -12);
+            $classname = substr($file, 0, dol_strlen($file) -12);
+
+            require_once($dir.'/'.$file);
+            $module=new $classname($db);
+
+            // Show modules according to features level
+            if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+            if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+            if ($module->isEnabled())
+            {
+                print '<tr '.$bc[$var].'><td width=\"100\">';
+                echo $module->name;
+                print '</td>';
+                print '<td>';
+                print $module->description;
+                print '</td>';
+
+                // Active
+                if (in_array($name, $def))
+                {
+                    print "<td align=\"center\">\n";
+                    if ($conf->global->DON_ADDON_MODEL == $name)
+                    {
+                        print img_picto($langs->trans("Enabled"),'on');
+                    }
+                    else
+                    {
+                        print '&nbsp;';
+                        print '</td><td align="center">';
+                        print '<a href="dons.php?action=setdoc&value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Enabled"),'on').'</a>';
+                    }
+                    print '</td>';
+                }
+                else
+                {
+                    print "<td align=\"center\">\n";
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+                    print "</td>";
+                }
+
+                // Defaut
+                print "<td align=\"center\">";
+                if ($conf->global->DON_ADDON_MODEL == "$name")
+                {
+                    print img_picto($langs->trans("Default"),'on');
+                }
+                else
+                {
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$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("MultiLanguage").': '.yn($module->option_multilang,1,1);
+                $text='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'" target="specimen">'.img_object($langs->trans("Preview"),'generic').'</a>';
+                print '<td align="center">';
+                print $form->textwithpicto(' &nbsp; '.$text,$htmltooltip,-1,0);
+                print '</td>';
+
+                print "</tr>\n";
+            }
+        }
+    }
+    closedir($handle);
+}
+
+print '</table>';
+
+
+print "<br>";
+
+
+$db->close();
+
+llxFooter();
+?>

+ 126 - 0
dolicloudimages/dolibarr/src/htdocs/admin/events.php

@@ -0,0 +1,126 @@
+<?php
+/* Copyright (C) 2008-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/events.php
+ *      \ingroup    core
+ *      \brief      Log event setup page
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/agenda.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/events.class.php");
+
+
+if (!$user->admin)
+accessforbidden();
+
+$langs->load("users");
+$langs->load("admin");
+$langs->load("other");
+
+$action=GETPOST("action");
+
+
+$securityevent=new Events($db);
+$eventstolog=$securityevent->eventstolog;
+
+
+
+/*
+ *	Actions
+ */
+if ($action == "save")
+{
+	$i=0;
+
+	$db->begin();
+
+	foreach ($eventstolog as $key => $arr)
+	{
+		$param='MAIN_LOGEVENTS_'.$arr['id'];
+		//print "param=".$param." - ".$_POST[$param];
+		if (! empty($_POST[$param])) dolibarr_set_const($db,$param,$_POST[$param],'chaine',0,'',$conf->entity);
+		else dolibarr_del_const($db,$param,$conf->entity);
+	}
+
+	$db->commit();
+	$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("Audit"));
+
+//$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
+
+print $langs->trans("LogEventDesc")."<br>\n";
+print "<br>\n";
+
+$head=security_prepare_head();
+
+dol_fiche_head($head, 'audit', $langs->trans("Security"));
+
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="save">';
+
+$var=true;
+print "<table class=\"noborder\" width=\"100%\">";
+print "<tr class=\"liste_titre\">";
+print "<td colspan=\"2\">".$langs->trans("LogEvents")."</td>";
+print "</tr>\n";
+// Loop on each event type
+foreach ($eventstolog as $key => $arr)
+{
+	if ($arr['id'])
+	{
+		$var=!$var;
+		print '<tr '.$bc[$var].'>';
+		print '<td>'.$arr['id'].'</td>';
+		print '<td>';
+		$key='MAIN_LOGEVENTS_'.$arr['id'];
+		$value=$conf->global->$key;
+		print '<input '.$bc[$var].' type="checkbox" name="'.$key.'" value="1"'.($value?' checked="checked"':'').'>';
+		print '</td></tr>'."\n";
+	}
+}
+print '</table>';
+
+print '<br><center>';
+print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
+print "</center>";
+
+print "</form>\n";
+
+print '</div>';
+
+
+dol_htmloutput_mesg($mesg);
+
+
+$db->close();
+
+llxFooter();
+?>

+ 626 - 0
dolicloudimages/dolibarr/src/htdocs/admin/expedition.php

@@ -0,0 +1,626 @@
+<?php
+/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent	    <jmenent@2byte.es>
+ * Copyright (C) 2011-2012 Philippe Grand	    <philippe.grand@atoo-net.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/expedition.php
+ *	\ingroup    expedition
+ *	\brief      Page d'administration/configuration du module Expedition
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php');
+
+$langs->load("admin");
+$langs->load("sendings");
+$langs->load("deliveries");
+
+if (!$user->admin) accessforbidden();
+
+$action=GETPOST('action','alpha');
+$value=GETPOST('value','alpha');
+
+if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
+{
+    $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor';
+}
+
+
+/*
+ * Actions
+ */
+if ($action == 'specimen')
+{
+	$modele=GETPOST('module','alpha');
+
+	$exp = new Expedition($db);
+	$exp->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/expedition/doc/pdf_expedition_".$modele.".modules.php",0);
+		if (file_exists($file))
+		{
+			$filefound=1;
+			$classname = "pdf_expedition_".$modele;
+			break;
+		}
+	}
+
+	if ($filefound)
+	{
+		require_once($file);
+
+		$module = new $classname($db);
+
+		if ($module->write_file($exp,$langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf");
+			return;
+		}
+		else
+		{
+			$mesg='<font class="error">'.$module->error.'</font>';
+			dol_syslog($module->error, LOG_ERR);
+		}
+	}
+	else
+	{
+		$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
+}
+
+// Activate a model
+if ($action == 'set')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+	$type='shipping';
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+	if ($db->query($sql))
+	{
+
+	}
+}
+
+if ($action == 'del')
+{
+	$type='shipping';
+	$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+	$sql.= " WHERE nom = '".$db->escape($value)."'";
+	$sql.= " AND type = '".$type."'";
+	$sql.= " AND entity = ".$conf->entity;
+
+	if ($db->query($sql))
+	{
+        if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF',$conf->entity);
+	}
+}
+
+// Set default model
+if ($action == 'setdoc')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+	$db->begin();
+
+	if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+	{
+		$conf->global->EXPEDITION_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$type='shipping';
+	$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+	$sql_del.= " WHERE nom = '".$db->escape($value)."'";
+	$sql_del.= " AND type = '".$type."'";
+	$sql_del.= " AND entity = ".$conf->entity;
+	$result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+	$result2=$db->query($sql);
+	if ($result1 && $result2)
+	{
+		$db->commit();
+	}
+	else
+	{
+		$db->rollback();
+	}
+}
+
+// TODO A quoi servent les methode d'expedition ?
+if ($action == 'setmethod' || $action== 'setmod')
+{
+	$module=GETPOST('module','alpha');
+	$moduleid=GETPOST('moduleid','alpha');
+	$statut=GETPOST('statut','alpha');
+
+	require_once(DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_$module.modules.php");
+
+	$classname = "methode_expedition_$module";
+	$expem = new $classname($db);
+
+	$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_shipment_mode";
+	$sql.= " WHERE rowid = ".$moduleid;
+
+	$resql = $db->query($sql);
+	if ($resql && ($statut == 1 || $action == 'setmod'))
+	{
+		$db->begin();
+
+		$sqlu = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
+		$sqlu.= " SET statut=1";
+		$sqlu.= " WHERE rowid=".$moduleid;
+
+		$result=$db->query($sqlu);
+		if ($result)
+		{
+			$db->commit();
+		}
+		else
+		{
+			$db->rollback();
+		}
+	}
+
+	if ($statut == 1 || $action == 'setmod')
+	{
+		$db->begin();
+
+		$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (rowid,code,libelle,description,statut)";
+		$sql.= " VALUES (".$moduleid.",'".$expem->code."','".$expem->name."','".$expem->description."',1)";
+		$result=$db->query($sql);
+		if ($result)
+		{
+			$db->commit();
+		}
+		else
+		{
+			//dol_print_error($db);
+			$db->rollback();
+		}
+	}
+	else if ($statut == 0)
+	{
+		$db->begin();
+
+		$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
+		$sql.= " SET statut=0";
+		$sql.= " WHERE rowid=".$moduleid;
+		$result=$db->query($sql);
+		if ($result)
+		{
+			$db->commit();
+		}
+		else
+		{
+			$db->rollback();
+		}
+	}
+}
+
+if ($action == 'setmod')
+{
+	// TODO Verifier si module numerotation choisi peut etre active
+	// par appel methode canBeActivated
+
+	$module=GETPOST('module','alpha');
+
+    dolibarr_set_const($db, "EXPEDITION_ADDON",$module,'chaine',0,'',$conf->entity);
+
+}
+
+if ($action == 'updateMask')
+{
+	$maskconst=GETPOST('maskconstexpedition','alpha');
+	$maskvalue=GETPOST('maskexpedition','alpha');
+	if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'setmodel')
+{
+	dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
+}
+
+if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
+{
+	$draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
+	$res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_SHIPPING_FREE_TEXT')
+{
+	$free=GETPOST('SHIPPING_FREE_TEXT','alpha');
+	$res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+$form=new Form($db);
+
+llxHeader("","");
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
+print '<br>';
+
+
+//if ($mesg) print $mesg.'<br>';
+
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
+$head[$h][1] = $langs->trans("Setup");
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
+$head[$h][1] = $langs->trans("Sending");
+$hselected=$h;
+$h++;
+
+if ($conf->global->MAIN_SUBMODULE_LIVRAISON)
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
+	$head[$h][1] = $langs->trans("Receivings");
+	$h++;
+}
+
+dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
+
+/*
+ * Numbering module
+ */
+//print "<br>";
+
+print_titre($langs->trans("SendingsNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/expedition/");
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			$var=true;
+
+			while (($file = readdir($handle))!==false)
+			{
+				if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
+				{
+					$file = $reg[1];
+					$classname = substr($file,4);
+
+					require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php");
+
+					$module = new $file;
+
+					// 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())
+					{
+						$var=!$var;
+						print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
+						print '<td>';
+						print $module->info();
+						print '</td>';
+
+                        // Show example of numbering module
+                        print '<td nowrap="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+						print '<td align="center">';
+						if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
+						{
+							print img_picto($langs->trans("Activated"),'switch_on');
+						}
+						else
+						{
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
+							print img_picto($langs->trans("Disabled"),'switch_off');
+							print '</a>';
+						}
+						print '</td>';
+
+						$expedition=new Expedition($db);
+						$expedition->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$facture->type=0;
+						$nextval=$module->getNextValue($mysoc,$expedition);
+						if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+						{
+							$htmltooltip.=''.$langs->trans("NextValue").': ';
+							if ($nextval)
+							{
+								$htmltooltip.=$nextval.'<br>';
+							}
+							else
+							{
+								$htmltooltip.=$langs->trans($module->error).'<br>';
+							}
+						}
+
+						print '<td align="center">';
+						print $form->textwithpicto('',$htmltooltip,1,0);
+						print '</td>';
+
+						print '</tr>';
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
+}
+
+print '</table><br>';
+
+
+/*
+ *  Modeles de documents
+ */
+print_titre($langs->trans("SendingsReceiptModel"));
+
+// Defini tableau def de modele invoice
+$type="shipping";
+$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%">';
+print '<tr class="liste_titre">';
+print '<td width="140">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
+print '<td align="center" width="80" nowrap="nowrap">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/expedition/doc/");
+
+	if (is_dir($dir))
+	{
+		$handle=opendir($dir);
+	    if (is_resource($handle))
+	    {
+	    	while (($file = readdir($handle))!==false)
+	    	{
+	    		if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,15) == 'pdf_expedition_')
+	    		{
+	    			$name = substr($file, 15, dol_strlen($file) - 27);
+	    			$classname = substr($file, 0, dol_strlen($file) - 12);
+
+	    			$var=!$var;
+	    			print "<tr $bc[$var]><td>";
+	    			print $name;
+	    			print "</td><td>\n";
+	    			require_once($dir.$file);
+	    			$module = new $classname();
+
+	    			print $module->description;
+	    			print '</td>';
+
+	    			// Active
+	    			if (in_array($name, $def))
+	    			{
+	    				print "<td align=\"center\">\n";
+	    				//if ($conf->global->EXPEDITION_ADDON_PDF != $name)
+	    				//{
+	    					print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">';
+	    					print img_picto($langs->trans("Activated"),'switch_on');
+	    					print '</a>';
+	    				//}
+	    				//else
+	    				//{
+	    				//	print img_picto($langs->trans("Activated"),'switch_on');
+	    				//}
+	    				print "</td>";
+	    			}
+	    			else
+	    			{
+	    				print "<td align=\"center\">\n";
+	    				print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	    				print "</td>";
+	    			}
+
+	    			// Default
+	    			print "<td align=\"center\">";
+	    			if ($conf->global->EXPEDITION_ADDON_PDF == $name)
+	    			{
+	    				print img_picto($langs->trans("Default"),'on');
+	    			}
+	    			else
+	    			{
+	    				print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$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"));
+	    			$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);
+	    			print '<td align="center">';
+	    			$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"),'sending').'</a>';
+	    			print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0);
+	    			print '</td>';
+
+	    			print '</tr>';
+	    		}
+	    	}
+	    	closedir($handle);
+	    }
+	}
+}
+
+print '</table>';
+print '<br>';
+
+
+/*
+ * Other options
+ *
+ */
+print_titre($langs->trans("OtherOptions"));
+
+$var=true;
+print "<table class=\"noborder\" width=\"100%\">";
+print "<tr class=\"liste_titre\">";
+print "<td>".$langs->trans("Parameter")."</td>\n";
+print '<td width="60" align="center">'.$langs->trans("Value")."</td>\n";
+print "<td>&nbsp;</td>\n";
+print "</tr>";
+
+$var=! $var;
+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_SHIPPING_FREE_TEXT">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnShippings").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="SHIPPING_FREE_TEXT" class="flat" cols="120">'.$conf->global->SHIPPING_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+$var=!$var;
+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_SHIPPING_DRAFT_WATERMARK">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("WatermarkOnDraft").'<br>';
+print '<input size="50" class="flat" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.$conf->global->SHIPPING_DRAFT_WATERMARK.'">';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+print '</table>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 327 - 0
dolicloudimages/dolibarr/src/htdocs/admin/external_rss.php

@@ -0,0 +1,327 @@
+<?php
+/* Copyright (C) 2003      Eric Seigne          <erics@rycks.com>
+ * Copyright (C) 2003,2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011 	    Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/external_rss.php
+ *      \ingroup    external_rss
+ *      \brief      Page to setupe module ExternalRss
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/rssparser.class.php");
+
+$langs->load("admin");
+
+// Security check
+if (!$user->admin) accessforbidden();
+
+$def = array();
+$lastexternalrss=0;
+$action=GETPOST('action');
+
+
+/*
+ * Actions
+ */
+
+// positionne la variable pour le nombre de rss externes
+$sql ="SELECT MAX(".$db->decrypt('name').") as name FROM ".MAIN_DB_PREFIX."const";
+$sql.=" WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'";
+$result=$db->query($sql);
+if ($result)
+{
+    $obj = $db->fetch_object($result);
+    preg_match('/([0-9]+)$/i',$obj->name,$reg);
+	if ($reg[1]) $lastexternalrss = $reg[1];
+}
+else
+{
+    dol_print_error($db);
+}
+
+if ($action == 'add' || GETPOST("modify"))
+{
+    $external_rss_title = "external_rss_title_" . GETPOST("norss");
+    $external_rss_urlrss = "external_rss_urlrss_" . GETPOST("norss");
+
+    if (! empty($_POST[$external_rss_urlrss]))
+    {
+        $boxlabel='(ExternalRSSInformations)';
+        //$external_rss_url = "external_rss_url_" . $_POST["norss"];
+
+        $db->begin();
+
+		if ($_POST["modify"])
+		{
+			// Supprime boite box_external_rss de definition des boites
+/*	        $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def";
+			$sql.= " SET name = '".$boxlabel."'";
+	        $sql.= " WHERE file ='box_external_rss.php' AND note like '".$_POST["norss"]." %'";
+
+			$resql=$db->query($sql);
+			if (! $resql)
+	        {
+				dol_print_error($db,"sql=$sql");
+				exit;
+	        }
+*/
+		}
+		else
+		{
+			// Ajoute boite box_external_rss dans definition des boites
+	        $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
+			$sql.= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss").' ('.GETPOST($external_rss_title)).")')";
+	        if (! $db->query($sql))
+	        {
+	        	dol_print_error($db);
+	            $err++;
+	        }
+		}
+
+		$result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . GETPOST("norss"),GETPOST($external_rss_title),'chaine',0,'',$conf->entity);
+		if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . GETPOST("norss"),GETPOST($external_rss_urlrss),'chaine',0,'',$conf->entity);
+
+        if ($result1 && $result2)
+        {
+            $db->commit();
+	  		//$mesg='<div class="ok">'.$langs->trans("Success").'</div>';
+            header("Location: ".$_SERVER["PHP_SELF"]);
+            exit;
+        }
+        else
+        {
+            $db->rollback();
+            dol_print_error($db);
+        }
+    }
+}
+
+if ($_POST["delete"])
+{
+    if(GETPOST("norss"))
+    {
+        $db->begin();
+
+		// Supprime boite box_external_rss de definition des boites
+        $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def";
+        $sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".GETPOST("norss")." %'";
+
+		$resql=$db->query($sql);
+		if ($resql)
+        {
+			$num = $db->num_rows($resql);
+			$i=0;
+			while ($i < $num)
+			{
+				$obj=$db->fetch_object($resql);
+
+		        $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
+		        $sql.= " WHERE box_id = ".$obj->rowid;
+				$resql=$db->query($sql);
+
+		        $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes_def";
+		        $sql.= " WHERE rowid = ".$obj->rowid;
+				$resql=$db->query($sql);
+
+				if (! $resql)
+				{
+					$db->rollback();
+					dol_print_error($db,"sql=".$sql);
+					exit;
+				}
+
+				$i++;
+			}
+
+			$db->commit();
+		}
+		else
+		{
+			$db->rollback();
+			dol_print_error($db,"sql=".$sql);
+			exit;
+        }
+
+
+		$result1=dolibarr_del_const($db,"EXTERNAL_RSS_TITLE_" . GETPOST("norss"),$conf->entity);
+		if ($result1) $result2=dolibarr_del_const($db,"EXTERNAL_RSS_URLRSS_" . GETPOST("norss"),$conf->entity);
+
+        if ($result1 && $result2)
+        {
+            $db->commit();
+	  		//$mesg='<div class="ok">'.$langs->trans("Success").'</div>';
+            header("Location: external_rss.php");
+            exit;
+        }
+        else
+        {
+            $db->rollback();
+            dol_print_error($db);
+        }
+    }
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("ExternalRSSSetup"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("ExternalRSSSetup"), $linkback, 'setup');
+print '<br>';
+
+// Formulaire ajout
+print '<form name="externalrssconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td colspan="2">'.$langs->trans("NewRSS").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '</tr>';
+print '<tr class="impair">';
+print '<td width="100">'.$langs->trans("Title").'</td>';
+print '<td><input type="text" name="external_rss_title_'.($lastexternalrss+1).'" value="'.@constant("EXTERNAL_RSS_TITLE_" . ($lastexternalrss+1)).'" size="64"></td>';
+print '<td>An interesting RSS feed</td>';
+print '</tr>';
+
+print '<tr class="pair">';
+print '<td>URL du RSS</td>';
+print '<td><input type="text" name="external_rss_urlrss_'.($lastexternalrss+1).'" value="'.@constant("EXTERNAL_RSS_URLRSS_" . ($lastexternalrss+1)).'" size="64"></td>';
+print '<td>http://news.google.com/news?ned=us&topic=h&output=rss<br>http://www.dolibarr.org/rss</td>';
+print '</tr>';
+print '</table>';
+
+print '<center><br>';
+print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
+print '<input type="hidden" name="action" value="add">';
+print '<input type="hidden" name="norss" value="'.($lastexternalrss+1).'">';
+print '<br><br>';
+
+print '</form>';
+
+
+$sql ="SELECT rowid, file, note FROM ".MAIN_DB_PREFIX."boxes_def";
+$sql.=" WHERE file = 'box_external_rss.php'";
+$sql.=" ORDER BY note";
+
+dol_syslog("select rss boxes sql=".$sql,LOG_DEBUG);
+$resql=$db->query($sql);
+if ($resql)
+{
+	$num =$db->num_rows($resql);
+	$i=0;
+
+	while ($i < $num)
+	{
+		$obj = $db->fetch_object($resql);
+
+	    preg_match('/^([0-9]+)/i',$obj->note,$reg);
+		$idrss = $reg[1];
+		//print "x".$idrss;
+
+        $rssparser=new RssParser($db);
+		$result = $rssparser->parser(@constant("EXTERNAL_RSS_URLRSS_".$idrss), 5, 300, $conf->externalrss->dir_temp);
+
+		$var=true;
+
+		print "<br>";
+		print "<form name=\"externalrssconfig\" action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
+
+		print '<table class="noborder" width="100%">';
+		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+		print "<tr class=\"liste_titre\">";
+		print "<td>".$langs->trans("RSS")." ".($i+1)."</td>";
+        print '<td align="right">';
+        print "<input type=\"submit\" class=\"button\" name=\"modify\" value=\"".$langs->trans("Modify")."\">";
+		print " &nbsp; ";
+		print "<input type=\"submit\" class=\"button\" name=\"delete\" value=\"".$langs->trans("Delete")."\">";
+		print "<input type=\"hidden\" name=\"norss\"  value=\"".$idrss."\">";
+		print '</td>';
+		print "</tr>";
+
+		$var=!$var;
+		print "<tr ".$bc[$var].">";
+		print "<td width=\"100px\">".$langs->trans("Title")."</td>";
+		print "<td><input type=\"text\" class=\"flat\" name=\"external_rss_title_" . $idrss . "\" value=\"" . @constant("EXTERNAL_RSS_TITLE_" . $idrss) . "\" size=\"64\"></td>";
+		print "</tr>";
+
+		$var=!$var;
+		print "<tr ".$bc[$var].">";
+		print "<td>".$langs->trans("URL")."</td>";
+		print "<td><input type=\"text\" class=\"flat\" name=\"external_rss_urlrss_" . $idrss . "\" value=\"" . @constant("EXTERNAL_RSS_URLRSS_" . $idrss) . "\" size=\"64\"></td>";
+		print "</tr>";
+
+		$var=!$var;
+		print "<tr ".$bc[$var].">";
+		print "<td>".$langs->trans("Status")."</td>";
+		print "<td>";
+	    if ($result > 0 && empty($rss->error))
+	    {
+			print '<font class="ok">'.$langs->trans("Online").'</div>';
+		}
+		else
+		{
+			print '<font class="error">'.$langs->trans("Offline");
+			$langs->load("errors");
+			if ($rssparser->error) print ' - '.$langs->trans($rssparser->error);
+			print '</div>';
+		}
+		print "</td>";
+		print "</tr>";
+
+		// Logo
+	    if ($result > 0 && empty($rss->error))
+	    {
+			$var=!$var;
+			print "<tr ".$bc[$var].">";
+			print "<td>".$langs->trans("Logo")."</td>";
+			print '<td>';
+			$imageurl=$rssparser->getImageUrl();
+			if ($imageurl) print '<img height="32" src="'.$imageurl.'">';
+			else print $langs->trans("None");
+			print '</td>';
+			print "</tr>";
+		}
+
+		print '</table>';
+
+		print "</form>";
+
+		$i++;
+	}
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 783 - 0
dolicloudimages/dolibarr/src/htdocs/admin/facture.php

@@ -0,0 +1,783 @@
+<?php
+/* Copyright (C) 2003-2004	Rodolphe Quiedeville		<rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011	Laurent Destailleur			<eldy@users.sourceforge.net>
+ * Copyright (C) 2005		Eric Seigne					<eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2012	Regis Houssin				<regis@dolibarr.fr>
+ * Copyright (C) 2008		Raphael Bertrand (Resultic)	<raphael.bertrand@resultic.fr>
+ * Copyright (C) 2012		Juanjo Menent				<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/facture.php
+ *		\ingroup    facture
+ *		\brief      Page to setup invoice module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php');
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'updateMask')
+{
+    $maskconstinvoice=GETPOST('maskconstinvoice','alpha');
+    $maskconstcredit=GETPOST('maskconstcredit','alpha');
+    $maskinvoice=GETPOST('maskinvoice','alpha');
+    $maskcredit=GETPOST('maskcredit','alpha');
+    if ($maskconstinvoice) $res = dolibarr_set_const($db,$maskconstinvoice,$maskinvoice,'chaine',0,'',$conf->entity);
+    if ($maskconstcredit)  $res = dolibarr_set_const($db,$maskconstcredit,$maskcredit,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'specimen')
+{
+    $modele=GETPOST('module','alpha');
+
+    $facture = new Facture($db);
+    $facture->initAsSpecimen();
+
+	// Search template files
+	$file=''; $classname=''; $filefound=0;
+	$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+	foreach($dirmodels as $reldir)
+	{
+	    $file=dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php",0);
+    	if (file_exists($file))
+    	{
+    		$filefound=1;
+    		$classname = "pdf_".$modele;
+    		break;
+    	}
+    }
+
+    if ($filefound)
+    {
+    	require_once($file);
+
+    	$module = new $classname($db);
+
+    	if ($module->write_file($facture,$langs) > 0)
+    	{
+    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
+    		return;
+    	}
+    	else
+    	{
+    		$mesg='<font class="error">'.$module->error.'</font>';
+    		dol_syslog($module->error, LOG_ERR);
+    	}
+    }
+    else
+    {
+    	$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+    	dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+    }
+}
+
+// define constants for models generator that need parameters
+if ($action == 'setModuleOptions')
+{
+    $post_size=count($_POST);
+    for($i=0;$i < $post_size;$i++)
+    {
+        if (array_key_exists('param'.$i,$_POST))
+        {
+            $param=GETPOST("param".$i,'alpha');
+            $value=GETPOST("value".$i,'alpha');
+            if ($param) $res = dolibarr_set_const($db,$param,$value,'chaine',0,'',$conf->entity);
+        }
+    }
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+    $type='invoice';
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    if ($db->query($sql))
+    {
+
+    }
+}
+
+if ($action == 'del')
+{
+    $type='invoice';
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql.= " WHERE nom = '".$db->escape($value)."'";
+    $sql.= " AND type = '".$type."'";
+    $sql.= " AND entity = ".$conf->entity;
+
+    if ($db->query($sql))
+    {
+        if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF',$conf->entity);
+    }
+}
+
+if ($action == 'setdoc')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+    $db->begin();
+
+    if (dolibarr_set_const($db, "FACTURE_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+    {
+        $conf->global->FACTURE_ADDON_PDF = $value;
+    }
+
+    // On active le modele
+    $type='invoice';
+
+    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql_del.= " WHERE nom = '".$db->escape($value)."'";
+    $sql_del.= " AND type = '".$type."'";
+    $sql_del.= " AND entity = ".$conf->entity;
+    dol_syslog("facture.php ".$sql_del);
+    $result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$scandir."'":"null");
+    $sql.= ")";
+    dol_syslog("facture.php ".$sql);
+    $result2=$db->query($sql);
+    if ($result1 && $result2)
+    {
+        $db->commit();
+    }
+    else
+    {
+        dol_syslog("facture.php ".$db->lasterror(), LOG_ERR);
+        $db->rollback();
+    }
+}
+
+if ($action == 'setmod')
+{
+    // TODO Verifier si module numerotation choisi peut etre active
+    // par appel methode canBeActivated
+
+    dolibarr_set_const($db, "FACTURE_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+if ($action == 'setribchq')
+{
+	$rib = GETPOST('rib','alpha');
+	$chq = GETPOST('chq','alpha');
+
+	$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER",$rib,'chaine',0,'',$conf->entity);
+    $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER",$chq,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_FACTURE_DRAFT_WATERMARK')
+{
+	$draft = GETPOST('FACTURE_DRAFT_WATERMARK','alpha');
+
+    $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_FACTURE_FREE_TEXT')
+{
+	$free = GETPOST('FACTURE_FREE_TEXT','alpha');
+
+    $res = dolibarr_set_const($db, "FACTURE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'setforcedate')
+{
+	$forcedate = GETPOST('forcedate','alpha');
+
+    $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION",$forcedate,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+llxHeader("",$langs->trans("BillsSetup"),'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura');
+
+$form=new Form($db);
+
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("BillsSetup"),$linkback,'setup');
+print '<br>';
+
+
+/*
+ *  Numbering module
+ */
+
+print_titre($langs->trans("BillsNumberingModule"));
+
+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 nowrap>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/facture/");
+    if (is_dir($dir))
+    {
+        $handle = opendir($dir);
+        if (is_resource($handle))
+        {
+        	$var=true;
+
+            while (($file = readdir($handle))!==false)
+            {
+                if (! is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
+                {
+                    $filebis = $file;
+                    $classname = preg_replace('/\.php$/','',$file);
+                    // For compatibility
+                    if (! is_file($dir.$filebis))
+                    {
+                        $filebis = $file."/".$file.".modules.php";
+                        $classname = "mod_facture_".$file;
+                    }
+                    if (! class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/',$filebis) || preg_match('/mod_/',$classname)) && substr($filebis, dol_strlen($filebis)-3, 3) == 'php')
+                    {
+                        // Chargement de la classe de numerotation
+                        require_once($dir.$filebis);
+
+                        $module = new $classname($db);
+
+                        // Show modules according to features level
+                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+                        if ($module->isEnabled())
+                        {
+                            $var = !$var;
+                            print '<tr '.$bc[$var].'><td width="100">';
+                            echo preg_replace('/mod_facture_/','',preg_replace('/\.php$/','',$file));
+                            print "</td><td>\n";
+
+                            print $module->info();
+
+                            print '</td>';
+
+                            // Show example of numbering module
+                            print '<td nowrap="nowrap">';
+                            $tmp=$module->getExample();
+                            if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                            elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                            else print $tmp;
+                            print '</td>'."\n";
+
+                            print '<td align="center">';
+                            //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
+                            if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
+                            {
+                                print img_picto($langs->trans("Activated"),'switch_on');
+                            }
+                            else
+                            {
+                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/','',$file).'&scandir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+                            }
+                            print '</td>';
+
+                            $facture=new Facture($db);
+                            $facture->initAsSpecimen();
+
+                            // Example for standard invoice
+                            $htmltooltip='';
+                            $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+                            $facture->type=0;
+                            $nextval=$module->getNextValue($mysoc,$facture);
+                            if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+                            {
+                                $htmltooltip.=$langs->trans("NextValueForInvoices").': ';
+                                if ($nextval)
+                                {
+                                    $htmltooltip.=$nextval.'<br>';
+                                }
+                                else
+                                {
+                                    $htmltooltip.=$langs->trans($module->error).'<br>';
+                                }
+                            }
+                            // Example for credit invoice
+                            $facture->type=2;
+                            $nextval=$module->getNextValue($mysoc,$facture);
+                            if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+                            {
+                                $htmltooltip.=$langs->trans("NextValueForCreditNotes").': ';
+                                if ($nextval)
+                                {
+                                    $htmltooltip.=$nextval;
+                                }
+                                else
+                                {
+                                    $htmltooltip.=$langs->trans($module->error);
+                                }
+                            }
+
+                            print '<td align="center">';
+                            print $form->textwithpicto('',$htmltooltip,1,0);
+
+                            if ($conf->global->FACTURE_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
+                            {
+                                if (! empty($module->error)) dol_htmloutput_mesg($module->error,'','error',1);
+                            }
+
+                            print '</td>';
+
+                            print "</tr>\n";
+
+                        }
+                    }
+                }
+            }
+            closedir($handle);
+        }
+    }
+}
+
+print '</table>';
+
+
+/*
+ *  Document templates generators
+ */
+print '<br>';
+print_titre($langs->trans("BillsPDFModules"));
+
+// Load array def with activated templates
+$type='invoice';
+$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%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
+print '<td align="center" width="32" colspan="2">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
+    {
+    	$dir = dol_buildpath($reldir."core/modules/facture".$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 '.$bc[$var].'><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 align="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 align=\"center\">\n";
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Defaut
+	                            print "<td align=\"center\">";
+	                            if ($conf->global->FACTURE_ADDON_PDF == "$name")
+	                            {
+	                                print img_picto($langs->trans("Default"),'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scandir='.$module->scandir.'&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("Escompte").': '.yn($module->option_escompte,1,1);
+	                            $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+	                            $htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+	                            $htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark,1,1);
+
+
+	                            print '<td align="center">';
+	                            print $form->textwithpicto('',$htmltooltip,1,0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td align="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>';
+
+
+/*
+ *  Modes de reglement
+ *
+ */
+print '<br>';
+print_titre($langs->trans("SuggestedPaymentModesIfNotDefinedInInvoice"));
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
+
+print '<table class="noborder" width="100%">';
+$var=True;
+
+print '<tr class="liste_titre">';
+print '<td>';
+print '<input type="hidden" name="action" value="setribchq">';
+print $langs->trans("PaymentMode").'</td>';
+print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+print "</tr>\n";
+$var=!$var;
+print '<tr '.$bc[$var].'>';
+print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
+print "<td>";
+if ($conf->banque->enabled)
+{
+    $sql = "SELECT rowid, label";
+    $sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
+    $sql.= " WHERE clos = 0";
+    $sql.= " AND courant = 1";
+    $sql.= " AND entity = ".$conf->entity;
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $num = $db->num_rows($resql);
+        $i = 0;
+        if ($num > 0)
+        {
+        	print '<select name="rib" class="flat" id="rib">';
+        	print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
+            while ($i < $num)
+            {
+                $row = $db->fetch_row($resql);
+
+                print '<option value="'.$row[0].'"';
+                print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected="selected"':'';
+                print '>'.$row[1].'</option>';
+
+                $i++;
+            }
+            print "</select>";
+        }
+        else
+        {
+        	print "<i>".$langs->trans("NoActiveBankAccountDefined")."</i>";
+        }
+    }
+}
+else
+{
+    print $langs->trans("BankModuleNotActive");
+}
+print "</td></tr>";
+$var=!$var;
+print '<tr '.$bc[$var].'>';
+print "<td>".$langs->trans("SuggestPaymentByChequeToAddress")."</td>";
+print "<td>";
+print '<select class="flat" name="chq" id="chq">';
+print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
+print '<option value="-1"'.($conf->global->FACTURE_CHQ_NUMBER?' selected="selected"':'').'>'.$langs->trans("MenuCompanySetup").' ('.($mysoc->name?$mysoc->name:$langs->trans("NotDefined")).')</option>';
+
+$sql = "SELECT rowid, label";
+$sql.= " FROM ".MAIN_DB_PREFIX."bank_account";
+$sql.= " WHERE clos = 0";
+$sql.= " AND courant = 1";
+$sql.= " AND entity = ".$conf->entity;
+$var=True;
+$resql=$db->query($sql);
+if ($resql)
+{
+    $num = $db->num_rows($resql);
+    $i = 0;
+    while ($i < $num)
+    {
+        $var=!$var;
+        $row = $db->fetch_row($resql);
+
+        print '<option value="'.$row[0].'"';
+        print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected="selected"':'';
+        print '>'.$langs->trans("OwnerOfBankAccount",$row[1]).'</option>';
+
+        $i++;
+    }
+}
+print "</select>";
+print "</td></tr>";
+print "</table>";
+print "</form>";
+
+
+print "<br>";
+print_titre($langs->trans("OtherOptions"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print '<td width="80">&nbsp;</td>';
+print "</tr>\n";
+$var=true;
+
+// Force date validation
+$var=! $var;
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
+print '<input type="hidden" name="action" value="setforcedate" />';
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("ForceInvoiceDate");
+print '</td><td width="60" align="center">';
+print $form->selectyesno("forcedate",$conf->global->FAC_FORCE_DATE_VALIDATION,1);
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
+print "</td></tr>\n";
+print '</form>';
+
+$var=! $var;
+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_FACTURE_FREE_TEXT" />';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="FACTURE_FREE_TEXT" class="flat" cols="120">'.$conf->global->FACTURE_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
+print "</td></tr>\n";
+print '</form>';
+
+$var=!$var;
+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_FACTURE_DRAFT_WATERMARK" />';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("WatermarkOnDraftBill").'<br>';
+print '<input size="50" class="flat" type="text" name="FACTURE_DRAFT_WATERMARK" value="'.$conf->global->FACTURE_DRAFT_WATERMARK.'" />';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';
+print "</td></tr>\n";
+print '</form>';
+
+print '</table>';
+
+
+/*
+ *  Repertoire
+ */
+print '<br>';
+print_titre($langs->trans("PathToDocuments"));
+
+print '<table class="noborder" width="100%">'."\n";
+print '<tr class="liste_titre">'."\n";
+print '<td>'.$langs->trans("Name").'</td>'."\n";
+print '<td>'.$langs->trans("Value").'</td>'."\n";
+print "</tr>\n";
+print '<tr '.$bc[false].'>'."\n";
+print '<td width="140">'.$langs->trans("PathDirectory").'</td>'."\n";
+print '<td>'.$conf->facture->dir_output.'</td>'."\n";
+print '</tr>'."\n";
+print "</table>\n";
+
+
+//dol_fiche_end();
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 170 - 0
dolicloudimages/dolibarr/src/htdocs/admin/fckeditor.php

@@ -0,0 +1,170 @@
+<?php
+/* Copyright (C) 2004-2011 Laurent Destailleur   <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2011 Regis Houssin         <regis@dolibarr.fr>
+ * Copyright (C) 2012	   Juanjo Menent         <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ *  \file       htdocs/admin/fckeditor.php
+ *  \ingroup    fckeditor
+ *  \brief      Page d'activation du module FCKeditor dans les autres modules
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+
+$langs->load("admin");
+$langs->load("fckeditor");
+
+$action = GETPOST('action','alpha');
+
+if (!$user->admin) accessforbidden();
+
+// Constante et traduction de la description du module
+$modules = array(
+'SOCIETE' => 'FCKeditorForCompany',
+'PRODUCTDESC' => 'FCKeditorForProduct',
+'MAILING' => 'FCKeditorForMailing',
+'DETAILS' => 'FCKeditorForProductDetails',
+);
+// Conditions pour que l'option soit proposee
+$conditions = array(
+'SOCIETE' => 1,
+'PRODUCTDESC' => ($conf->product->enabled||$conf->service->enabled),
+'MAILING' => $conf->mailing->enabled,
+'DETAILS' => ($conf->facture->enabled||$conf->propal->enabled||$conf->commande->enabled),
+);
+// Picto
+$picto = array(
+'SOCIETE' => 'generic',
+'PRODUCTDESC' => 'product',
+'MAILING' => 'email',
+'DETAILS' => 'generic',
+);
+
+
+
+/*
+ *  Actions
+ */
+
+foreach($modules as $const => $desc)
+{
+    if ($action == 'activate_'.strtolower($const))
+    {
+        dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1",'chaine',0,'',$conf->entity);
+        // Si fckeditor est active dans la description produit/service, on l'active dans les formulaires
+        if ($const == 'PRODUCTDESC' && $conf->global->PRODUIT_DESC_IN_FORM)
+        {
+            dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1",'chaine',0,'',$conf->entity);
+        }
+        Header("Location: ".$_SERVER["PHP_SELF"]);
+        exit;
+    }
+    if ($action == 'disable_'.strtolower($const))
+    {
+        dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const,$conf->entity);
+        Header("Location: ".$_SERVER["PHP_SELF"]);
+        exit;
+    }
+}
+
+if (GETPOST('save','alpha'))
+{
+    $res=dolibarr_set_const($db, "FCKEDITOR_TEST", GETPOST('formtestfield'),'chaine',0,'',$conf->entity);
+
+    if ($res > 0) $mesg=$langs->trans("RecordModifiedSuccessfully");
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader();
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("AdvancedEditor"),$linkback,'setup');
+print '<br>';
+
+$var=true;
+
+if (empty($conf->use_javascript_ajax))
+{
+    dol_htmloutput_errors('',array($langs->trans("NotAvailable"),$langs->trans("JavascriptDisabled")),1);
+}
+else
+{
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td colspan="2">'.$langs->trans("ActivateFCKeditor").'</td>';
+    print '<td align="center" width="100">'.$langs->trans("Action").'</td>';
+    print "</tr>\n";
+
+    // Modules
+    foreach($modules as $const => $desc)
+    {
+        // Si condition non remplie, on ne propose pas l'option
+        if (! $conditions[$const]) continue;
+
+        $var=!$var;
+        print "<tr ".$bc[$var].">";
+        print '<td width="16">'.img_object("",$picto[$const]).'</td>';
+        print '<td>'.$langs->trans($desc).'</td>';
+        print '<td align="center" width="100">';
+        $constante = 'FCKEDITOR_ENABLE_'.$const;
+        $value = $conf->global->$constante;
+        if($value == 0)
+        {
+            print '<a href="fckeditor.php?action=activate_'.strtolower($const).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+        }
+        else if($value == 1)
+        {
+            print '<a href="fckeditor.php?action=disable_'.strtolower($const).'">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
+        }
+
+        print "</td>";
+        print '</tr>';
+    }
+
+    print '</table>'."\n";
+
+    dol_htmloutput_mesg($mesg);
+
+    print '<br>'."\n";
+    print_fiche_titre($langs->trans("TestSubmitForm"),'','');
+    print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
+    $uselocalbrowser=true;
+    $editor=new DolEditor('formtestfield',isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test','',200,'dolibarr_notes','In', true, $uselocalbrowser);
+    $editor->Create();
+    print '<center><br><input class="button" type="submit" name="save" value="'.$langs->trans("Save").'"></center>'."\n";
+    print '</form>'."\n";
+
+    /*
+     print '<!-- Result -->';
+     print $_POST["formtestfield"];
+     print '<!-- Result -->';
+     print $conf->global->FCKEDITOR_TEST;
+     */
+}
+
+$db->close();
+
+llxFooter();
+?>

+ 463 - 0
dolicloudimages/dolibarr/src/htdocs/admin/fichinter.php

@@ -0,0 +1,463 @@
+<?php
+/* Copyright (C) 2003-2004 Rodolphe Quiedeville         <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur          <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio          <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier               <benoit.mortier@opensides.be>
+ * Copyright (C) 2005-2012 Regis Houssin                <regis@dolibarr.fr>
+ * Copyright (C) 2008 	   Raphael Bertrand (Resultic)  <raphael.bertrand@resultic.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent			    <jmenent@2byte.es>
+ * Copyright (C) 2011-2012 Philippe Grand			    <philippe.grand@atoo-net.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/fichinter.php
+ *	\ingroup    fichinter
+ *	\brief      Setup page of module Interventions
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php');
+
+$langs->load("admin");
+$langs->load("errors");
+$langs->load("interventions");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+$label = GETPOST('label','alpha');
+$scandir = GETPOST('scandir','alpha');
+$type='ficheinter';
+
+
+/*
+ * Actions
+ */
+if ($action == 'updateMask')
+{
+	$maskconst=GETPOST('maskconst','alpha');
+	$maskvalue=GETPOST('maskvalue','alpha');
+	if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_FICHINTER_FREE_TEXT')
+{
+	$freetext= GETPOST('FICHINTER_FREE_TEXT','alpha');
+	$res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'set_FICHINTER_DRAFT_WATERMARK')
+{
+	$draft= GETPOST('FICHINTER_DRAFT_WATERMARK','alpha');
+
+	$res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'specimen')
+{
+	$modele= GETPOST('module','alpha');
+
+	$inter = new Fichinter($db);
+	$inter->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/fichinter/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($inter,$langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf");
+			return;
+		}
+		else
+		{
+			$mesg='<font class="error">'.$obj->error.'</font>';
+			dol_syslog($obj->error, LOG_ERR);
+		}
+	}
+	else
+	{
+		$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
+}
+
+if ($action == 'set')
+{
+	$ret = addDocumentModel($value, $type, $label, $scandir);
+}
+
+if ($action == 'del')
+{
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF',$conf->entity);
+	}
+}
+
+if ($action == 'setdoc')
+{
+	if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+	{
+		// La constante qui a ete lue en avant du nouveau set
+		// on passe donc par une variable pour avoir un affichage coherent
+		$conf->global->FICHEINTER_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
+}
+
+if ($action == 'setmod')
+{
+	// TODO Verifier si module numerotation choisi peut etre active
+	// par appel methode canBeActivated
+
+	dolibarr_set_const($db, "FICHEINTER_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup');
+
+print "<br>";
+
+
+print_titre($langs->trans("FicheinterNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/fichinter/");
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			$var=true;
+
+			while (($file = readdir($handle))!==false)
+			{
+				if (preg_match('/^(mod_.*)\.php$/i',$file,$reg))
+				{
+					$file = $reg[1];
+					$classname = substr($file,4);
+
+					require_once(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/".$file.".php");
+
+					$module = new $file;
+
+					// 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())
+					{
+						$var=!$var;
+						print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
+						print $module->info();
+						print '</td>';
+
+                        // Show example of numbering module
+                        print '<td nowrap="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+						print '<td align="center">';
+						if ($conf->global->FICHEINTER_ADDON == $classname)
+						{
+							print img_picto($langs->trans("Activated"),'switch_on');
+						}
+						else
+						{
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+						}
+						print '</td>';
+
+						$ficheinter=new Fichinter($db);
+						$ficheinter->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$nextval=$module->getNextValue($mysoc,$ficheinter);
+						if ($nextval != $langs->trans("NotAvailable"))
+						{
+							$htmltooltip.=''.$langs->trans("NextValue").': '.$nextval;
+						}
+						print '<td align="center">';
+						print $form->textwithpicto('',$htmltooltip,1,0);
+						print '</td>';
+
+						print '</tr>';
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
+}
+
+print '</table><br>';
+
+
+
+print_titre($langs->trans("TemplatePDFInterventions"));
+
+// Defini tableau def des modeles
+$type='ficheinter';
+$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%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td align="center" width="80">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+$var=true;
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/fichinter/doc/");
+
+	if (is_dir($dir))
+	{
+		$handle=opendir($dir);
+		if (is_resource($handle))
+		{
+		    while (($file = readdir($handle))!==false)
+		    {
+		    	if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
+		    	{
+		    		$name = substr($file, 4, dol_strlen($file) -16);
+		    		$classname = substr($file, 0, dol_strlen($file) -12);
+
+		    		$var=!$var;
+
+		    		print '<tr '.$bc[$var].'><td>';
+		    		echo "$name";
+		    		print "</td><td>\n";
+		    		require_once($dir.$file);
+		    		$module = new $classname($db);
+		    		print $module->description;
+		    		print '</td>';
+
+		    		// Active
+		    		if (in_array($name, $def))
+		    		{
+		    			print "<td align=\"center\">\n";
+		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
+		    			print img_picto($langs->trans("Enabled"),'switch_on');
+		    			print '</a>';
+		    			print "</td>";
+		    		}
+		    		else
+		    		{
+		    			print "<td align=\"center\">\n";
+		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+		    			print "</td>";
+		    		}
+
+		    		// Defaut
+		    		print "<td align=\"center\">";
+		    		if ($conf->global->FICHEINTER_ADDON_PDF == "$name")
+		    		{
+		    			print img_picto($langs->trans("Default"),'on');
+		    		}
+		    		else
+		    		{
+		    			print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$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"));
+		    		$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+		    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+		    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+		    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1);
+		    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1);
+		    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1);
+		    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1);
+		    		print '<td align="center">';
+		    		$link='<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'intervention').'</a>';
+		    		print $form->textwithpicto(' &nbsp; &nbsp; '.$link,$htmltooltip,-1,0);
+		    		print '</td>';
+
+		    		print '</tr>';
+		    	}
+		    }
+		    closedir($handle);
+		}
+	}
+}
+
+print '</table>';
+
+//Autres Options
+print "<br>";
+print_titre($langs->trans("OtherOptions"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print "<td>&nbsp;</td>\n";
+print "</tr>\n";
+$var=true;
+
+$var=! $var;
+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_FICHINTER_FREE_TEXT">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnInterventions").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="FICHINTER_FREE_TEXT" class="flat" cols="120">'.$conf->global->FICHINTER_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+//Use draft Watermark
+$var=!$var;
+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_FICHINTER_DRAFT_WATERMARK\">";
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("WatermarkOnDraftInterventionCards").'<br>';
+print '<input size="50" class="flat" type="text" name="FICHINTER_DRAFT_WATERMARK" value="'.$conf->global->FICHINTER_DRAFT_WATERMARK.'">';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+
+print '</table>';
+
+print '<br>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 677 - 0
dolicloudimages/dolibarr/src/htdocs/admin/fournisseur.php

@@ -0,0 +1,677 @@
+<?php
+/* Copyright (C) 2003-2007 Rodolphe Quiedeville    <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur     <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2011 Regis Houssin           <regis@dolibarr.fr>
+ * Copyright (C) 2004      Sebastien Di Cintio     <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier          <benoit.mortier@opensides.be>
+ * Copyright (C) 2010-2012 Juanjo Menent           <jmenent@2byte.es>
+ * Copyright (C) 2011      Philippe Grand          <philippe.grand@atoo-net.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       htdocs/admin/fournisseur.php
+ *  \ingroup    fournisseur
+ *  \brief      Page d'administration-configuration du module Fournisseur
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php');
+require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php');
+require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
+
+$langs->load("admin");
+
+if (!$user->admin)
+accessforbidden();
+
+$type=GETPOST('type', 'alpha');
+$value=GETPOST('value', 'alpha');
+$action=GETPOST('action', 'alpha');
+
+$specimenthirdparty=new Societe($db);
+$specimenthirdparty->initAsSpecimen();
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'updateMask')
+{
+    $maskconstorder=GETPOST('maskconstorder','alpha');
+    $maskorder=GETPOST('maskorder','alpha');
+
+    if ($maskconstorder)  $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity);
+
+    if (! $res > 0) $error++;
+
+    if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'specimen')  // For orders
+{
+    $modele=GETPOST('module','alpha');
+
+    $commande = new CommandeFournisseur($db);
+    $commande->initAsSpecimen();
+    $commande->thirdparty=$specimenthirdparty;
+
+    // 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/supplier_order/pdf/pdf_".$modele.".modules.php",0);
+    	if (file_exists($file))
+    	{
+    		$filefound=1;
+    		$classname = "pdf_".$modele;
+    		break;
+    	}
+    }
+
+    if ($filefound)
+    {
+    	require_once($file);
+
+    	$module = new $classname($db,$commande);
+
+    	if ($module->write_file($commande,$langs) > 0)
+    	{
+    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf");
+    		return;
+    	}
+    	else
+    	{
+    		$mesg='<font class="error">'.$module->error.'</font>';
+    		dol_syslog($module->error, LOG_ERR);
+    	}
+    }
+    else
+    {
+    	$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+    	dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+    }
+}
+
+if ($action == 'specimenfacture')   // For invoices
+{
+    $modele=GETPOST('module','alpha');
+
+    $facture = new FactureFournisseur($db);
+    $facture->initAsSpecimen();
+    $facture->thirdparty=$specimenthirdparty;    // Define who should has build the invoice (so the supplier)
+
+	// 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/supplier_invoice/pdf/pdf_".$modele.".modules.php",0);
+    	if (file_exists($file))
+    	{
+    		$filefound=1;
+    		$classname = "pdf_".$modele;
+    		break;
+    	}
+    }
+
+    if ($filefound)
+    {
+    	require_once($file);
+
+    	$module = new $classname($db,$facture);
+
+    	if ($module->write_file($facture,$langs) > 0)
+    	{
+    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture_fournisseur&file=SPECIMEN.pdf");
+    		return;
+    	}
+    	else
+    	{
+    		$mesg='<font class="error">'.$module->error.'</font>';
+    		dol_syslog($module->error, LOG_ERR);
+    	}
+    }
+    else
+    {
+    	$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+    	dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+    }
+}
+
+if ($action == 'set')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $res=$db->query($sql);
+    if ($res)
+    {
+
+    }
+    //	else dol_print_error($db);
+}
+
+if ($action == 'del')
+{
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql.= " WHERE nom = '".$value."'";
+    $sql.= " AND type = '".$type."'";
+    $sql.= " AND entity = ".$conf->entity;
+    $db->query($sql);
+    if ($res)
+    {
+
+    }
+    //    else dol_print_error($db);
+}
+
+if ($action == 'setdoc')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+    $db->begin();
+
+    if ($type == 'order_supplier' && dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+    {
+        $conf->global->COMMANDE_SUPPLIER_ADDON_PDF = $value;
+    }
+
+    if ($type == 'invoice_supplier' && dolibarr_set_const($db, "INVOICE_SUPPLIER_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+    {
+        $conf->global->INVOICE_SUPPLIER_ADDON_PDF = $value;
+    }
+
+    // On active le modele
+    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql_del.= " WHERE nom = '".$db->escape($value)."'";
+    $sql_del.= " AND type = '".$type."'";
+    $sql_del.= " AND entity = ".$conf->entity;
+    $result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $result2=$db->query($sql);
+    if ($result1 && $result2)
+    {
+        $db->commit();
+    }
+    else
+    {
+        $db->rollback();
+    }
+}
+
+if ($action == 'setmod')
+{
+    // TODO Verifier si module numerotation choisi peut etre active
+    // par appel methode canBeActivated
+
+    dolibarr_set_const($db, "COMMANDE_SUPPLIER_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+if ($action == 'addcat')
+{
+    $fourn = new Fournisseur($db);
+    $fourn->CreateCategory($user,$_POST["cat"]);
+}
+
+if ($action == 'set_SUPPLIER_INVOICE_FREE_TEXT')
+{
+    $free = GETPOST('SUPPLIER_INVOICE_FREE_TEXT','alpha');
+    $res = dolibarr_set_const($db, "SUPPLIER_INVOICE_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
+
+    if (! $res > 0) $error++;
+
+    if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ * View
+ */
+
+$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']);
+
+llxHeader();
+
+$form=new Form($db);
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup');
+
+print "<br>";
+
+
+// Supplier order numbering module
+
+print_titre($langs->trans("OrdersNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="16">'.$langs->trans("Info").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/supplier_order/");
+
+    if (is_dir($dir))
+    {
+        $handle = opendir($dir);
+        if (is_resource($handle))
+        {
+            $var=true;
+
+            while (($file = readdir($handle))!==false)
+            {
+                if (substr($file, 0, 25) == 'mod_commande_fournisseur_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+                {
+                    $file = substr($file, 0, dol_strlen($file)-4);
+
+                    require_once($dir.$file.".php");
+
+                    $module = new $file;
+
+                    if ($module->isEnabled())
+                    {
+                        // 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;
+
+                        $var=!$var;
+                        print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
+                        print $module->info();
+                        print '</td>';
+
+                        // Show example of numbering module
+                        print '<td nowrap="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/',$tmp)) {
+                            $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
+                        }
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+                        print '<td align="center">';
+                        if ($conf->global->COMMANDE_SUPPLIER_ADDON == "$file")
+                        {
+                            print img_picto($langs->trans("Activated"),'switch_on');
+                        }
+                        else
+                        {
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+                        }
+                        print '</td>';
+
+                        $commande=new CommandeFournisseur($db);
+                        $commande->initAsSpecimen();
+
+                        // Info
+                        $htmltooltip='';
+                        $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+                        $facture->type=0;
+                        $nextval=$module->getNextValue($mysoc,$commande);
+                        if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+                        {
+                            $htmltooltip.=''.$langs->trans("NextValue").': ';
+                            if ($nextval)
+                            {
+                                $htmltooltip.=$nextval.'<br>';
+                            }
+                            else
+                            {
+                                $htmltooltip.=$langs->trans($module->error).'<br>';
+                            }
+                        }
+
+                        print '<td align="center">';
+                        print $form->textwithpicto('',$htmltooltip,1,0);
+                        print '</td>';
+
+                        print '</tr>';
+                    }
+                }
+            }
+            closedir($handle);
+        }
+    }
+}
+
+print '</table><br>';
+
+
+
+
+/*
+ * Modeles documents for supplier orders
+ */
+
+print_titre($langs->trans("OrdersModelModule"));
+
+// Defini tableau def de modele
+$def = array();
+
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = 'order_supplier'";
+$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 width="100">'.$langs->trans("Name").'</td>'."\n";
+print '<td>'.$langs->trans("Description").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
+print '<td align="center" width="40" colspan="2">'.$langs->trans("Info").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/supplier_order/pdf/");
+
+    if (is_dir($dir))
+    {
+        $var=true;
+
+        $handle=opendir($dir);
+
+
+        if (is_resource($handle))
+        {
+            while (($file = readdir($handle))!==false)
+            {
+                if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
+                {
+                    $name = substr($file, 4, dol_strlen($file) -16);
+                    $classname = substr($file, 0, dol_strlen($file) -12);
+
+                    $var=!$var;
+                    print "<tr ".$bc[$var].">\n";
+                    print "<td>".$name."</td>\n";
+                    print "<td>\n";
+                    require_once($dir.$file);
+                    $module = new $classname($db,$specimenthirdparty);
+                    print $module->description;
+                    print "</td>\n";
+
+                    // Active
+                    if (in_array($name, $def))
+                    {
+                        print '<td align="center">'."\n";
+                        if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF != "$name")
+                        {
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">';
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                            print '</a>';
+                        }
+                        else
+                        {
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                        }
+                        print "</td>";
+                    }
+                    else
+                    {
+                        print '<td align="center">'."\n";
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+                        print "</td>";
+                    }
+
+                    // Defaut
+                    print '<td align="center">';
+                    if ($conf->global->COMMANDE_SUPPLIER_ADDON_PDF == "$name")
+                    {
+                        print img_picto($langs->trans("Default"),'on');
+                    }
+                    else
+                    {
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=order_supplier"" 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"));
+                    $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);
+                    print '<td align="center">';
+                    print $form->textwithpicto('',$htmltooltip,1,0);
+                    print '</td>';
+                    print '<td align="center">';
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'order').'</a>';
+                    print '</td>';
+
+                    print "</tr>\n";
+                }
+            }
+
+            closedir($handle);
+        }
+    }
+}
+
+print '</table><br/>';
+
+/*
+ * Modeles documents for supplier invoices
+ */
+
+print_titre($langs->trans("BillsPDFModules"));
+
+// Defini tableau def de modele
+$def = array();
+
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = 'invoice_supplier'";
+$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 width="100">'.$langs->trans("Name").'</td>'."\n";
+print '<td>'.$langs->trans("Description").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>'."\n";
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>'."\n";
+print '<td align="center" width="40" colspan="2">'.$langs->trans("Info").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/supplier_invoice/pdf/");
+
+    if (is_dir($dir))
+    {
+        $var=true;
+
+        $handle=opendir($dir);
+
+        if (is_resource($handle))
+        {
+            while (($file = readdir($handle)) !== false)
+            {
+                if (preg_match('/\.modules\.php$/i',$file) && substr($file,0,4) == 'pdf_')
+                {
+                    $name = substr($file, 4, dol_strlen($file) -16);
+                    $classname = substr($file, 0, dol_strlen($file) -12);
+
+                    $var=!$var;
+                    print "<tr ".$bc[$var].">\n";
+                    print "<td>".$name."</td>\n";
+                    print "<td>";
+                    require_once($dir.$file);
+                    $module = new $classname($db,$specimenthirdparty);
+                    print $module->description;
+                    print "</td>\n";
+
+                    // Active
+                    if (in_array($name, $def))
+                    {
+                        print "<td align=\"center\">\n";
+                        if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF != "$name")
+                        {
+                            print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">';
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                            print '</a>';
+                        }
+                        else
+                        {
+                            print img_picto($langs->trans("Enabled"),'switch_on');
+                        }
+                        print "</td>";
+                    }
+                    else
+                    {
+                        print "<td align=\"center\">\n";
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+                        print "</td>";
+                    }
+
+                    // Defaut
+                    print "<td align=\"center\">";
+                    if ($conf->global->INVOICE_SUPPLIER_ADDON_PDF == "$name")
+                    {
+                        print img_picto($langs->trans("Default"),'on');
+                    }
+                    else
+                    {
+                        print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=invoice_supplier" 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"));
+                    $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);
+                    print '<td align="center">';
+                    print $form->textwithpicto('',$htmltooltip,1,0);
+                    print '</td>';
+                    print '<td align="center">';
+                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimenfacture&amp;module='.$name.'">'.img_object($langs->trans("Preview"),'bill').'</a>';
+                    print '</td>';
+
+                    print "</tr>\n";
+                }
+            }
+            closedir($handle);
+        }
+    }
+}
+
+print '</table><br/>';
+
+print_titre($langs->trans("OtherOptions"));
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print '<td width="80">&nbsp;</td>';
+print "</tr>\n";
+
+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_SUPPLIER_INVOICE_FREE_TEXT">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnInvoices").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="SUPPLIER_INVOICE_FREE_TEXT" class="flat" cols="120">'.$conf->global->SUPPLIER_INVOICE_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+llxFooter();
+?>

+ 155 - 0
dolicloudimages/dolibarr/src/htdocs/admin/geoipmaxmind.php

@@ -0,0 +1,155 @@
+<?php
+/* Copyright (C) 2009-2012	Laurent Destailleur	<eldy@users.sourceforge.org>
+ * Copyright (C) 2011	    Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/geoipmaxmind.php
+ *	\ingroup    geoipmaxmind
+ *	\brief      Setup page for geoipmaxmind module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/dolgeoip.class.php");
+
+// Security check
+if (!$user->admin)
+accessforbidden();
+
+$langs->load("admin");
+$langs->load("errors");
+
+$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+if ($action == 'set')
+{
+	$error=0;
+
+	$gimcdf= GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE");
+
+	if (! $gimcdf && ! file_exists($gimcdf))
+	{
+		$mesg='<div class="error">'.$langs->trans("ErrorFileNotFound",$gimcdf).'</div>';
+		$error++;
+	}
+
+	if (! $error)
+	{
+		$res = dolibarr_set_const($db,"GEOIPMAXMIND_COUNTRY_DATAFILE",$gimcdf,'chaine',0,'',$conf->entity);
+		if (! $res > 0) $error++;
+
+		if (! $error)
+	    {
+	        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+	    }
+	    else
+	    {
+	        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+	    }
+	}
+}
+
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+llxHeader();
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("GeoIPMaxmindSetup"),$linkback,'setup');
+print '<br>';
+
+$version='';
+$geoip='';
+if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE))
+{
+	$geoip=new DolGeoIP('country',$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE);
+}
+
+// Mode
+$var=true;
+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">';
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
+print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+print "</tr>\n";
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").'</td>';
+print '<td colspan="2">';
+print '<input size="50" type="text" name="GEOIPMAXMIND_COUNTRY_DATAFILE" value="'.$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE.'">';
+if ($geoip) $version=$geoip->getVersion();
+if ($version)
+{
+	print '<br>'.$langs->trans("Version").': '.$version;
+}
+print '</td></tr>';
+
+print '</table>';
+
+print "</form>\n";
+
+print '<br>';
+
+print $langs->trans("NoteOnPathLocation").'<br>';
+
+$url1='http://www.maxmind.com/app/perl?rId=awstats';
+print $langs->trans("YouCanDownloadFreeDatFileTo",'<a href="'.$url1.'" target="_blank">'.$url1.'</a>');
+
+print '<br>';
+
+$url2='http://www.maxmind.com/app/perl?rId=awstats';
+print $langs->trans("YouCanDownloadAdvancedDatFileTo",'<a href="'.$url2.'" target="_blank">'.$url2.'</a>');
+
+if ($geoip)
+{
+	print '<br><br>';
+	print '<br>'.$langs->trans("TestGeoIPResult",$ip).':';
+
+	$ip='24.24.24.24';
+	print '<br>'.$ip.' -> ';
+	$result=dol_print_ip($ip,1);
+	if ($result) print $result;
+	else print $langs->trans("Error");
+
+	/* We disable this test because dol_print_ip need an ip as input
+	$ip='www.google.com';
+	print '<br>'.$ip.' -> ';
+	$result=dol_print_ip($ip,1);
+	if ($result) print $result;
+	else print $langs->trans("Error");
+	*/
+	$geoip->close();
+}
+
+dol_htmloutput_mesg($mesg);
+
+llxFooter();
+
+$db->close();
+?>

+ 408 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ihm.php

@@ -0,0 +1,408 @@
+<?php
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/admin/ihm.php
+ *       \brief      Page to setup GUI display options
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/usergroups.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+
+$langs->load("admin");
+$langs->load("languages");
+$langs->load("other");
+
+$langs->load("companies");
+$langs->load("products");
+$langs->load("members");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action');
+
+
+if (! defined("MAIN_MOTD")) define("MAIN_MOTD","");
+
+// List of supported permanent search area
+$searchform=array("MAIN_SEARCHFORM_SOCIETE","MAIN_SEARCHFORM_CONTACT", "MAIN_SEARCHFORM_PRODUITSERVICE","MAIN_SEARCHFORM_ADHERENT");
+$searchformconst=array($conf->global->MAIN_SEARCHFORM_SOCIETE,$conf->global->MAIN_SEARCHFORM_CONTACT,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE,$conf->global->MAIN_SEARCHFORM_ADHERENT);
+$searchformtitle=array($langs->trans("Companies"),$langs->trans("Contacts"),$langs->trans("ProductsAndServices"),$langs->trans("Members"));
+$searchformmodule=array('Module1Name','Module1Name','Module50Name','Module310Name');
+
+
+if ($action == 'update')
+{
+	dolibarr_set_const($db, "MAIN_LANG_DEFAULT",       $_POST["main_lang_default"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_MULTILANGS",         $_POST["main_multilangs"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT",   $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS",   $_POST["main_use_preview_tabs"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_START_WEEK",         $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_SHOW_LOGO",          $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION",          $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
+
+	dolibarr_set_const($db, "MAIN_THEME",              $_POST["main_theme"],'chaine',0,'',$conf->entity);
+
+	dolibarr_set_const($db, "MAIN_SEARCHFORM_CONTACT", $_POST["MAIN_SEARCHFORM_CONTACT"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_SEARCHFORM_SOCIETE", $_POST["MAIN_SEARCHFORM_SOCIETE"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_SEARCHFORM_PRODUITSERVICE",$_POST["MAIN_SEARCHFORM_PRODUITSERVICE"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_SEARCHFORM_ADHERENT",$_POST["MAIN_SEARCHFORM_ADHERENT"],'chaine',0,'',$conf->entity);
+
+	dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0);	// Param for all entities
+	dolibarr_set_const($db, "MAIN_MOTD",                   dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_HOME",                   dol_htmlcleanlastbr($_POST["main_home"]),'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_HELP_DISABLELINK",       $_POST["MAIN_HELP_DISABLELINK"],'chaine',0,'',0);	    // Param for all entities
+	dolibarr_set_const($db, "MAIN_BUGTRACK_ENABLELINK",    $_POST["MAIN_BUGTRACK_ENABLELINK"],'chaine',0,'',$conf->entity);
+
+	$_SESSION["mainmenu"]="";   // Le gestionnaire de menu a pu changer
+
+	Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
+	exit;
+}
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+$form=new Form($db);
+$formother=new FormOther($db);
+$formadmin=new FormAdmin($db);
+
+print_fiche_titre($langs->trans("GUISetup"),'','setup');
+
+print $langs->trans("DisplayDesc")."<br>\n";
+print "<br>\n";
+
+
+if ($action == 'edit')	// Edit
+{
+    //WYSIWYG Editor
+    require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
+
+    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+
+    clearstatcache();
+    $var=true;
+
+    print_fiche_titre($langs->trans("Language"),'','').'<br>';
+    print '<table summary="edit" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Default language
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
+    print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,'main_lang_default',1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	// Multilangual GUI
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>';
+    print $form->selectyesno('main_multilangs',$conf->global->MAIN_MULTILANGS,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	print '</table><br>'."\n";
+
+    // Themes
+    show_theme('',1);
+    print '<br>';
+
+    // Liste des zone de recherche permanantes supportees
+    print '<table summary="search" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td width="35%">'.$langs->trans("PermanentLeftSearchForm").'</td><td colspan="2">'.$langs->trans("Activated").'</td></tr>';
+    $var=True;
+    foreach ($searchform as $key => $value)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$searchformtitle[$key].'</td><td colspan="2">';
+        print $form->selectyesno($searchform[$key],$searchformconst[$key],1);
+        print '</td></tr>';
+    }
+    print '</table>';
+    print '<br>';
+
+    // Other
+    print '<table summary="edit" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	// Show logo
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableShowLogo").'</td><td>';
+    print $form->selectyesno('MAIN_SHOW_LOGO',$conf->global->MAIN_SHOW_LOGO,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	// Taille max des listes
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeList").'</td><td><input class="flat" name="main_size_liste_limit" size="4" value="' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '"></td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Desactivation javascript et ajax
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableJavascript").'</td><td>';
+    print $form->selectyesno('main_disable_javascript',isset($conf->global->MAIN_DISABLE_JAVASCRIPT)?$conf->global->MAIN_DISABLE_JAVASCRIPT:0,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Activate preview tab on element card
+    if (class_exists("Imagick"))
+	{
+	    $var=!$var;
+	    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
+	    print $form->selectyesno('main_use_preview_tabs',isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0,1);
+	    print '</td>';
+		print '<td width="20">&nbsp;</td>';
+		print '</tr>';
+	}
+
+    // First day for weeks
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
+    print $formother->select_dayofweek((isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'),'MAIN_START_WEEK',0);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Firstname/Name
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
+	$array=array(0=>$langs->trans("Firstname").' '.$langs->trans("Lastname"),1=>$langs->trans("Lastname").' '.$langs->trans("Firstname"));
+    print $form->selectarray('MAIN_FIRSTNAME_NAME_POSITION',$array,(isset($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?$conf->global->MAIN_FIRSTNAME_NAME_POSITION:0));
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Hide helpcenter link on login page
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td>';
+    print $form->selectyesno('MAIN_HELPCENTER_DISABLELINK',isset($conf->global->MAIN_HELPCENTER_DISABLELINK)?$conf->global->MAIN_HELPCENTER_DISABLELINK:0,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	// Hide wiki link on login page
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td>';
+    print $form->selectyesno('MAIN_HELP_DISABLELINK',isset($conf->global->MAIN_HELP_DISABLELINK)?$conf->global->MAIN_HELP_DISABLELINK:0,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Message on login page
+	$var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
+	
+	$doleditor = new DolEditor('main_home', $conf->global->MAIN_HOME, '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90);
+	$doleditor->Create();
+
+	print '</td></tr>'."\n";
+
+	// Message of the day on home page
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
+	
+	$doleditor = new DolEditor('main_motd', $conf->global->MAIN_MOTD, '', 142, 'dolibarr_notes', 'In', false, true, true, ROWS_4, 90);
+	$doleditor->Create();
+
+	print '</td></tr>'."\n";
+
+	/*
+	// Show bugtrack link
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("ShowBugTrackLink").'</td><td>';
+    print $form->selectyesno('main_show_bugtrack_link',$conf->global->MAIN_BUGTRACK_ENABLELINK,1);
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+	*/
+
+	print '</table>'."\n";
+
+
+    print '<br><center>';
+    print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
+    print '</center>';
+
+    print '</form>';
+    print '<br>';
+}
+else	// Show
+{
+    $var=true;
+
+    // Language
+    print_fiche_titre($langs->trans("Language"),'','').'<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td><td>&nbsp;</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DefaultLanguage").'</td><td>';
+    $s=picto_from_langcode($conf->global->MAIN_LANG_DEFAULT);
+    print ($s?$s.' ':'');
+    print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
+    print '</td>';
+	print '<td width="20">';
+    if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation",$conf->global->MAIN_LANG_DEFAULT),1);
+	print '</td>';
+	print "</tr>";
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("EnableMultilangInterface").'</td><td>' . yn($conf->global->MAIN_MULTILANGS) . '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+
+	print '</table><br>'."\n";
+
+
+	// Themes
+    show_theme('',0);
+    print '<br>';
+
+
+    // Liste des zone de recherches permanentes supportees
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td width="35%">'.$langs->trans("PermanentLeftSearchForm").'</td><td>'.$langs->trans("Activated").'</td><td>&nbsp;</td></tr>';
+    $var=true;
+    foreach ($searchform as $key => $value)
+    {
+        $var=!$var;
+        print '<tr '.$bc[$var].'><td width="35%">'.$searchformtitle[$key].'</td><td>'.yn($searchformconst[$key]).'</td>';
+		print '<td align="left">'.$langs->trans("IfModuleEnabled",$langs->transnoentitiesnoconv($searchformmodule[$key]));
+        print '</td></tr>';
+    }
+    print '</table>';
+    print '<br>';
+
+
+    // Other
+    $var=true;
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Parameter").'</td><td colspan="2">'.$langs->trans("Value").'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("EnableShowLogo").'</td><td>' . yn($conf->global->MAIN_SHOW_LOGO) . '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+
+	$var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMaxSizeList").'</td><td>' . $conf->global->MAIN_SIZE_LISTE_LIMIT . '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+
+    // Disable javascript/ajax
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableJavascript").'</td><td>';
+    print yn($conf->global->MAIN_DISABLE_JAVASCRIPT)."</td>";
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+
+    // Activate preview tab on element card
+    if (class_exists("Imagick"))
+	{
+		$var=!$var;
+	    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("UsePreviewTabs").'</td><td>';
+	    print yn(isset($conf->global->MAIN_USE_PREVIEW_TABS)?$conf->global->MAIN_USE_PREVIEW_TABS:0)."</td>";
+		print '<td width="20">&nbsp;</td>';
+		print "</tr>";
+	}
+
+	// First day for weeks
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("WeekStartOnDay").'</td><td>';
+    print $langs->trans("Day".(isset($conf->global->MAIN_START_WEEK)?$conf->global->MAIN_START_WEEK:'1'));
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+	// Firstname / Name position
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("FirstnameNamePosition").'</td><td>';
+    if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print $langs->trans("Firstname").' '.$langs->trans("Lastname"); }
+    else { print $langs->trans("Lastname").' '.$langs->trans("Firstname"); }
+    print '</td>';
+	print '<td width="20">&nbsp;</td>';
+	print '</tr>';
+
+    // Link to help center
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelpCenter").'</td><td colspan="2">';
+    print yn($conf->global->MAIN_HELPCENTER_DISABLELINK,1);
+    print '</td></tr>';
+
+    // Link to wiki help
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("DisableLinkToHelp",img_picto('',DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/helpdoc.png','',1)).'</td><td colspan="2">';
+    print yn($conf->global->MAIN_HELP_DISABLELINK,1);
+    print '</td></tr>';
+
+    // Message login
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageLogin").'</td><td colspan="2">';
+    print dol_htmlcleanlastbr($conf->global->MAIN_HOME);
+    print '</td></tr>'."\n";
+
+    // Message of the day
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td width="35%">'.$langs->trans("MessageOfDay").'</td><td colspan="2">';
+    print dol_htmlcleanlastbr($conf->global->MAIN_MOTD);
+    print '</td></tr>'."\n";
+
+    /*
+    // Show bugtrack link
+	$var=!$var;
+    print '<tr '.$bc[$var].'"><td width="35%">'.$langs->trans("ShowBugTrackLink").'</td><td>';
+    print yn($conf->global->MAIN_BUGTRACK_ENABLELINK)."</td>";
+	print '<td width="20">&nbsp;</td>';
+	print "</tr>";
+	*/
+
+    print '</table>'."\n";
+
+    print '<div class="tabsAction">';
+    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+    print '</div>';
+	print '<br>';
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 86 - 0
dolicloudimages/dolibarr/src/htdocs/admin/index.php

@@ -0,0 +1,86 @@
+<?php
+/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/index.php
+ *		\brief      Page d'accueil de l'espace administration/configuration
+ */
+
+require("../main.inc.php");
+
+$langs->load("admin");
+$langs->load("companies");
+
+if (!$user->admin) accessforbidden();
+
+$mesg='';
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+$form = new Form($db);
+
+
+print_fiche_titre($langs->trans("SetupArea"),'','setup');
+
+if ($mesg) print $mesg.'<br>';
+
+print $langs->trans("SetupDescription1").' ';
+print $langs->trans("AreaForAdminOnly").' ';
+
+
+//print "<br>";
+//print "<br>";
+print $langs->trans("SetupDescription2")."<br><br>";
+
+print "<br>";
+print "<br>";
+//print '<hr style="color: #DDDDDD;">';
+print img_picto('','puce').' '.$langs->trans("SetupDescription3")."<br>";
+print '<br>';
+print "<br>";
+//print '<hr style="color: #DDDDDD;">';
+print img_picto('','puce').' '.$langs->trans("SetupDescription4")."<br>";
+print "<br>";
+print '<br>';
+//print '<hr style="color: #DDDDDD;">';
+print $langs->trans("SetupDescription5")."<br>";
+//print '<hr style="color: #DDDDDD;">';
+print "<br>";
+
+/*
+print '<table width="100%">';
+print '<tr '.$bc[false].'><td '.$bc[false].'>'.img_picto('','puce').' '.$langs->trans("SetupDescription3")."</td></tr>";
+print '<tr '.$bc[true].'><td '.$bc[true].'>'.img_picto('','puce').' '.$langs->trans("SetupDescription4")."</td></tr>";
+print '<tr '.$bc[false].'><td '.$bc[false].'>'.img_picto('','puce').' '.$langs->trans("SetupDescription5")."</td></tr>";
+print '</table>';
+*/
+
+//print '<br>';
+//print info_admin($langs->trans("OnceSetupFinishedCreateUsers")).'<br>';
+
+
+$db->close();
+
+llxFooter();
+?>

+ 330 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ldap.php

@@ -0,0 +1,330 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/ldap.php
+ *      \ingroup    ldap
+ *      \brief      Page d'administration/configuration du module Ldap
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+
+$langs->load("admin");
+
+if (!$user->admin)
+  accessforbidden();
+
+  $action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$error=0;
+
+	$db->begin();
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',GETPOST("type"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',GETPOST("LDAP_SERVER_PROTOCOLVERSION"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',GETPOST("host"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',GETPOST("slave"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',GETPOST("port"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',GETPOST("dn"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',GETPOST("admin"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',GETPOST("pass"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',GETPOST("usetls"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',GETPOST("activesynchro"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',GETPOST("activecontact"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',GETPOST("activemembers"),'chaine',0,'',$conf->entity)) $error++;
+
+	if (! $error)
+  	{
+  		$db->commit();
+  		$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+  	}
+  	else
+  	{
+  		$db->rollback();
+		dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'setup');
+
+$head = ldap_prepare_head();
+
+// Test si fonction LDAP actives
+if (! function_exists("ldap_connect"))
+{
+	$mesg.='<div class="error">'.$langs->trans("LDAPFunctionsNotAvailableOnPHP").'</div>';  ;
+}
+
+dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup"));
+
+$var=true;
+$form=new Form($db);
+
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+print '<table class="noborder" width="100%">';
+
+// Liste de synchro actives
+print '<tr class="liste_titre">';
+print '<td colspan="3">'.$langs->trans("LDAPSynchronization").'</td>';
+print "</tr>\n";
+
+// Synchro utilisateurs/groupes active
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPDnSynchroActive").'</td><td>';
+$arraylist=array();
+$arraylist['0']=$langs->trans("No");
+$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr");
+$arraylist['dolibarr2ldap']=$langs->trans("DolibarrToLDAP");
+print $form->selectarray('activesynchro',$arraylist,$conf->global->LDAP_SYNCHRO_ACTIVE);
+print '</td><td>'.$langs->trans("LDAPDnSynchroActiveExample");
+if ($conf->global->LDAP_SYNCHRO_ACTIVE && ! $conf->global->LDAP_USER_DN)
+{
+	print '<br><font class="error">'.$langs->trans("LDAPSetupNotComplete").'</font>';
+}
+print '</td></tr>';
+
+// Synchro contact active
+if ($conf->societe->enabled)
+{
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
+	$arraylist=array();
+	$arraylist['0']=$langs->trans("No");
+	$arraylist['1']=$langs->trans("DolibarrToLDAP");
+	print $form->selectarray('activecontact',$arraylist,$conf->global->LDAP_CONTACT_ACTIVE);
+	print '</td><td>'.$langs->trans("LDAPDnContactActiveExample").'</td></tr>';
+}
+
+// Synchro adherentt active
+if ($conf->adherent->enabled)
+{
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPDnMemberActive").'</td><td>';
+	$arraylist=array();
+	$arraylist['0']=$langs->trans("No");
+	$arraylist['1']=$langs->trans("DolibarrToLDAP");
+	print $form->selectarray('activemembers',$arraylist,$conf->global->LDAP_MEMBER_ACTIVE);
+	print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
+}
+
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print '<td>'.$langs->trans("Example").'</td>';
+print "</tr>\n";
+
+// Type
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("Type").'</td><td>';
+$arraylist=array();
+$arraylist['activedirectory']='Active Directory';
+$arraylist['openldap']='OpenLdap';
+$arraylist['egroupware']='Egroupware';
+print $form->selectarray('type',$arraylist,$conf->global->LDAP_SERVER_TYPE);
+print '</td><td>&nbsp;</td></tr>';
+
+// Version
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("Version").'</td><td>';
+$arraylist=array();
+$arraylist['3']='Version 3';
+$arraylist['2']='Version 2';
+print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION',$arraylist,$conf->global->LDAP_SERVER_PROTOCOLVERSION);
+print '</td><td>'.$langs->trans("LDAPServerProtocolVersion").'</td></tr>';
+
+// Serveur primaire
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("LDAPPrimaryServer").'</td><td>';
+print '<input size="25" type="text" name="host" value="'.$conf->global->LDAP_SERVER_HOST.'">';
+print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
+
+// Serveur secondaire
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("LDAPSecondaryServer").'</td><td>';
+print '<input size="25" type="text" name="slave" value="'.$conf->global->LDAP_SERVER_HOST_SLAVE.'">';
+print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
+
+// Port
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerPort").'</td><td>';
+if ($conf->global->LDAP_SERVER_PORT)
+{
+  print '<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">';
+}
+else
+{
+  print '<input size="25" type="text" name="port" value="389">';
+}
+print '</td><td>'.$langs->trans("LDAPServerPortExample").'</td></tr>';
+
+// DNserver
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerDn").'</td><td>';
+print '<input size="25" type="text" name="dn" value="'.$conf->global->LDAP_SERVER_DN.'">';
+print '</td><td>'.$langs->trans("LDAPServerDnExample").'</td></tr>';
+
+// Utiliser TLS
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerUseTLS").'</td><td>';
+$arraylist=array();
+$arraylist['0']=$langs->trans("No");
+$arraylist['1']=$langs->trans("Yes");
+print $form->selectarray('usetls',$arraylist,$conf->global->LDAP_SERVER_USE_TLS);
+print '</td><td>'.$langs->trans("LDAPServerUseTLSExample").'</td></tr>';
+
+print '<tr class="liste_titre">';
+print '<td colspan="3">'.$langs->trans("ForANonAnonymousAccess").'</td>';
+print "</tr>\n";
+
+// DNAdmin
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPAdminDn").'</td><td>';
+print '<input size="25" type="text" name="admin" value="'.$conf->global->LDAP_ADMIN_DN.'">';
+print '</td><td>'.$langs->trans("LDAPAdminDnExample").'</td></tr>';
+
+// Pass
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPPassword").'</td><td>';
+if ($conf->global->LDAP_ADMIN_PASS)
+{
+	print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';// je le met en visible pour test
+}
+else
+{
+	print '<input size="25" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';
+}
+print '</td><td>secret</td></tr>';
+
+print '</table>';
+
+print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
+
+print '</form>';
+
+print '</div>';
+
+
+
+/*
+ * Test de la connexion
+ */
+if (function_exists("ldap_connect"))
+{
+	if ($conf->global->LDAP_SERVER_HOST)
+	{
+		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test">'.$langs->trans("LDAPTestConnect").'</a><br><br>';
+	}
+
+	if ($_GET["action"] == 'test')
+	{
+		$ldap = new Ldap();	// Les parametres sont passes et recuperes via $conf
+
+		$result = $ldap->connect_bind();
+		if ($result)
+		{
+			// Test ldap connect and bind
+			print img_picto('','info').' ';
+			print '<font class="ok">'.$langs->trans("LDAPTCPConnectOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).'</font>';
+			print '<br>';
+
+			if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
+			{
+				if ($result == 2)
+				{
+					print img_picto('','info').' ';
+					print '<font class="ok">'.$langs->trans("LDAPBindOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)).'</font>';
+					print '<br>';
+				}
+				else
+				{
+					print img_picto('','error').' ';
+					print '<font class="error">'.$langs->trans("LDAPBindKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)).'</font>';
+					print '<br>';
+					print $langs->trans("Error").' '.$ldap->error;
+					print '<br>';
+				}
+			}
+			else
+			{
+				print img_picto('','warning').' ';
+				print '<font class="warning">'.$langs->trans("LDAPNoUserOrPasswordProvidedAccessIsReadOnly").'</font>';
+				print '<br>';
+			}
+
+
+			// Test ldap_getversion
+			if (($ldap->getVersion() == 3))
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSetupForVersion3").'</font>';
+				print '<br>';
+			}
+			else
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSetupForVersion2").'</font>';
+				print '<br>';
+			}
+
+			$unbind = $ldap->unbind();
+		}
+		else
+		{
+			print img_picto('','error').' ';
+			print '<font class="error">'.$langs->trans("LDAPTCPConnectKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).'</font>';
+			print '<br>';
+			print $langs->trans("Error").' '.$ldap->error;
+			print '<br>';
+		}
+
+	}
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 337 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ldap_contacts.php

@@ -0,0 +1,337 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * 	\file       htdocs/admin/ldap_contacts.php
+ *  \ingroup    ldap
+ *  \brief      Page d'administration/configuration du module Ldap
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php");
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (!$user->admin)
+  accessforbidden();
+
+$action = GETPOST("action");
+  
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$error=0;
+
+	$db->begin();
+	
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',GETPOST("contactdn"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
+
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME',GETPOST("fieldname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME',GETPOST("fieldfirstname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY',GETPOST("fieldcompany"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE',GETPOST("fieldhomephone"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY',GETPOST("fieldcountry"),'chaine',0,'',$conf->entity)) $error++;
+
+    // This one must be after the others
+    $valkey='';
+    $key=GETPOST("key");
+    if ($key) $valkey=$conf->global->$key;
+    if (! dolibarr_set_const($db, 'LDAP_KEY_CONTACTS',$valkey,'chaine',0,'',$conf->entity)) $error++;
+
+	if (! $error)
+  	{
+  		$db->commit();
+  		$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+  	}
+  	else
+  	{
+  		$db->rollback();
+		dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * Visu
+ */
+
+llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'setup');
+
+$head = ldap_prepare_head();
+
+// Test si fonction LDAP actives
+if (! function_exists("ldap_connect"))
+{
+	$mesg.='<div class="error">'.$langs->trans("LDAPFunctionsNotAvailableOnPHP").'</div>';  ;
+}
+
+dol_fiche_head($head, 'contacts', $langs->trans("LDAPSetup"));
+
+
+print $langs->trans("LDAPDescContact").'<br>';
+print '<br>';
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+$form=new Form($db);
+
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td colspan="4">'.$langs->trans("LDAPSynchronizeContacts").'</td>';
+print "</tr>\n";
+
+
+// DN Pour les contacts
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPContactDn").'</span></td><td>';
+print '<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
+print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// List of object class used to define attributes in structure
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPContactObjectClassList").'</span></td><td>';
+print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_CONTACT_OBJECT_CLASS.'">';
+print '</td><td>'.$langs->trans("LDAPContactObjectClassListExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+print '</table>';
+print '<br>';
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
+print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
+print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
+print "</tr>\n";
+
+// Common name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
+print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_CONTACT_FIELD_FULLNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FULLNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FULLNAME?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
+print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_CONTACT_FIELD_NAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_NAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_NAME?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Firstname
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
+print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FIRSTNAME"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FIRSTNAME?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Company
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldCompany").'</td><td>';
+print '<input size="25" type="text" name="fieldcompany" value="'.$conf->global->LDAP_CONTACT_FIELD_COMPANY.'">';
+print '</td><td>'.$langs->trans("LDAPFieldCompanyExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COMPANY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COMPANY?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Mail
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
+print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_CONTACT_FIELD_MAIL.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value=">LDAP_CONTACT_FIELD_MAIL"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MAIL?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Phone pro
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
+print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_CONTACT_FIELD_PHONE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_PHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_PHONE?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Phone home
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
+print '<input size="25" type="text" name="fieldhomephone" value="'.$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_HOMEPHONE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_HOMEPHONE?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Mobile
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
+print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_CONTACT_FIELD_MOBILE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_MOBILE"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_MOBILE?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Fax
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
+print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_CONTACT_FIELD_FAX.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_FAX"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_FAX?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Address
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
+print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_CONTACT_FIELD_ADDRESS.'">';
+print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ADDRESS"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ADDRESS?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// CP
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
+print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_CONTACT_FIELD_ZIP.'">';
+print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_ZIP"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_ZIP?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Ville
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
+print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_CONTACT_FIELD_TOWN.'">';
+print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_TOWN"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_TOWN?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Pays
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
+print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_CONTACT_FIELD_COUNTRY.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_CONTACT_FIELD_COUNTRY"'.($conf->global->LDAP_KEY_CONTACTS && $conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_CONTACT_FIELD_COUNTRY?' checked="checked"':'')."></td>";
+print '</tr>';
+
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table>';
+
+print '</form>';
+
+print '</div>';
+
+print info_admin($langs->trans("LDAPDescValues"));
+
+/*
+ * Test de la connexion
+ */
+$butlabel=$langs->trans("LDAPTestSynchroContact");
+$testlabel='test';
+$key=$conf->global->LDAP_KEY_CONTACTS;
+$dn=$conf->global->LDAP_CONTACT_DN;
+$objectclass=$conf->global->LDAP_CONTACT_OBJECT_CLASS;
+
+show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
+
+
+if (function_exists("ldap_connect"))
+{
+	if ($_GET["action"] == 'test')
+	{
+		// Creation objet
+		$object=new Contact($db);
+		$object->initAsSpecimen();
+
+		// Test synchro
+		$ldap=new Ldap();
+		$result=$ldap->connect_bind();
+
+		if ($result > 0)
+		{
+			$info=$object->_load_ldap_info();
+			$dn=$object->_load_ldap_dn($info);
+
+			$result1=$ldap->delete($dn);			// To be sure to delete existing records
+			$result2=$ldap->add($dn,$info,$user);	// Now the test
+			$result3=$ldap->delete($dn);			// Clean what we did
+
+			if ($result2 > 0)
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
+			}
+			else
+			{
+				print img_picto('','error').' ';
+				print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
+				print ': '.$ldap->error;
+				print '</font><br>';
+				print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+			}
+
+			print "<br>\n";
+			print "LDAP input file used for test:<br><br>\n";
+			print nl2br($ldap->dump_content($dn,$info));
+			print "\n<br>";
+		}
+		else
+		{
+			print img_picto('','error').' ';
+			print '<font class="error">'.$langs->trans("LDAPSynchroKO");
+			print ': '.$ldap->error;
+			print '</font><br>';
+			print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+		}
+	}
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+
+?>

+ 261 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ldap_groups.php

@@ -0,0 +1,261 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *     	\file       htdocs/admin/ldap_groups.php
+ *     	\ingroup    ldap
+ *		\brief      Page to setup LDAP synchronization for groups
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
+require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (!$user->admin)
+  accessforbidden();
+  
+$action = GETPOST("action");
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$error=0;
+	$db->begin();
+	
+	if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',GETPOST("group"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
+
+	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
+	//if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS',GETPOST("fieldgroupmembers"),'chaine',0,'',$conf->entity)) $error++;
+
+	// This one must be after the others
+    $valkey='';
+    $key=GETPOST("key");
+    if ($key) $valkey=$conf->global->$key;
+    if (! dolibarr_set_const($db, 'LDAP_KEY_GROUPS',$valkey,'chaine',0,'',$conf->entity)) $error++;
+
+	if (! $error)
+  	{
+  		$db->commit();
+  		$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+  	}
+  	else
+  	{
+  		$db->rollback();
+		dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'setup');
+
+$head = ldap_prepare_head();
+
+// Test si fonction LDAP actives
+if (! function_exists("ldap_connect"))
+{
+	$mesg.='<div class="error">'.$langs->trans("LDAPFunctionsNotAvailableOnPHP").'</div>';  ;
+}
+
+dol_fiche_head($head, 'groups', $langs->trans("LDAPSetup"));
+
+
+print $langs->trans("LDAPDescGroups").'<br>';
+print '<br>';
+
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+$form=new Form($db);
+
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td colspan="4">'.$langs->trans("LDAPSynchronizeGroups").'</td>';
+print "</tr>\n";
+
+// DN pour les groupes
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPGroupDn").'</span></td><td>';
+print '<input size="48" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">';
+print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// List of object class used to define attributes in structure
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPGroupObjectClassList").'</span></td><td>';
+print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_GROUP_OBJECT_CLASS.'">';
+print '</td><td>'.$langs->trans("LDAPGroupObjectClassListExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+print '</table>';
+print '<br>';
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
+print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
+print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
+print "</tr>\n";
+
+// Filtre
+
+// Common name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
+print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_GROUP_FIELD_FULLNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldCommonNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_FULLNAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Name
+/*$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
+print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_GROUP_FIELD_NAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_GROUP_FIELD_NAME.'"'.($conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_NAME?' checked="checked"':'')."></td>";
+print '</tr>';
+*/
+
+// Description
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
+print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_GROUP_FIELD_DESCRIPTION.'">';
+print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_DESCRIPTION)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// User group
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldGroupMembers").'</td><td>';
+print '<input size="25" type="text" name="fieldgroupmembers" value="'.$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS.'">';
+print '</td><td>'.$langs->trans("LDAPFieldGroupMembersExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_GROUP_FIELD_GROUPMEMBERS"'.(($conf->global->LDAP_KEY_GROUPS && $conf->global->LDAP_KEY_GROUPS==$conf->global->LDAP_GROUP_FIELD_GROUPMEMBERS)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table>';
+
+print '</form>';
+
+print '</div>';
+
+print info_admin($langs->trans("LDAPDescValues"));
+
+/*
+ * Test de la connexion
+ */
+if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
+{
+	$butlabel=$langs->trans("LDAPTestSynchroGroup");
+	$testlabel='testgroup';
+	$key=$conf->global->LDAP_KEY_GROUPS;
+	$dn=$conf->global->LDAP_GROUP_DN;
+	$objectclass=$conf->global->LDAP_GROUP_OBJECT_CLASS;
+
+	show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
+}
+
+if (function_exists("ldap_connect"))
+{
+	if ($_GET["action"] == 'testgroup')
+	{
+		// Creation objet
+		$object=new UserGroup($db);
+		$object->initAsSpecimen();
+
+		// Test synchro
+		$ldap=new Ldap();
+		$result=$ldap->connect_bind();
+
+		if ($result > 0)
+		{
+			$info=$object->_load_ldap_info();
+			$dn=$object->_load_ldap_dn($info);
+
+			$result1=$ldap->delete($dn);			// To be sure to delete existing records
+			$result2=$ldap->add($dn,$info,$user);	// Now the test
+			$result3=$ldap->delete($dn);			// Clean what we did
+
+			if ($result2 > 0)
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
+			}
+			else
+			{
+				print img_picto('','error').' ';
+				print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
+				print ': '.$ldap->error;
+				print '</font><br>';
+				print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+			}
+
+			print "<br>\n";
+			print "LDAP input file used for test:<br><br>\n";
+			print nl2br($ldap->dump_content($dn,$info));
+			print "\n<br>";
+		}
+		else
+		{
+			print img_picto('','error').' ';
+			print '<font class="error">'.$langs->trans("LDAPSynchroKO");
+			print ': '.$ldap->error;
+			print '</font><br>';
+			print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+		}
+	}
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 444 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ldap_members.php

@@ -0,0 +1,444 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/ldap_members.php
+ *		\ingroup    ldap member
+ *		\brief      Page d'administration/configuration du module Ldap adherent
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php");
+require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (!$user->admin)
+  accessforbidden();
+
+$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$error=0;
+
+	$db->begin();
+	
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',GETPOST("user"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
+	// Members
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN',GETPOST("fieldlogin"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA',GETPOST("fieldloginsamba"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD',GETPOST("fieldpassword"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED',GETPOST("fieldpasswordcrypted"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME',GETPOST("fieldname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME',GETPOST("fieldfirstname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO',GETPOST("fieldphoneperso"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS',GETPOST("fieldaddress"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP',GETPOST("fieldzip"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN',GETPOST("fieldtown"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY',GETPOST("fieldcountry"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE',GETPOST("fieldbirthdate"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS',GETPOST("fieldstatus"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"),'chaine',0,'',$conf->entity)) $error++;
+
+	// Subscriptions
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE',  GETPOST("fieldfirstsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT',GETPOST("fieldfirstsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE',   GETPOST("fieldlastsubscriptiondate"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"),'chaine',0,'',$conf->entity)) $error++;
+
+    // This one must be after the others
+    $valkey='';
+    $key=GETPOST("key");
+    if ($key) $valkey=$conf->global->$key;
+    if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
+
+	if (! $error)
+  	{
+  		$db->commit();
+  		$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+  	}
+  	else
+  	{
+  		$db->rollback();
+		dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'setup');
+
+$head = ldap_prepare_head();
+
+// Test si fonction LDAP actives
+if (! function_exists("ldap_connect"))
+{
+	$mesg.='<div class="error">'.$langs->trans("LDAPFunctionsNotAvailableOnPHP").'</div>';  ;
+}
+
+dol_fiche_head($head, 'members', $langs->trans("LDAPSetup"));
+
+
+print $langs->trans("LDAPDescMembers").'<br>';
+print '<br>';
+
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+$form=new Form($db);
+
+print '<table class="noborder" width="100%">';
+$var=true;
+
+
+print '<tr class="liste_titre">';
+print '<td colspan="4">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
+print "</tr>\n";
+
+// DN Pour les adherents
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberDn").'</span></td><td>';
+print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
+print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// List of object class used to define attributes in structure
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPMemberObjectClassList").'</span></td><td>';
+print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_MEMBER_OBJECT_CLASS.'">';
+print '</td><td>'.$langs->trans("LDAPMemberObjectClassListExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+print '</table>';
+print '<br>';
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
+print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
+print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
+print "</tr>\n";
+
+// Filtre
+
+// Common name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
+print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_MEMBER_FIELD_FULLNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_FULLNAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
+print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_MEMBER_FIELD_NAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_NAME"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_NAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Firstname
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
+print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_MEMBER_FIELD_FIRSTNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Login unix
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
+print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN.'">';
+print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Login samba
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
+print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA.'">';
+print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_LOGIN_SAMBA)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Password not crypted
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
+print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Password crypted
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
+print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Mail
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
+print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_MEMBER_FIELD_MAIL.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_MEMBER_FIELD_MAIL"'.(($conf->global->LDAP_KEY_MEMBERS && $conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_MEMBER_FIELD_MAIL)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Phone pro
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
+print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Phone perso
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldHomePhone").'</td><td>';
+print '<input size="25" type="text" name="fieldphoneperso" value="'.$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO.'">';
+print '</td><td>'.$langs->trans("LDAPFieldHomePhoneExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Mobile
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
+print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_MEMBER_FIELD_MOBILE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Fax
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
+print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_MEMBER_FIELD_FAX.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Address
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
+print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_MEMBER_FIELD_ADDRESS.'">';
+print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// CP
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
+print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_MEMBER_FIELD_ZIP.'">';
+print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Ville
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
+print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_MEMBER_FIELD_TOWN.'">';
+print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Pays
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldCountry").'</td><td>';
+print '<input size="25" type="text" name="fieldcountry" value="'.$conf->global->LDAP_MEMBER_FIELD_COUNTRY.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Description
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
+print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_MEMBER_FIELD_DESCRIPTION.'">';
+print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Date naissance
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldBirthdate").'</td><td>';
+print '<input size="25" type="text" name="fieldbirthdate" value="'.$conf->global->LDAP_MEMBER_FIELD_BIRTHDATE.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Status
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldStatus").'</td><td>';
+print '<input size="25" type="text" name="fieldstatus" value="'.$conf->global->LDAP_FIELD_MEMBER_STATUS.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// First subscription date
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstSubscriptionDate").'</td><td>';
+print '<input size="25" type="text" name="fieldfirstsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// First subscription amount
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstSubscriptionAmount").'</td><td>';
+print '<input size="25" type="text" name="fieldfirstsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Last subscription date
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLastSubscriptionDate").'</td><td>';
+print '<input size="25" type="text" name="fieldlastsubscriptiondate" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// Last subscription amount
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLastSubscriptionAmount").'</td><td>';
+print '<input size="25" type="text" name="fieldlastsubscriptionamount" value="'.$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+// End last subscriptions
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldEndLastSubscription").'</td><td>';
+print '<input size="25" type="text" name="fieldendlastsubscription" value="'.$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION.'">';
+print '</td><td>&nbsp;</td>';
+print '<td align="right">&nbsp;</td>';
+print '</tr>';
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table>';
+
+print '</form>';
+
+print '</div>';
+
+print info_admin($langs->trans("LDAPDescValues"));
+
+
+/*
+ * Test de la connexion
+ */
+if ($conf->global->LDAP_MEMBER_ACTIVE)
+{
+	$butlabel=$langs->trans("LDAPTestSynchroMember");
+	$testlabel='testmember';
+	$key=$conf->global->LDAP_KEY_MEMBERS;
+	$dn=$conf->global->LDAP_MEMBER_DN;
+	$objectclass=$conf->global->LDAP_MEMBER_OBJECT_CLASS;
+
+	show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
+}
+
+if (function_exists("ldap_connect"))
+{
+	if ($_GET["action"] == 'testmember')
+	{
+		// Creation objet
+		$object=new Adherent($db);
+		$object->initAsSpecimen();
+
+		// Test synchro
+		$ldap=new Ldap();
+		$result=$ldap->connect_bind();
+
+		if ($result > 0)
+		{
+			$info=$object->_load_ldap_info();
+			$dn=$object->_load_ldap_dn($info);
+
+			$result1=$ldap->delete($dn);			// To be sure to delete existing records
+			$result2=$ldap->add($dn,$info,$user);	// Now the test
+			$result3=$ldap->delete($dn);			// Clean what we did
+
+			if ($result2 > 0)
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
+			}
+			else
+			{
+				print img_picto('','error').' ';
+				print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
+				print ': '.$ldap->error;
+				print '</font><br>';
+				print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+			}
+
+			print "<br>\n";
+			print "LDAP input file used for test:<br><br>\n";
+			print nl2br($ldap->dump_content($dn,$info));
+			print "\n<br>";
+		}
+		else
+		{
+			print img_picto('','error').' ';
+			print '<font class="error">'.$langs->trans("LDAPSynchroKO");
+			print ': '.$ldap->error;
+			print '</font><br>';
+			print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+		}
+	}
+
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 349 - 0
dolicloudimages/dolibarr/src/htdocs/admin/ldap_users.php

@@ -0,0 +1,349 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2006-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2011 	   Juanjo Menent		<jmenent@2byte.es>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/ldap_users.php
+ *		\ingroup    ldap
+ *		\brief      Page d'administration/configuration du module Ldap
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php");
+require_once(DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/ldap.lib.php");
+
+$langs->load("admin");
+$langs->load("errors");
+
+if (!$user->admin)
+  accessforbidden();
+
+$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$error=0;
+	$db->begin();
+	
+	if (! dolibarr_set_const($db, 'LDAP_USER_DN',GETPOST("user"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS',GETPOST("objectclass"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',GETPOST("filterconnection"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',GETPOST("fieldfullname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',GETPOST("fieldlogin"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA',GETPOST("fieldloginsamba"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD',GETPOST("fieldpassword"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED',GETPOST("fieldpasswordcrypted"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',GETPOST("fieldname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',GETPOST("fieldfirstname"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',GETPOST("fieldmail"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',GETPOST("fieldphone"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',GETPOST("fieldmobile"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',GETPOST("fieldfax"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',GETPOST("fielddescription"),'chaine',0,'',$conf->entity)) $error++;
+	if (! dolibarr_set_const($db, 'LDAP_FIELD_SID',GETPOST("fieldsid"),'chaine',0,'',$conf->entity)) $error++;
+
+    // This one must be after the others
+    $valkey='';
+    $key=GETPOST("key");
+    if ($key) $valkey=$conf->global->$key;
+    if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$valkey,'chaine',0,'',$conf->entity)) $error++;
+
+	if (! $error)
+  	{
+  		$db->commit();
+  		$mesg='<div class="ok">'.$langs->trans("SetupSaved").'</div>';
+  	}
+  	else
+  	{
+  		$db->rollback();
+		dol_print_error($db);
+    }
+}
+
+
+
+/*
+ * Visu
+ */
+
+llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:M&oacute;dulo_LDAP');
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'setup');
+
+$head = ldap_prepare_head();
+
+// Test si fonction LDAP actives
+if (! function_exists("ldap_connect"))
+{
+	$mesg.='<div class="error">'.$langs->trans("LDAPFunctionsNotAvailableOnPHP").'</div>';  ;
+}
+
+dol_fiche_head($head, 'users', $langs->trans("LDAPSetup"));
+
+print $langs->trans("LDAPDescUsers").'<br>';
+print '<br>';
+
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+
+$form=new Form($db);
+
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
+print "</tr>\n";
+
+// DN Pour les utilisateurs
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPUserDn").'</span></td><td>';
+print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
+print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// List of object class used to define attributes in structure
+$var=!$var;
+print '<tr '.$bc[$var].'><td width="25%"><span class="fieldrequired">'.$langs->trans("LDAPUserObjectClassList").'</span></td><td>';
+print '<input size="48" type="text" name="objectclass" value="'.$conf->global->LDAP_USER_OBJECT_CLASS.'">';
+print '</td><td>'.$langs->trans("LDAPUserObjectClassListExample").'</td>';
+print '<td>&nbsp;</td>';
+print '</tr>';
+
+// Filtre
+//Utilise pour filtrer la recherche
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
+print '<input size="48" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
+print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
+print '<td></td>';
+print '</tr>';
+
+print '</table>';
+print '<br>';
+print '<table class="noborder" width="100%">';
+$var=true;
+
+print '<tr class="liste_titre">';
+print '<td width="25%">'.$langs->trans("LDAPDolibarrMapping").'</td>';
+print '<td colspan="2">'.$langs->trans("LDAPLdapMapping").'</td>';
+print '<td align="right">'.$langs->trans("LDAPNamingAttribute").'</td>';
+print "</tr>\n";
+
+// Common name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
+print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_FIELD_FULLNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FULLNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FULLNAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Name
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
+print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_NAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_NAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Firstname
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
+print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FIRSTNAME"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FIRSTNAME)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Login unix
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
+print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
+print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Login samba
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
+print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
+print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_LOGIN_SAMBA"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN_SAMBA)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Password not crypted
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordNotCrypted").'</td><td>';
+print '<input size="25" type="text" name="fieldpassword" value="'.$conf->global->LDAP_FIELD_PASSWORD.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Password crypted
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPasswordCrypted").'</td><td>';
+print '<input size="25" type="text" name="fieldpasswordcrypted" value="'.$conf->global->LDAP_FIELD_PASSWORD_CRYPTED.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPasswordExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PASSWORD_CRYPTED"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PASSWORD_CRYPTED)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Mail
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
+print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_MAIL"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MAIL)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Phone
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
+print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_PHONE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PHONE)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Mobile
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
+print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
+print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_MOBILE"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MOBILE)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Fax
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
+print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
+print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_FAX"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Description
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldDescription").'</td><td>';
+print '<input size="25" type="text" name="fielddescription" value="'.$conf->global->LDAP_FIELD_DESCRIPTION.'">';
+print '</td><td>'.$langs->trans("LDAPFieldDescriptionExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_DESCRIPTION"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_DESCRIPTION)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+// Sid
+$var=!$var;
+print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldSid").'</td><td>';
+print '<input size="25" type="text" name="fieldsid" value="'.$conf->global->LDAP_FIELD_SID.'">';
+print '</td><td>'.$langs->trans("LDAPFieldSidExample").'</td>';
+print '<td align="right"><input type="radio" name="key" value="LDAP_FIELD_SID"'.(($conf->global->LDAP_KEY_USERS && $conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_SID)?' checked="checked"':'')."></td>";
+print '</tr>';
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table>';
+
+print '</form>';
+
+print '</div>';
+
+print info_admin($langs->trans("LDAPDescValues"));
+
+
+/*
+ * Test de la connexion
+ */
+if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
+{
+	$butlabel=$langs->trans("LDAPTestSynchroUser");
+	$testlabel='testuser';
+	$key=$conf->global->LDAP_KEY_USERS;
+	$dn=$conf->global->LDAP_USER_DN;
+	$objectclass=$conf->global->LDAP_USER_OBJECT_CLASS;
+
+	show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass);
+}
+
+if (function_exists("ldap_connect"))
+{
+	if ($_GET["action"] == 'testuser')
+	{
+		// Creation objet
+		$object=new User($db);
+		$object->initAsSpecimen();
+
+		// TODO Mutualize code following with other ldap_xxxx.php pages
+
+		// Test synchro
+		$ldap=new Ldap();
+		$result=$ldap->connect_bind();
+
+		if ($result > 0)
+		{
+			$info=$object->_load_ldap_info();
+			$dn=$object->_load_ldap_dn($info);
+
+			$result1=$ldap->delete($dn);			// To be sure to delete existing records
+			$result2=$ldap->add($dn,$info,$user);	// Now the test
+			$result3=$ldap->delete($dn);			// Clean what we did
+
+			if ($result2 > 0)
+			{
+				print img_picto('','info').' ';
+				print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
+			}
+			else
+			{
+				print img_picto('','error').' ';
+				print '<font class="error">'.$langs->trans("LDAPSynchroKOMayBePermissions");
+				print ': '.$ldap->error;
+				print '</font><br>';
+				print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+			}
+
+			print "<br>\n";
+			print "LDAP input file used for test:<br><br>\n";
+			print nl2br($ldap->dump_content($dn,$info));
+			print "\n<br>";
+		}
+		else
+		{
+			print img_picto('','error').' ';
+			print '<font class="error">'.$langs->trans("LDAPSynchroKO");
+			print ': '.$ldap->error;
+			print '</font><br>';
+			print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
+		}
+	}
+}
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 307 - 0
dolicloudimages/dolibarr/src/htdocs/admin/limits.php

@@ -0,0 +1,307 @@
+<?php
+/* Copyright (C) 2007-2012	Laurent Destailleur	<eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2012	Regis Houssin		<regis@dolibarr.fr>
+ * Copyright (C) 2010		Juanjo Menent		<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/admin/limits.php
+ *       \brief      Page to setup limits
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/price.lib.php");
+
+$langs->load("companies");
+$langs->load("products");
+$langs->load("admin");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+if ($action == 'update')
+{
+    $error=0;
+    $MAXDEC=8;
+    if ($_POST["MAIN_MAX_DECIMALS_UNIT"]  > $MAXDEC
+    || $_POST["MAIN_MAX_DECIMALS_TOT"]   > $MAXDEC
+    || $_POST["MAIN_MAX_DECIMALS_SHOWN"] > $MAXDEC)
+    {
+        $error++;
+        $mesg='<div class="error">'.$langs->trans("ErrorDecimalLargerThanAreForbidden",$MAXDEC).'</div>';
+    }
+
+    if ($_POST["MAIN_MAX_DECIMALS_UNIT"]  < 0
+    || $_POST["MAIN_MAX_DECIMALS_TOT"]   < 0
+    || $_POST["MAIN_MAX_DECIMALS_SHOWN"] < 0)
+    {
+        $langs->load("errors");
+        $error++;
+        $mesg='<div class="error">'.$langs->trans("ErrorNegativeValueNotAllowed").'</div>';
+    }
+
+    if ($_POST["MAIN_ROUNDING_RULE_TOT"])
+    {
+        if ($_POST["MAIN_ROUNDING_RULE_TOT"] * pow(10,$_POST["MAIN_MAX_DECIMALS_TOT"]) < 1)
+        {
+            $langs->load("errors");
+            $error++;
+            $mesg='<div class="error">'.$langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT").'</div>';
+        }
+    }
+
+    if (! $error)
+    {
+        dolibarr_set_const($db, "MAIN_MAX_DECIMALS_UNIT",   $_POST["MAIN_MAX_DECIMALS_UNIT"],'chaine',0,'',$conf->entity);
+        dolibarr_set_const($db, "MAIN_MAX_DECIMALS_TOT",    $_POST["MAIN_MAX_DECIMALS_TOT"],'chaine',0,'',$conf->entity);
+        dolibarr_set_const($db, "MAIN_MAX_DECIMALS_SHOWN",  $_POST["MAIN_MAX_DECIMALS_SHOWN"],'chaine',0,'',$conf->entity);
+
+        dolibarr_set_const($db, "MAIN_ROUNDING_RULE_TOT",   $_POST["MAIN_ROUNDING_RULE_TOT"],'chaine',0,'',$conf->entity);
+
+        Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
+        exit;
+    }
+}
+
+
+
+/*
+ * View
+*/
+
+$form=new Form($db);
+
+llxHeader();
+
+print_fiche_titre($langs->trans("LimitsSetup"),'','setup');
+
+
+print $langs->trans("LimitsDesc")."<br>\n";
+print "<br>\n";
+
+if ($mesg) print $mesg.'<br>';
+
+if ($action == 'edit')
+{
+    print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+
+    clearstatcache();
+    $var=true;
+
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td><input class="flat" name="MAIN_MAX_DECIMALS_UNIT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_UNIT . '"></td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td><input class="flat" name="MAIN_MAX_DECIMALS_TOT" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_TOT . '"></td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td><input class="flat" name="MAIN_MAX_DECIMALS_SHOWN" size="3" value="' . $conf->global->MAIN_MAX_DECIMALS_SHOWN . '"></td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td><input class="flat" name="MAIN_ROUNDING_RULE_TOT" size="3" value="' . $conf->global->MAIN_ROUNDING_RULE_TOT . '"></td></tr>';
+
+    print '</table>';
+
+    print '<br><center>';
+    print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
+    print '</center>';
+
+    print '</form>';
+    print '<br>';
+}
+else
+{
+    $var=true;
+
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_UNIT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_UNIT.'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_MAX_DECIMALS_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_TOT.'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAX_DECIMALS_SHOWN").'</td><td align="right">'.$conf->global->MAIN_MAX_DECIMALS_SHOWN.'</td></tr>';
+
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>';
+    print $form->textwithpicto($langs->trans("MAIN_ROUNDING_RULE_TOT"),$langs->trans("ParameterActiveForNextInputOnly"));
+    print '</td><td align="right">'.$conf->global->MAIN_ROUNDING_RULE_TOT.'</td></tr>';
+
+    print '</table>';
+
+    print '<div class="tabsAction">';
+    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+    print '</div>';
+}
+
+
+// Show examples
+print '<b>'.$langs->trans("ExamplesWithCurrentSetup").":</b><br>\n";
+
+// Always show vat rates with vat 0
+$s=2/7;$qty=1;$vat=0;
+$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+print " x ".$langs->trans("Quantity").": ".$qty;
+print " - ".$langs->trans("VAT").": ".$vat.'%';
+print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+
+$s=10/3;$qty=1;$vat=0;
+$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+print " x ".$langs->trans("Quantity").": ".$qty;
+print " - ".$langs->trans("VAT").": ".$vat.'%';
+print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+
+$s=10/3;$qty=2;$vat=0;
+$tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+print " x ".$langs->trans("Quantity").": ".$qty;
+print " - ".$langs->trans("VAT").": ".$vat.'%';
+print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+
+// Add vat rates examples specific to country
+$vat_rates=array();
+
+$sql.="SELECT taux as vat_rate";
+$sql.=" FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_pays as p";
+$sql.=" WHERE t.active=1 AND t.fk_pays = p.rowid AND p.code='".$mysoc->country_code."' AND taux != 0";
+$sql.=" ORDER BY t.taux ASC";
+$resql=$db->query($sql);
+if ($resql)
+{
+    $num = $db->num_rows($resql);
+    if ($num)
+    {
+        for ($i = 0; $i < $num; $i++)
+        {
+            $obj = $db->fetch_object($resql);
+            $vat_rates[$i] = $obj->vat_rate;
+        }
+    }
+}
+else dol_print_error($db);
+
+if (count($vat_rates))
+{
+    foreach($vat_rates as $vat)
+    {
+        for ($qty=1; $qty<=2; $qty++)
+        {
+            $s=10/3;
+            $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+            print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+            print " x ".$langs->trans("Quantity").": ".$qty;
+            print " - ".$langs->trans("VAT").": ".$vat.'%';
+            print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+        }
+    }
+}
+else
+{
+    // More examples if not specific vat rate found
+    // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
+    // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
+
+    $s=10/3;$qty=1;$vat=10;
+    $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+    print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+    print " x ".$langs->trans("Quantity").": ".$qty;
+    print " - ".$langs->trans("VAT").": ".$vat.'%';
+    print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+
+    $s=10/3;$qty=2;$vat=10;
+    $tmparray=calcul_price_total(1,$qty*price2num($s,'MU'),0,$vat,0,0,0,'HT',0);
+    print $langs->trans("UnitPriceOfProduct").": ".price2num($s,'MU');
+    print " x ".$langs->trans("Quantity").": ".$qty;
+    print " - ".$langs->trans("VAT").": ".$vat.'%';
+    print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+
+}
+
+// Important: can debug rounding, to simulate the rounded total
+/*
+print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
+
+foreach($vat_rates as $vat)
+{
+	for ($qty=1; $qty<=2; $qty++)
+	{
+		$s1=10/3;
+		$s2=2/7;
+
+		// Round by line
+		$tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0);
+		$tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0);
+		$total_ht = $tmparray1[0] + $tmparray2[0];
+		$total_tva = $tmparray1[1] + $tmparray2[1];
+		$total_ttc = $tmparray1[2] + $tmparray2[2];
+
+		print $langs->trans("UnitPriceOfProduct").": ".(price2num($s1,'MU') + price2num($s2,'MU'));
+		print " x ".$langs->trans("Quantity").": ".$qty;
+		print " - ".$langs->trans("VAT").": ".$vat.'%';
+		print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
+	}
+}
+
+print '<br><b>'.$langs->trans("VATRoundedOnTotal").'</b><br>';
+
+foreach($vat_rates as $vat)
+{
+	for ($qty=1; $qty<=2; $qty++)
+	{
+		$s1=10/3;
+		$s2=2/7;
+
+		// Global round
+		$subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
+		$tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0);
+		$total_ht = $tmparray3[0];
+		$total_tva = $tmparray3[1];
+		$total_ttc = $tmparray3[2];
+
+		print $langs->trans("UnitPriceOfProduct").": ".price2num($s1+$s2,'MU');
+		print " x ".$langs->trans("Quantity").": ".$qty;
+		print " - ".$langs->trans("VAT").": ".$vat.'%';
+		print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
+	}
+}
+*/
+
+llxFooter();
+
+$db->close();
+?>

+ 486 - 0
dolicloudimages/dolibarr/src/htdocs/admin/livraison.php

@@ -0,0 +1,486 @@
+<?php
+/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Sebastien Di Cintio  <sdicintio@ressource-toi.org>
+ * Copyright (C) 2004      Benoit Mortier       <benoit.mortier@opensides.be>
+ * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011-2012 Juanjo Menent	    <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/livraison.php
+ *      \ingroup    livraison
+ *      \brief      Page d'administration/configuration du module Livraison
+ */
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/livraison/class/livraison.class.php");
+
+$langs->load("admin");
+$langs->load("sendings");
+$langs->load("deliveries");
+
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+$value = GETPOST('value','alpha');
+
+/*
+ * Actions
+ */
+
+if ($action == 'updateMask')
+{
+	$maskconstdelivery=GETPOST('maskconstdelivery','alpha');
+	$maskdelivery=GETPOST('maskdelivery','alpha');
+	if ($maskconstdelivery)  $res = dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'specimen')
+{
+	$modele=GETPOST('module','alpha');
+
+	$sending = new Livraison($db);
+	$sending->initAsSpecimen();
+	//$sending->fetch_commande();
+
+	// Charge le modele
+	$dir = DOL_DOCUMENT_ROOT . "/core/modules/livraison/pdf/";
+	$file = "pdf_".$modele.".modules.php";
+	if (file_exists($dir.$file))
+	{
+		$classname = "pdf_".$modele;
+		require_once($dir.$file);
+
+		$obj = new $classname($db);
+
+		if ($obj->write_file($sending,$langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=livraison&file=SPECIMEN.pdf");
+			return;
+		}
+		else
+		{
+			$mesg='<font class="error">'.$obj->error.'</font>';
+			dol_syslog($obj->error, LOG_ERR);
+		}
+	}
+	else
+	{
+		$mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
+}
+
+if ($action == 'set')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+
+	$type='delivery';
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $resql=$db->query($sql);
+}
+
+if ($action == 'del')
+{
+    $type='delivery';
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql.= " WHERE nom = '".$db->escape($value)."'";
+    $sql.= " AND type = '".$type."'";
+    $sql.= " AND entity = ".$conf->entity;
+
+    if ($db->query($sql))
+    {
+        if ($conf->global->LIVRAISON_ADDON_PDF == "$value") dolibarr_del_const($db, 'LIVRAISON_ADDON_PDF',$conf->entity);
+    }
+}
+
+if ($action == 'setdoc')
+{
+	$label = GETPOST('label','alpha');
+	$scandir = GETPOST('scandir','alpha');
+	$db->begin();
+
+    if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$value,'chaine',0,'',$conf->entity))
+    {
+        $conf->global->LIVRAISON_ADDON_PDF = $value;
+    }
+
+    // On active le modele
+    $type='delivery';
+    $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+    $sql_del.= " WHERE nom = '".$db->escape($value)."'";
+    $sql_del.= " AND type = '".$type."'";
+    $sql_del.= " AND entity = ".$conf->entity;
+    $result1=$db->query($sql_del);
+
+    $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+    $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
+    $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
+    $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
+    $sql.= ")";
+    $result2=$db->query($sql);
+    if ($result1 && $result2)
+    {
+		$db->commit();
+    }
+    else
+    {
+    	$db->rollback();
+    }
+}
+
+if ($action == 'set_DELIVERY_FREE_TEXT')
+{
+	$free=GETPOST('DELIVERY_FREE_TEXT','alpha');
+    $res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity);
+
+    if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == 'setmod')
+{
+    // TODO Verifier si module numerotation choisi peut etre active
+    // par appel methode canBeActivated
+
+	dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity);
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+llxHeader("","");
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
+print '<br>';
+
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php";
+$head[$h][1] = $langs->trans("Setup");
+$h++;
+
+if ($conf->global->MAIN_SUBMODULE_EXPEDITION)
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/expedition.php";
+	$head[$h][1] = $langs->trans("Sending");
+	$h++;
+}
+
+$head[$h][0] = DOL_URL_ROOT."/admin/livraison.php";
+$head[$h][1] = $langs->trans("Receivings");
+$hselected=$h;
+$h++;
+
+
+dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup"));
+
+/*
+ *  Module numerotation
+ */
+print_titre($langs->trans("DeliveryOrderNumberingModules"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="100">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td nowrap>'.$langs->trans("Example").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($conf->file->dol_document_root as $dirroot)
+{
+	$dir = $dirroot . "/core/modules/livraison/";
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+		    $var=true;
+		    while (($file = readdir($handle))!==false)
+		    {
+		        if (substr($file, 0, 14) == 'mod_livraison_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+				{
+					$file = substr($file, 0, dol_strlen($file)-4);
+
+					require_once(DOL_DOCUMENT_ROOT ."/core/modules/livraison/".$file.".php");
+
+					$module = new $file;
+
+					// 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())
+				    {
+						$var=!$var;
+						print '<tr '.$bc[$var].'><td>'.$module->nom."</td><td>\n";
+						print $module->info();
+						print '</td>';
+
+                        // Show example of numbering module
+                        print '<td nowrap="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+						print '<td align="center">';
+						if ($conf->global->LIVRAISON_ADDON == "$file")
+						{
+							print img_picto($langs->trans("Activated"),'switch_on');
+						}
+						else
+						{
+							print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+						}
+						print '</td>';
+
+						$livraison=new Livraison($db);
+						$livraison->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$facture->type=0;
+				        $nextval=$module->getNextValue($mysoc,$livraison);
+						if ("$nextval" != $langs->trans("NotAvailable"))	// Keep " on nextval
+						{
+							$htmltooltip.=''.$langs->trans("NextValue").': ';
+					        if ($nextval)
+							{
+								$htmltooltip.=$nextval.'<br>';
+							}
+							else
+							{
+								$htmltooltip.=$langs->trans($module->error).'<br>';
+							}
+						}
+
+						print '<td align="center">';
+						print $form->textwithpicto('',$htmltooltip,1,0);
+						print '</td>';
+
+						print '</tr>';
+				    }
+				}
+		    }
+		    closedir($handle);
+		}
+	}
+}
+
+print '</table>';
+
+
+/*
+ *  Modeles de documents
+ */
+print '<br>';
+print_titre($langs->trans("DeliveryOrderModel"));
+
+// Defini tableau def de modele invoice
+$type="delivery";
+$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%">';
+print '<tr class="liste_titre">';
+print '<td width="140">'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Default").'</td>';
+print '<td align="center" width="32" colspan="2">'.$langs->trans("Infos").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($conf->file->dol_document_root as $dirroot)
+{
+	$dir = $dirroot . "/core/modules/livraison/pdf/";
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+	    	while (($file = readdir($handle))!==false)
+	    	{
+	    		if (substr($file, dol_strlen($file) -12) == '.modules.php' && substr($file,0,4) == 'pdf_')
+	    		{
+	    			$name = substr($file, 4, dol_strlen($file) - 16);
+	    			$classname = substr($file, 0, dol_strlen($file) - 12);
+
+	    			$var=!$var;
+	    			print "<tr $bc[$var]><td>";
+	    			print $name;
+	    			print "</td><td>\n";
+	    			require_once($dir.$file);
+	    			$module = new $classname($db);
+
+	    			print $module->description;
+	    			print '</td>';
+
+	    			// Activ
+	    			if (in_array($name, $def))
+	    			{
+	    				print "<td align=\"center\">\n";
+	    				//if ($conf->global->LIVRAISON_ADDON_PDF != "$name")
+	    				//{
+	    					print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
+	    					print img_picto($langs->trans("Enabled"),'switch_on');
+	    					print '</a>';
+	    				//}
+	    				//else
+	    				//{
+	    				//	print img_picto($langs->trans("Enabled"),'switch_on');
+	    				//}
+	    				print "</td>";
+	    			}
+	    			else
+	    			{
+	    				print "<td align=\"center\">\n";
+	    				print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	    				print "</td>";
+	    			}
+
+	    			// Defaut
+	    			print "<td align=\"center\">";
+	    			if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
+	    			{
+	    				print img_picto($langs->trans("Default"),'on');
+	    			}
+	    			else
+	    			{
+	    				print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>';
+	    			}
+	    			print '</td>';
+
+	    			// Info
+	    			$htmltooltip =    ''.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+	    			$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+	    			$htmltooltip.='<br><br>'.$langs->trans("FeaturesSupported").':';
+	    			$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo,1,1);
+	    	    	print '<td align="center">';
+	    	    	print $form->textwithpicto('',$htmltooltip,1,0);
+	    	    	print '</td>';
+	    	    	print '<td align="center">';
+	    	    	print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"),'sending').'</a>';
+	    	    	print '</td>';
+
+	    			print '</tr>';
+	    		}
+	    	}
+	    	closedir($handle);
+	    }
+	}
+}
+
+print '</table>';
+
+/*
+*
+*
+*/
+print "<br>";
+print_titre($langs->trans("OtherOptions"));
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
+print '<td width="80">&nbsp;</td>';
+print "</tr>\n";
+$var=true;
+
+$var=! $var;
+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_DELIVERY_FREE_TEXT">';
+print '<tr '.$bc[$var].'><td colspan="2">';
+print $langs->trans("FreeLegalTextOnDeliveryReceipts").' ('.$langs->trans("AddCRIfTooLong").')<br>';
+print '<textarea name="DELIVERY_FREE_TEXT" class="flat" cols="120">'.$conf->global->DELIVERY_FREE_TEXT.'</textarea>';
+print '</td><td align="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+print '</table>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 133 - 0
dolicloudimages/dolibarr/src/htdocs/admin/mailing.php

@@ -0,0 +1,133 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville 	<rodolphe@quiedeville.org>
+ * Copyright (C) 2005-2011 Laurent Destailleur  	<eldy@users.sourceforge.org>
+ * Copyright (C) 2011-2012 Juanjo Menent			<jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/mailing.php
+ *		\ingroup    mailing
+ *		\brief      Page to setup emailing module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("admin");
+$langs->load("mails");
+
+if (!$user->admin)
+  accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$db->begin();
+
+	$mailfrom = GETPOST('MAILING_EMAIL_FROM','alpha');
+	$mailerror = GETPOST('MAILING_EMAIL_ERRORSTO','alpha');
+
+	$res=dolibarr_set_const($db, "MAILING_EMAIL_FROM",$mailfrom,'chaine',0,'',$conf->entity);
+	if (! $res > 0) $error++;
+	$res=dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO",$mailerror,'chaine',0,'',$conf->entity);
+	if (! $res > 0) $error++;
+	$res=dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE",$checkread,'chaine',0,'',$conf->entity);
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+    	$db->commit();
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+    	$db->rollback();
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+/*
+ *	View
+ */
+
+llxHeader('',$langs->trans("MailingSetup"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup');
+
+dol_htmloutput_mesg($mesg);
+
+print '<br>';
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setvalue">';
+
+$var=true;
+
+print '<table class="nobordernopadding" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print "</tr>\n";
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("MailingEMailFrom").'</td><td>';
+print '<input size="32" type="text" name="MAILING_EMAIL_FROM" value="'.$conf->global->MAILING_EMAIL_FROM.'">';
+if (!empty($conf->global->MAILING_EMAIL_FROM) && ! isValidEmail($conf->global->MAILING_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
+print '</td></tr>';
+
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("MailingEMailError").'</td><td>';
+print '<input size="32" type="text" name="MAILING_EMAIL_ERRORSTO" value="'.$conf->global->MAILING_EMAIL_ERRORSTO.'">';
+if (!empty($conf->global->MAILING_EMAIL_ERRORSTO) && ! isValidEmail($conf->global->MAILING_EMAIL_ERRORSTO)) print ' '.img_warning($langs->trans("BadEMail"));
+print '</td></tr>';
+
+/*
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("ActivateCheckRead").'</td><td>';
+if ($conf->global->MAILING_EMAIL_UNSUBSCRIBE==1)
+{
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&value=0">';
+	print img_picto($langs->trans("Enabled"),'switch_on');
+	print '</a>';
+}
+else
+{
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setvalue&value=1">';
+	print img_picto($langs->trans("Disabled"),'switch_off');
+	print '</a>';
+}
+print '</td></tr>';
+*/
+
+
+print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
+print '</table></form>';
+
+
+llxFooter();
+
+$db->close();
+?>

+ 770 - 0
dolicloudimages/dolibarr/src/htdocs/admin/mails.php

@@ -0,0 +1,770 @@
+<?php
+/* Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2011 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/admin/mails.php
+ *       \brief      Page to setup emails sending
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+$langs->load("companies");
+$langs->load("products");
+$langs->load("admin");
+$langs->load("mails");
+$langs->load("other");
+$langs->load("errors");
+
+if (!$user->admin) accessforbidden();
+
+$substitutionarrayfortest=array(
+'__LOGIN__' => $user->login,
+'__ID__' => 'TESTIdRecord',
+'__EMAIL__' => 'TESTEMail',
+'__LASTNAME__' => 'TESTLastname',
+'__FIRSTNAME__' => 'TESTFirstname',
+'__SIGNATURE__' => 'TESTSignature',
+'__PERSONALIZED__' => 'TESTPersonalized'
+);
+complete_substitutions_array($substitutionarrayfortest, $langs);
+
+$action=GETPOST('action');
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update' && empty($_POST["cancel"]))
+{
+	dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS",   GETPOST("MAIN_DISABLE_ALL_MAILS"),'chaine',0,'',$conf->entity);
+    // Send mode parameters
+	dolibarr_set_const($db, "MAIN_MAIL_SENDMODE",       GETPOST("MAIN_MAIL_SENDMODE"),'chaine',0,'',0);
+	if (isset($_POST["MAIN_MAIL_SMTP_PORT"]))   dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT",   GETPOST("MAIN_MAIL_SMTP_PORT"),'chaine',0,'',0);
+	if (isset($_POST["MAIN_MAIL_SMTP_SERVER"])) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", GETPOST("MAIN_MAIL_SMTP_SERVER"),'chaine',0,'',0);
+	if (isset($_POST["MAIN_MAIL_SMTPS_ID"]))    dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID",    GETPOST("MAIN_MAIL_SMTPS_ID"), 'chaine',0,'',0);
+	if (isset($_POST["MAIN_MAIL_SMTPS_PW"]))    dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW",    GETPOST("MAIN_MAIL_SMTPS_PW"), 'chaine',0,'',0);
+	if (isset($_POST["MAIN_MAIL_EMAIL_TLS"]))   dolibarr_set_const($db, "MAIN_MAIL_EMAIL_TLS",   GETPOST("MAIN_MAIL_EMAIL_TLS"),'chaine',0,'',0);
+    // Content parameters
+	dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM",     GETPOST("MAIN_MAIL_EMAIL_FROM"), 'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_ERRORS_TO",		GETPOST("MAIN_MAIL_ERRORS_TO"),  'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_MAIL_AUTOCOPY_TO",    GETPOST("MAIN_MAIL_AUTOCOPY_TO"),'chaine',0,'',$conf->entity);
+
+	Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
+	exit;
+}
+
+
+/*
+ * Add file in email form
+ */
+if ($_POST['addfile'] || $_POST['addfilehtml'])
+{
+	require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
+
+	// Set tmp user directory
+	$vardir=$conf->user->dir_output."/".$user->id;
+	$upload_dir = $vardir.'/temp';
+
+	if (dol_mkdir($upload_dir) >= 0)
+	{
+		$resupload=dol_move_uploaded_file($_FILES['addedfile']['tmp_name'], $upload_dir . "/" . $_FILES['addedfile']['name'], 1, 0, $_FILES['addedfile']['error']);
+		if (is_numeric($resupload) && $resupload > 0)
+		{
+			$mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
+
+			include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+			$formmail = new FormMail($db);
+			$formmail->add_attached_files($upload_dir . "/" . $_FILES['addedfile']['name'],$_FILES['addedfile']['name'],$_FILES['addedfile']['type']);
+		}
+		else
+		{
+			$langs->load("errors");
+			if ($resupload < 0)	// Unknown error
+			{
+				$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
+			}
+			else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload))	// Files infected by a virus
+			{
+				$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
+			}
+			else	// Known error
+			{
+				$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
+			}
+		}
+	}
+	else
+	{
+		$langs->load("errors");
+		$mesg = '<div class="error">'.$langs->trans("ErrorFailToCreateDir",$upload_dir).'</div>';
+	}
+
+	if ($_POST['addfile'])     $action='test';
+	if ($_POST['addfilehtml']) $action='testhtml';
+}
+
+/*
+ * Remove file in email form
+ */
+if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml']))
+{
+	// Set tmp user directory
+	$vardir=$conf->user->dir_output."/".$user->id;
+	$upload_dir = $vardir.'/temp';
+
+	$keytodelete=isset($_POST['removedfile'])?$_POST['removedfile']:$_POST['removedfilehtml'];
+	$keytodelete--;
+
+	$listofpaths=array();
+	$listofnames=array();
+	$listofmimes=array();
+	if (! empty($_SESSION["listofpaths"])) $listofpaths=explode(';',$_SESSION["listofpaths"]);
+	if (! empty($_SESSION["listofnames"])) $listofnames=explode(';',$_SESSION["listofnames"]);
+	if (! empty($_SESSION["listofmimes"])) $listofmimes=explode(';',$_SESSION["listofmimes"]);
+
+	if ($keytodelete >= 0)
+	{
+		$pathtodelete=$listofpaths[$keytodelete];
+		$filetodelete=$listofnames[$keytodelete];
+		$result = dol_delete_file($pathtodelete,1);
+		if ($result >= 0)
+		{
+            $langs->load("other");
+		    $message = '<div class="ok">'.$langs->trans("FileWasRemoved",$filetodelete).'</div>';
+			//print_r($_FILES);
+
+			include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+			$formmail = new FormMail($db);
+			$formmail->remove_attached_files($keytodelete);
+		}
+	}
+	if ($_POST['removedfile'] || $action='send')     $action='test';
+	if ($_POST['removedfilehtml'] || $action='sendhtml') $action='testhtml';
+}
+
+/*
+ * Send mail
+ */
+if (($action == 'send' || $action == 'sendhtml') && ! $_POST['addfile'] && ! $_POST['addfilehtml'] && ! $_POST["removedfile"] && ! $_POST['cancel'])
+{
+	$error=0;
+
+	$email_from='';
+	if (! empty($_POST["fromname"])) $email_from=$_POST["fromname"].' ';
+	if (! empty($_POST["frommail"])) $email_from.='<'.$_POST["frommail"].'>';
+
+	$errors_to  = $_POST["errorstomail"];
+	$sendto     = $_POST["sendto"];
+	$sendtocc   = $_POST["sendtocc"];
+	$sendtoccc  = $_POST["sendtoccc"];
+	$subject    = $_POST['subject'];
+	$body       = $_POST['message'];
+	$deliveryreceipt= $_POST["deliveryreceipt"];
+
+	// Create form object
+	include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php');
+	$formmail = new FormMail($db);
+
+	$attachedfiles=$formmail->get_attached_files();
+	$filepath = $attachedfiles['paths'];
+	$filename = $attachedfiles['names'];
+	$mimetype = $attachedfiles['mimes'];
+
+	if (empty($_POST["frommail"]))
+	{
+		$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom")).'</div>';
+		$action='test';
+		$error++;
+	}
+	if (empty($sendto))
+	{
+		$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTo")).'</div>';
+		$action='test';
+		$error++;
+	}
+	if (! $error)
+	{
+		// Le message est-il en html
+		$msgishtml=0;	// Message is not HTML
+		if ($action == 'sendhtml') $msgishtml=1;	// Force message to HTML
+
+		// Pratique les substitutions sur le sujet et message
+		$subject=make_substitutions($subject,$substitutionarrayfortest);
+		$body=make_substitutions($body,$substitutionarrayfortest);
+
+		require_once(DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
+        $mailfile = new CMailFile(
+            $subject,
+            $sendto,
+            $email_from,
+            $body,
+            $filepath,
+            $mimetype,
+            $filename,
+            $sendtocc,
+            $sendtoccc,
+            $deliveryreceipt,
+            $msgishtml,
+            $errors_to
+        );
+
+		$result=$mailfile->sendfile();
+
+		if ($result)
+		{
+			$message='<div class="ok">'.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($email_from,2),$mailfile->getValidAddress($sendto,2)).'</div>';
+		}
+		else
+		{
+			$message='<div class="error">'.$langs->trans("ResultKo").'<br>'.$mailfile->error.' '.$result.'</div>';
+		}
+
+		$action='';
+	}
+}
+
+
+
+/*
+ * View
+ */
+
+$linuxlike=1;
+if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
+if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
+
+
+if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
+$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:ini_get('smtp_port');
+if (! $port) $port=25;
+$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:ini_get('SMTP');
+if (! $server) $server='127.0.0.1';
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:Setup EMails|FR:Paramétrage EMails|ES:Configuración EMails';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+print_fiche_titre($langs->trans("EMailsSetup"),'','setup');
+
+print $langs->trans("EMailsDesc")."<br>\n";
+print "<br>\n";
+
+dol_htmloutput_mesg($message);
+
+// List of sending methods
+$listofmethods=array();
+$listofmethods['mail']='PHP mail function';
+//$listofmethods['simplemail']='Simplemail class';
+$listofmethods['smtps']='SMTP/SMTPS socket library';
+
+
+if ($action == 'edit')
+{
+	$form=new Form($db);
+
+	if ($conf->use_javascript_ajax)
+	{
+		print "\n".'<script type="text/javascript" language="javascript">';
+		print 'jQuery(document).ready(function () {
+                    function initfields()
+                    {
+                        if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'mail\')
+                        {
+                            jQuery(".drag").hide();
+                            jQuery("#MAIN_MAIL_EMAIL_TLS").val(0);
+                            jQuery("#MAIN_MAIL_EMAIL_TLS").attr(\'disabled\', \'disabled\');
+                            ';
+		if ($linuxlike)
+		{
+			print '         jQuery("#MAIN_MAIL_SMTP_SERVER").attr(\'disabled\', \'disabled\');';
+			print '         jQuery("#MAIN_MAIL_SMTP_PORT").attr(\'disabled\', \'disabled\');';
+		}
+		print '
+                        }
+                        if (jQuery("#MAIN_MAIL_SENDMODE").val()==\'smtps\')
+                        {
+                            jQuery(".drag").show();
+                            jQuery("#MAIN_MAIL_EMAIL_TLS").val('.$conf->global->MAIN_MAIL_EMAIL_TLS.');
+                            jQuery("#MAIN_MAIL_EMAIL_TLS").removeAttr(\'disabled\');
+                            jQuery("#MAIN_MAIL_SMTP_SERVER").removeAttr(\'disabled\');
+                            jQuery("#MAIN_MAIL_SMTP_PORT").removeAttr(\'disabled\');
+                        }
+                    }
+                    initfields();
+                    jQuery("#MAIN_MAIL_SENDMODE").change(function() {
+                        initfields();
+                    });
+               })';
+		print '</script>'."\n";
+	}
+
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="update">';
+
+	clearstatcache();
+	$var=true;
+
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+	// Disable
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>';
+	print $form->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1);
+	print '</td></tr>';
+
+	// Separator
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
+
+	// Method
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
+
+	// SuperAdministrator access only
+	if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+	{
+		print $form->selectarray('MAIN_MAIL_SENDMODE',$listofmethods,$conf->global->MAIN_MAIL_SENDMODE);
+	}
+	else
+	{
+		$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
+		if (empty($text)) $text = $langs->trans("Undefined");
+		$htmltext = $langs->trans("ContactSuperAdminForChange");
+		print $form->textwithpicto($text,$htmltext,1,'superadmin');
+		print '<input type="hidden" name="MAIN_MAIL_SENDMODE" value="'.$conf->global->MAIN_MAIL_SENDMODE.'">';
+	}
+	print '</td></tr>';
+
+	// Server
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>';
+	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	{
+		print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
+		print '</td><td>';
+		print $langs->trans("SeeLocalSendMailSetup");
+	}
+	else
+	{
+		$smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined");
+		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
+		else print $langs->trans("MAIN_MAIL_SMTP_SERVER",$smtpserver);
+		print '</td><td>';
+		// SuperAdministrator access only
+		if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $conf->global->MAIN_MAIL_SMTP_SERVER . '">';
+		}
+		else
+		{
+			$text = $conf->global->MAIN_MAIL_SMTP_SERVER ? $conf->global->MAIN_MAIL_SMTP_SERVER : $smtpserver;
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($text,$htmltext,1,'superadmin');
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$conf->global->MAIN_MAIL_SMTP_SERVER.'">';
+		}
+	}
+	print '</td></tr>';
+
+	// Port
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>';
+	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	{
+		print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
+		print '</td><td>';
+		print $langs->trans("SeeLocalSendMailSetup");
+	}
+	else
+	{
+		$smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined");
+		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
+		else print $langs->trans("MAIN_MAIL_SMTP_PORT",$smtpport);
+		print '</td><td>';
+		// SuperAdministrator access only
+		if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="' . $conf->global->MAIN_MAIL_SMTP_PORT . '">';
+		}
+		else
+		{
+			$text = $conf->global->MAIN_MAIL_SMTP_PORT ? $conf->global->MAIN_MAIL_SMTP_PORT : $smtpport;
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($text,$htmltext,1,'superadmin');
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$conf->global->MAIN_MAIL_SMTP_PORT.'">';
+		}
+	}
+	print '</td></tr>';
+
+	// ID
+	if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		$var=!$var;
+		print '<tr '.$bcdd[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
+		// SuperAdministrator access only
+		if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="' . $conf->global->MAIN_MAIL_SMTPS_ID . '">';
+		}
+		else
+		{
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_ID,$htmltext,1,'superadmin');
+			print '<input type="hidden" name="MAIN_MAIL_SMTPS_ID" value="'.$conf->global->MAIN_MAIL_SMTPS_ID.'">';
+		}
+		print '</td></tr>';
+	}
+
+	// PW
+	if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		$var=!$var;
+		print '<tr '.$bcdd[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>';
+		// SuperAdministrator access only
+		if ((empty($conf->global->MAIN_MODULE_MULTICOMPANY)) || ($user->admin && !$user->entity))
+		{
+			print '<input class="flat" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . $conf->global->MAIN_MAIL_SMTPS_PW . '">';
+		}
+		else
+		{
+			$htmltext = $langs->trans("ContactSuperAdminForChange");
+			print $form->textwithpicto($conf->global->MAIN_MAIL_SMTPS_PW,$htmltext,1,'superadmin');
+			print '<input type="hidden" name="MAIN_MAIL_SMTPS_PW" value="'.$conf->global->MAIN_MAIL_SMTPS_PW.'">';
+		}
+		print '</td></tr>';
+	}
+
+	// TLS
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
+	if ($conf->use_javascript_ajax || $conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		if (function_exists('openssl_open'))
+		{
+			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS',$conf->global->MAIN_MAIL_EMAIL_TLS,1);
+		}
+		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+	}
+	else print yn(0).' ('.$langs->trans("NotSupported").')';
+	print '</td></tr>';
+
+	// Separator
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
+
+	// From
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>';
+	print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . $conf->global->MAIN_MAIL_EMAIL_FROM;
+	print '"></td></tr>';
+
+	// From
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
+	print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="' . $conf->global->MAIN_MAIL_ERRORS_TO;
+	print '"></td></tr>';
+
+	// Autocopy to
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
+	print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . $conf->global->MAIN_MAIL_AUTOCOPY_TO;
+	print '"></td></tr>';
+	print '</table>';
+
+	print '<br><center>';
+	print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
+	print ' &nbsp; &nbsp; ';
+	print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
+	print '</center>';
+
+	print '</form>';
+	print '<br>';
+}
+else
+{
+	$var=true;
+
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+
+	// Disable
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS).'</td></tr>';
+
+	// Separator
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
+
+	// Method
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
+	$text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
+	if (empty($text)) $text=$langs->trans("Undefined").img_warning();
+	print $text;
+	print '</td></tr>';
+
+	// Server
+	$var=!$var;
+	if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
+	}
+	else
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER",ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).'</td><td>'.$conf->global->MAIN_MAIL_SMTP_SERVER.'</td></tr>';
+	}
+
+	// Port
+	$var=!$var;
+	if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").'</td><td>'.$langs->trans("SeeLocalSendMailSetup").'</td></tr>';
+	}
+	else
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT",ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).'</td><td>'.$conf->global->MAIN_MAIL_SMTP_PORT.'</td></tr>';
+	}
+
+	// SMTPS ID
+	$var=!$var;
+	if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>'.$conf->global->MAIN_MAIL_SMTPS_ID.'</td></tr>';
+	}
+
+	// SMTPS PW
+	$var=!$var;
+	if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_SMTPS_PW").'</td><td>'.preg_replace('/./','*',$conf->global->MAIN_MAIL_SMTPS_PW).'</td></tr>';
+	}
+
+	// TLS
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
+	if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps')
+	{
+		if (function_exists('openssl_open'))
+		{
+			print yn($conf->global->MAIN_MAIL_EMAIL_TLS);
+		}
+		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
+	}
+	else print yn(0).' ('.$langs->trans("NotSupported").')';
+	print '</td></tr>';
+
+	// Separator
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td colspan="2">&nbsp;</td></tr>';
+
+	// From
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>';
+	print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
+	if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail"));
+	print '</td></tr>';
+
+	// Errors To
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
+	print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
+	if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail"));
+	print '</td></tr>';
+
+	// Autocopy to
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
+	print '<td>'.$conf->global->MAIN_MAIL_AUTOCOPY_TO;
+	if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && ! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail"));
+	print '</td></tr>';
+
+	print '</table>';
+
+    // Warning 1
+    if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
+    {
+        print '<br>';
+    	if ($linuxlike)
+    	{
+    		$sendmailoption=ini_get('mail.force_extra_parameters');
+    		//print 'x'.$sendmailoption;
+    		if (empty($sendmailoption) || ! preg_match('/ba/',$sendmailoption))
+    		{
+    			print info_admin($langs->trans("SendmailOptionNotComplete"));
+    		}
+    	}
+    	// Warning 2
+   	    print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
+    }
+
+	// Boutons actions
+	print '<div class="tabsAction">';
+
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+
+	if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || ! $linuxlike)
+	{
+		if (function_exists('fsockopen') && $port && $server)
+		{
+			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testconnect">'.$langs->trans("DoTestServerAvailability").'</a>';
+		}
+	}
+	else
+	{
+		print '<a class="butActionRefused" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
+	}
+
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
+
+	if ($conf->fckeditor->enabled)
+	{
+		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&amp;mode=init">'.$langs->trans("DoTestSendHTML").'</a>';
+	}
+
+	print '</div>';
+
+
+	// Run the test to connect
+	if ($action == 'testconnect')
+	{
+		print '<br>';
+		print_titre($langs->trans("DoTestServerAvailability"));
+
+		// If we use SSL/TLS
+		if (! empty($conf->global->MAIN_MAIL_EMAIL_TLS) && function_exists('openssl_open')) $server='ssl://'.$server;
+
+		include_once(DOL_DOCUMENT_ROOT."/core/class/CMailFile.class.php");
+		$mail = new CMailFile('','','','');
+		$result=$mail->check_server_port($server,$port);
+		if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort",$server,$port).'</div>';
+		else
+		{
+			print '<div class="error">'.$langs->trans("ServerNotAvailableOnIPOrPort",$server,$port);
+			if ($mail->error) print ' - '.$mail->error;
+			print '</div>';
+		}
+		print '<br>';
+	}
+
+	// Affichage formulaire de TEST simple
+	if ($action == 'test')
+	{
+		print '<br>';
+		print_titre($langs->trans("DoTestSend"));
+
+		// Cree l'objet formulaire mail
+		include_once(DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php");
+		$formmail = new FormMail($db);
+		$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->withfromreadonly=0;
+		$formmail->withsubstit=0;
+		$formmail->withfrom=1;
+		$formmail->witherrorsto=1;
+		$formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1));
+		$formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1);       // ! empty to keep field if empty
+		$formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1);    // ! empty to keep field if empty
+		$formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test"));
+		$formmail->withtopicreadonly=0;
+		$formmail->withfile=2;
+		$formmail->withbody=(isset($_POST['message'])?$_POST['message']:$langs->trans("PredefinedMailTest"));
+		$formmail->withbodyreadonly=0;
+		$formmail->withcancel=1;
+		$formmail->withdeliveryreceipt=1;
+		$formmail->withfckeditor=0;
+		// Tableau des substitutions
+		$formmail->substit=$substitutionarrayfortest;
+		// Tableau des parametres complementaires du post
+		$formmail->param["action"]="send";
+		$formmail->param["models"]="body";
+		$formmail->param["mailid"]=0;
+		$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
+
+		// Init list of files
+        if (GETPOST("mode")=='init')
+		{
+			$formmail->clear_attached_files();
+		}
+
+		$formmail->show_form('addfile','removefile');
+
+		print '<br>';
+	}
+
+	// Affichage formulaire de TEST HTML
+	if ($action == 'testhtml')
+	{
+		print '<br>';
+		print_titre($langs->trans("DoTestSendHTML"));
+
+		// Cree l'objet formulaire mail
+		include_once(DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php");
+		$formmail = new FormMail($db);
+		$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->withfromreadonly=0;
+		$formmail->withsubstit=0;
+		$formmail->withfrom=1;
+		$formmail->witherrorsto=1;
+		$formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1));
+		$formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1);       // ! empty to keep field if empty
+		$formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1);    // ! empty to keep field if empty
+		$formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test"));
+		$formmail->withtopicreadonly=0;
+		$formmail->withfile=2;
+		$formmail->withbody=(isset($_POST['message'])?$_POST['message']:$langs->trans("PredefinedMailTestHtml"));
+		//$formmail->withbody='Test <b>aaa</b> __LOGIN__';
+		$formmail->withbodyreadonly=0;
+		$formmail->withcancel=1;
+		$formmail->withdeliveryreceipt=1;
+		$formmail->withfckeditor=1;
+		// Tableau des substitutions
+		$formmail->substit=$substitutionarrayfortest;
+		// Tableau des parametres complementaires du post
+		$formmail->param["action"]="sendhtml";
+		$formmail->param["models"]="body";
+		$formmail->param["mailid"]=0;
+		$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
+
+		// Init list of files
+        if (GETPOST("mode")=='init')
+		{
+			$formmail->clear_attached_files();
+		}
+
+		$formmail->show_form('addfilehtml','removefilehtml');
+
+		print '<br>';
+	}
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 279 - 0
dolicloudimages/dolibarr/src/htdocs/admin/menus.php

@@ -0,0 +1,279 @@
+<?php
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *      \file       htdocs/admin/menus.php
+ *      \ingroup    core
+ *      \brief      Page to setup menu manager to use
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$action=GETPOST('action');
+
+$langs->load("companies");
+$langs->load("products");
+$langs->load("admin");
+$langs->load("users");
+$langs->load("other");
+
+// Security check
+if (!$user->admin) accessforbidden();
+
+$dirstandard = array("/core/menus/standard");
+$dirsmartphone = array("/core/menus/smartphone");
+foreach($conf->menus_modules as $dir)
+{
+    $dirstandard[]=$dir.'standard';
+    $dirsmartphone[]=$dir.'standard';
+}
+
+
+// Cette page peut etre longue. On augmente le delai autorise.
+// Ne fonctionne que si on est pas en safe_mode.
+$err=error_reporting();
+error_reporting(0);     // Disable all errors
+//error_reporting(E_ALL);
+@set_time_limit(300);   // Need more than 240 on Windows 7/64
+error_reporting($err);
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update' && empty($_POST["cancel"]))
+{
+	$_SESSION["mainmenu"]="home";   // Le gestionnaire de menu a pu changer
+
+	dolibarr_set_const($db, "MAIN_MENU_STANDARD",      $_POST["MAIN_MENU_STANDARD"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_MENU_SMARTPHONE",     $_POST["MAIN_MENU_SMARTPHONE"],'chaine',0,'',$conf->entity);
+
+	dolibarr_set_const($db, "MAIN_MENUFRONT_STANDARD", $_POST["MAIN_MENUFRONT_STANDARD"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_MENUFRONT_SMARTPHONE",$_POST["MAIN_MENUFRONT_SMARTPHONE"],'chaine',0,'',$conf->entity);
+
+	// Define list of menu handlers to initialize
+	$listofmenuhandler=array();
+	$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_STANDARD"])]=1;
+	$listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_STANDARD"])]=1;
+	if (isset($_POST["MAIN_MENU_SMARTPHONE"]))      $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENU_SMARTPHONE"])]=1;
+	if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
+
+	// Initialize menu handlers
+	$error=0; $errmsgs=array();
+	foreach ($listofmenuhandler as $key => $val)
+	{
+		// Load sql init_menu_handler.sql file
+        $dir = "/core/menus/";
+	    $file='init_menu_'.$key.'.sql';
+	    $fullpath=dol_buildpath($dir.$file);
+
+		if (file_exists($fullpath))
+		{
+			$db->begin();
+
+			$result=run_sql($fullpath,1,'',1,$key,'none');
+			if ($result > 0)
+			{
+				$db->commit();
+			}
+			else
+			{
+				$error++;
+				$errmsgs[]='Failed to initialize menu '.$key.'.';
+				$db->rollback();
+			}
+		}
+	}
+
+	if (! $error)
+	{
+		$db->close();
+
+		// We make a header redirect because we need to change menu NOW.
+		header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	}
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formadmin=new FormAdmin($db);
+
+$wikihelp='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+print_fiche_titre($langs->trans("Menus"),'','setup');
+
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
+$head[$h][1] = $langs->trans("MenuHandlers");
+$head[$h][2] = 'handler';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
+$head[$h][1] = $langs->trans("MenuAdmin");
+$head[$h][2] = 'editor';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
+$head[$h][1] = $langs->trans("Miscellanous");
+$head[$h][2] = 'misc';
+$h++;
+
+
+dol_fiche_head($head, 'handler', $langs->trans("Menus"));
+
+print $langs->trans("MenusDesc")."<br>\n";
+print "<br>\n";
+
+
+if (isset($_GET["action"]) && $_GET["action"] == 'edit')
+{
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+	print '<input type="hidden" name="action" value="update">';
+
+	clearstatcache();
+
+	// Gestionnaires de menu
+	$var=true;
+
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
+	print '<td>';
+	print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
+	print '</td>';
+	print '<td>';
+	print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
+	print '</td>';
+	print '</tr>';
+
+	// Menu top
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
+	print '<td>';
+	print $formadmin->select_menu(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED, 'MAIN_MENU_STANDARD', $dirstandard, empty($conf->global->MAIN_MENU_STANDARD_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '<td>';
+	print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED, 'MAIN_MENUFRONT_STANDARD', $dirstandard, empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '</tr>';
+
+	// Menu smartphone
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
+	print '<td>';
+	print $formadmin->select_menu(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED, 'MAIN_MENU_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '<td>';
+	print $formadmin->select_menu(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED, 'MAIN_MENUFRONT_SMARTPHONE', array_merge($dirstandard,$dirsmartphone), empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?'':' disabled="disabled"');
+	print '</td>';
+	print '</tr>';
+
+	print '</table>';
+
+	print '<br><center>';
+	print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
+	print ' &nbsp; &nbsp; ';
+	print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
+	print '</center>';
+
+	print '</form>';
+}
+else
+{
+	// Gestionnaires de menu
+	$var=true;
+
+	print '<table class="noborder" width="100%">';
+	print '<tr class="liste_titre"><td width="35%">'.$langs->trans("Menu").'</td>';
+	print '<td>';
+	print $form->textwithpicto($langs->trans("InternalUsers"),$langs->trans("InternalExternalDesc"));
+	print '</td>';
+	print '<td>';
+	print $form->textwithpicto($langs->trans("ExternalUsers"),$langs->trans("InternalExternalDesc"));
+	print '</td>';
+	print '</tr>';
+
+	$var=!$var;
+	print '<tr '.$bc[$var].'><td>'.$langs->trans("DefaultMenuManager").'</td>';
+	print '<td>';
+	$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_STANDARD_FORCED)?$conf->global->MAIN_MENU_STANDARD:$conf->global->MAIN_MENU_STANDARD_FORCED));
+	print $filelib;
+	print '</td>';
+	print '<td>';
+	$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_STANDARD_FORCED)?$conf->global->MAIN_MENUFRONT_STANDARD:$conf->global->MAIN_MENUFRONT_STANDARD_FORCED));
+	print $filelib;
+	print '</td>';
+	print '</tr>';
+
+	$var=!$var;
+	print '<tr '.$bc[$var].'>';
+	print '<td>'.$langs->trans("DefaultMenuSmartphoneManager").'</td>';
+	print '<td>';
+	$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED)?$conf->global->MAIN_MENU_SMARTPHONE:$conf->global->MAIN_MENU_SMARTPHONE_FORCED));
+	print $filelib;
+	if (preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE_FORCED)
+	|| (empty($conf->global->MAIN_MENU_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENU_SMARTPHONE)))
+	{
+		print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
+	}
+	print '</td>';
+	print '<td>';
+	$filelib=preg_replace('/.php$/i','',(empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)?$conf->global->MAIN_MENUFRONT_SMARTPHONE:$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED));
+	print $filelib;
+	if (preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED)
+	|| (empty($conf->global->MAIN_MENUFRONT_SMARTPHONE_FORCED) && preg_match('/smartphone/',$conf->global->MAIN_MENUFRONT_SMARTPHONE)))
+	{
+		print ' '.img_warning($langs->transnoentitiesnoconv("ThisForceAlsoTheme"));
+	}
+	print '</td>';
+	print '</tr>';
+
+	print '</table>';
+}
+
+print '</div>';
+
+
+dol_htmloutput_errors('',$errmsgs);
+
+
+if (! isset($_GET["action"]) || $_GET["action"] != 'edit')
+{
+	print '<div class="tabsAction">';
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+	print '</div>';
+}
+
+
+llxFooter();
+
+$db->close();
+?>

+ 440 - 0
dolicloudimages/dolibarr/src/htdocs/admin/menus/edit.php

@@ -0,0 +1,440 @@
+<?php
+/* Copyright (C) 2007      Patrick Raguin       <patrick.raguin@gmail.com>
+ * Copyright (C) 2007-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2011 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *		\file       htdocs/admin/menus/edit.php
+ *		\ingroup    core
+ *		\brief      Tool to edit menus
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/menubase.class.php");
+
+
+$langs->load("admin");
+
+if (! $user->admin) accessforbidden();
+
+$dirstandard = "/core/menus/standard";
+$dirsmartphone = "/core/menus/smartphone";
+
+$dirmenu = array($dirstandard,$dirsmartphone);
+
+$action=GETPOST('action');
+$mesg=GETPOST('mesg');
+
+$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
+$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
+$menu_handler_top=preg_replace('/_backoffice.php/i','',$menu_handler_top);
+$menu_handler_top=preg_replace('/_frontoffice.php/i','',$menu_handler_top);
+$menu_handler_smartphone=preg_replace('/_backoffice.php/i','',$menu_handler_smartphone);
+$menu_handler_smartphone=preg_replace('/_frontoffice.php/i','',$menu_handler_smartphone);
+
+$menu_handler=$menu_handler_top;
+
+if ($_REQUEST["handler_origine"]) $menu_handler=$_REQUEST["handler_origine"];
+if ($_REQUEST["menu_handler"])    $menu_handler=$_REQUEST["menu_handler"];
+
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'update')
+{
+    if (! $_POST['cancel'])
+    {
+        $menu = new Menubase($db);
+        $result=$menu->fetch($_POST['menuId']);
+        if ($result > 0)
+        {
+            $menu->titre=$_POST['titre'];
+            $menu->leftmenu=$_POST['leftmenu'];
+            $menu->url=$_POST['url'];
+            $menu->langs=$_POST['langs'];
+            $menu->position=$_POST['position'];
+            $menu->enabled=$_POST['enabled'];
+            $menu->perms=$_POST['perms'];
+            $menu->target=$_POST['target'];
+            $menu->user=$_POST['user'];
+            $result=$menu->update($user);
+            if ($result > 0)
+            {
+                $mesg='<div class="ok">'.$langs->trans("RecordModifiedSuccessfully").'</div>';
+            }
+            else
+            {
+                $mesg='<div class="error">'.$menu->error.'</div>';
+            }
+        }
+        else
+        {
+            $mesg='<div class="error">'.$menu->error.'</div>';
+        }
+        $_GET["menuId"] = $_POST['menuId'];
+        $action = "edit";
+    }
+    else
+    {
+        header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
+        exit;
+    }
+
+    if ($_GET['return'])
+    {
+        header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
+        exit;
+    }
+}
+
+if ($action == 'add')
+{
+    if ($_POST['cancel'])
+    {
+        header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$menu_handler);
+        exit;
+    }
+
+    $langs->load("errors");
+
+    $error=0;
+    if (! $error && ! $_POST['menu_handler'])
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("MenuHandler")).'</div>';
+        $action = 'create';
+        $error++;
+    }
+    if (! $error && ! $_POST['type'])
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("Type")).'</div>';
+        $action = 'create';
+        $error++;
+    }
+    if (! $error && ! $_POST['url'])
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Url")).'</div>';
+        $action = 'create';
+        $error++;
+    }
+    if (! $error && ! $_POST['titre'])
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("Title")).'</div>';
+        $action = 'create';
+        $error++;
+    }
+    if (! $error && $_POST['menuId'] && $_POST['type'] == 'top')
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorTopMenuMustHaveAParentWithId0").'</div>';
+        $action = 'create';
+        $error++;
+    }
+    if (! $error && ! $_POST['menuId'] && $_POST['type'] == 'left')
+    {
+        $mesg='<div class="error">'.$langs->trans("ErrorLeftMenuMustHaveAParentId").'</div>';
+        $action = 'create';
+        $error++;
+    }
+
+    if (! $error)
+    {
+        $menu = new Menubase($db);
+        $menu->fk_menu=$_POST['menuId'];
+        $menu->menu_handler=$_POST['menu_handler'];
+        $menu->type=$_POST['type'];
+        $menu->titre=$_POST['titre'];
+        $menu->leftmenu=$_POST['leftmenu'];
+        $menu->url=$_POST['url'];
+        $menu->langs=$_POST['langs'];
+        $menu->position=$_POST['position'];
+        $menu->enabled=$_POST['enabled'];
+        $menu->perms=$_POST['perms'];
+        $menu->target=$_POST['target'];
+        $menu->user=$_POST['user'];
+        $result=$menu->create($user);
+        if ($result > 0)
+        {
+            header("Location: ".DOL_URL_ROOT."/admin/menus/index.php?menu_handler=".$_POST['menu_handler']);
+            exit;
+        }
+        else
+        {
+            $action = 'create';
+            $mesg='<div class="error">'.$menu->error.'</div>';
+        }
+    }
+}
+
+// delete
+if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes')
+{
+    $this->db->begin();
+
+    $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".$_GET['menuId'];
+    $db->query($sql);
+
+    if ($result == 0)
+    {
+        $this->db->commit();
+
+        llxHeader();
+        print '<div class="ok">'.$langs->trans("MenuDeleted").'</div>';
+        llxFooter();
+        exit ;
+    }
+    else
+    {
+        $this->db->rollback();
+
+        $reload = 0;
+        $_GET["action"]='';
+    }
+}
+
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formadmin=new FormAdmin($db);
+
+llxHeader('',$langs->trans("Menu"));
+
+
+if ($action == 'create')
+{
+    print '<script type="text/javascript" language="javascript">
+    jQuery(document).ready(function() {
+    	function init_topleft()
+    	{
+    		if (jQuery("#topleft").val() == \'top\')
+    		{
+	    		jQuery("#menuId").attr(\'disabled\',\'disabled\');
+	    		jQuery("#menuId").val(\'\');
+			}
+    		else
+    		{
+    			jQuery("#menuId").removeAttr(\'disabled\');
+    		}
+    	}
+    	init_topleft();
+    	jQuery("#topleft").click(function() {
+    		init_topleft();
+    	});
+    });
+    </script>';
+
+    print_fiche_titre($langs->trans("NewMenu"),'','setup');
+
+    print '<form action="./edit.php?action=add&menuId='.$_GET['menuId'].'" method="post" name="formmenucreate">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+    print '<table class="border" width="100%">';
+
+    // Id
+    $parent_rowid = $_GET['menuId'];
+    if ($_GET['menuId'])
+    {
+        $sql = "SELECT m.rowid, m.mainmenu, m.level, m.langs FROM ".MAIN_DB_PREFIX."menu as m WHERE m.rowid = ".$_GET['menuId'];
+        $res  = $db->query($sql);
+        if ($res)
+        {
+
+            while ($menu = $db->fetch_array($res))
+            {
+                $parent_rowid = $menu['rowid'];
+                $parent_mainmenu = $menu['mainmenu'];
+                $parent_langs = $menu['langs'];
+                $parent_level = $menu['level'];
+            }
+        }
+    }
+
+    // Handler
+    print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td>';
+    print '<td>';
+    print $formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu);
+    print '</td>';
+    print '<td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
+
+    //User
+    print '<tr><td nowrap="nowrap" class="fieldrequired">'.$langs->trans('MenuForUsers').'</td>';
+    print '<td><select class="flat" name="user">';
+    print '<option value="2" selected>'.$langs->trans("AllMenus").'</option>';
+    print '<option value="0">'.$langs->trans('Interne').'</option>';
+    print '<option value="1">'.$langs->trans('Externe').'</option>';
+    print '</select></td>';
+    print '<td>'.$langs->trans('DetailUser').'</td></tr>';
+
+    // Type
+    print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>';
+    if ($parent_rowid)
+    {
+        print 'Left';
+        print '<input type="hidden" name="type" value="left">';
+    }
+    else
+    {
+        print '<select name="type" class="flat" id="topleft">';
+        print '<option value="">&nbsp;</option>';
+        print '<option value="top"'.($_POST["type"] && $_POST["type"]=='top'?' selected="true"':'').'>Top</option>';
+        print '<option value="left"'.($_POST["type"] && $_POST["type"]=='left'?' selected="true"':'').'>Left</option>';
+        print '</select>';
+    }
+    //	print '<input type="text" size="50" name="type" value="'.$type.'">';
+    print '</td><td>'.$langs->trans('DetailType').'</td></tr>';
+
+    // MenuId Parent
+    print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>';
+    if ($parent_rowid)
+    {
+        print '<td>'.$parent_rowid.'<input type="hidden" name="menuId" value="'.$parent_rowid.'"></td>';
+    }
+    else
+    {
+        print '<td><input type="text" size="8" id="menuId" name="menuId" value="'.($parent_rowid?$parent_rowid:'').'"></td>';
+    }
+    print '<td>'.$langs->trans('DetailMenuIdParent').'</td></tr>';
+
+    // Title
+    print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" size="30" name="titre" value="'.$_POST["titre"].'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
+
+    // Langs
+    print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" size="30" name="langs" value="'.$parent_langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
+
+    // Position
+    print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" size="5" name="position" value="'.(isset($_POST["position"])?$_POST["position"]:100).'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
+
+    // URL
+    print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" size="60" name="url" value="'.$_POST["url"].'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
+
+    // Target
+    print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
+    print '<option value=""'.($menu->target==""?' selected="true"':'').'>'.$langs->trans('').'</option>';
+    print '<option value="_blank"'.($menu->target=="_blank"?' selected="true"':'').'>'.$langs->trans('_blank').'</option>';
+    print '</select></td></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
+
+    // Enabled
+    print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" size="60" name="enabled" value="'.$_POST["enabled"].'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
+
+    // Perms
+    print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" size="60" name="perms" value="'.$_POST["perms"].'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
+
+    print '</table>';
+
+    // Boutons
+    print '<center><br><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
+    print ' &nbsp; &nbsp; ';
+    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
+
+    print '</form>';
+
+    dol_htmloutput_mesg($mesg);
+}
+elseif ($action == 'edit')
+{
+    print_fiche_titre($langs->trans("ModifMenu"),'','setup');
+    print '<br>';
+
+    print '<form action="./edit.php?action=update" method="POST" name="formmenuedit">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="handler_origine" value="'.$menu_handler.'">';
+    print '<input type="hidden" name="menuId" value="'.$_GET['menuId'].'">';
+
+    print '<table class="border" width="100%">';
+
+    $menu = new Menubase($db);
+    $result=$menu->fetch($_GET['menuId']);
+    //var_dump($menu);
+
+    // Id
+    print '<tr><td>'.$langs->trans('Id').'</td><td>'.$menu->id.'</td><td>'.$langs->trans('DetailId').'</td></tr>';
+
+    // Module
+    print '<tr><td>'.$langs->trans('MenuModule').'</td><td>'.$menu->module.'</td><td>'.$langs->trans('DetailMenuModule').'</td></tr>';
+
+    // Handler
+    print '<tr><td class="fieldrequired">'.$langs->trans('MenuHandler').'</td><td>'.$menu->menu_handler.'</td><td>'.$langs->trans('DetailMenuHandler').'</td></tr>';
+
+    // User
+    print '<tr><td nowrap="nowrap" class="fieldrequired">'.$langs->trans('MenuForUsers').'</td><td><select class="flat" name="user">';
+    print '<option value="2"'.($menu->user==2?' selected="true"':'').'>'.$langs->trans("All").'</option>';
+    print '<option value="0"'.($menu->user==0?' selected="true"':'').'>'.$langs->trans('Interne').'</option>';
+    print '<option value="1"'.($menu->user==1?' selected="true"':'').'>'.$langs->trans('Externe').'</option>';
+    print '</select></td><td>'.$langs->trans('DetailUser').'</td></tr>';
+
+    // Type
+    print '<tr><td class="fieldrequired">'.$langs->trans('Type').'</td><td>'.$menu->type.'</td><td>'.$langs->trans('DetailType').'</td></tr>';
+
+    // MenuId Parent
+    print '<tr><td class="fieldrequired">'.$langs->trans('MenuIdParent').'</td>';
+    //$menu_handler
+    //print '<td><input type="text" size="50" name="handler" value="all"></td>';
+    print '<td>'.$menu->fk_menu.'</td>';
+    print '<td>'.$langs->trans('DetailMenuIdParent').'</td></tr>';
+
+    // Niveau
+    //print '<tr><td>'.$langs->trans('Level').'</td><td>'.$menu->level.'</td><td>'.$langs->trans('DetailLevel').'</td></tr>';
+
+    // Titre
+    print '<tr><td class="fieldrequired">'.$langs->trans('Title').'</td><td><input type="text" size="30" name="titre" value="'.$menu->titre.'"></td><td>'.$langs->trans('DetailTitre').'</td></tr>';
+
+    // Langs
+    print '<tr><td>'.$langs->trans('LangFile').'</td><td><input type="text" size="30" name="langs" value="'.$menu->langs.'"></td><td>'.$langs->trans('DetailLangs').'</td></tr>';
+
+    // Position
+    print '<tr><td>'.$langs->trans('Position').'</td><td><input type="text" size="5" name="position" value="'.$menu->position.'"></td><td>'.$langs->trans('DetailPosition').'</td></tr>';
+
+    // Url
+    print '<tr><td class="fieldrequired">'.$langs->trans('URL').'</td><td><input type="text" size="60" name="url" value="'.$menu->url.'"></td><td>'.$langs->trans('DetailUrl').'</td></tr>';
+
+    // Target
+    print '<tr><td>'.$langs->trans('Target').'</td><td><select class="flat" name="target">';
+    print '<option value=""'.($menu->target==""?' selected="true"':'').'>'.$langs->trans('').'</option>';
+    print '<option value="_blank"'.($menu->target=="_blank"?' selected="true"':'').'>'.$langs->trans('_blank').'</option>';
+    print '</select></td><td>'.$langs->trans('DetailTarget').'</td></tr>';
+
+    // Enabled
+    print '<tr><td>'.$langs->trans('Enabled').'</td><td><input type="text" size="60" name="enabled" value="'.$menu->enabled.'"></td><td>'.$langs->trans('DetailEnabled').'</td></tr>';
+
+    // Perms
+    print '<tr><td>'.$langs->trans('Rights').'</td><td><input type="text" size="60" name="perms" value="'.$menu->perms.'"></td><td>'.$langs->trans('DetailRight').'</td></tr>';
+
+    print '</table>';
+
+    // Bouton
+    print '<center><br><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
+    print ' &nbsp; &nbsp; ';
+    print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></center>';
+
+    print '</form>';
+
+    print '<br>';
+
+    dol_htmloutput_mesg($mesg);
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 347 - 0
dolicloudimages/dolibarr/src/htdocs/admin/menus/index.php

@@ -0,0 +1,347 @@
+<?php
+/* Copyright (C) 2007      Patrick Raguin       <patrick.raguin@gmail.com>
+ * Copyright (C) 2007-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2009-2011 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       htdocs/admin/menus/index.php
+ *  \ingroup    core
+ *  \brief      Index page for menu editor
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php");
+
+$langs->load("other");
+$langs->load("admin");
+
+if (! $user->admin) accessforbidden();
+
+$dirstandard = array("/core/menus/standard");
+$dirsmartphone = array("/core/menus/smartphone");
+foreach($conf->menus_modules as $dir)
+{
+    $dirstandard[]=$dir.'standard';
+    $dirsmartphone[]=$dir.'standard';
+}
+
+$mesg=$_GET["mesg"];
+
+$menu_handler_top=$conf->global->MAIN_MENU_STANDARD;
+$menu_handler_smartphone=$conf->global->MAIN_MENU_SMARTPHONE;
+$menu_handler_top=preg_replace('/_backoffice.php/i','',$menu_handler_top);
+$menu_handler_top=preg_replace('/_frontoffice.php/i','',$menu_handler_top);
+$menu_handler_smartphone=preg_replace('/_backoffice.php/i','',$menu_handler_smartphone);
+$menu_handler_smartphone=preg_replace('/_frontoffice.php/i','',$menu_handler_smartphone);
+
+$menu_handler=$menu_handler_top;
+
+if ($_REQUEST["handler_origine"]) $menu_handler=$_REQUEST["handler_origine"];
+if ($_REQUEST["menu_handler"])    $menu_handler=$_REQUEST["menu_handler"];
+
+
+/*
+* Actions
+*/
+
+if (isset($_GET["action"]) && ($_GET["action"] == 'up'))
+{
+	$current=array();
+	$previous=array();
+
+	// Get current position
+	$sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE m.rowid = ".$_GET["menuId"];
+	dol_syslog("admin/menus/index.php ".$sql);
+	$result = $db->query($sql);
+	$num = $db->num_rows($result);
+	$i = 0;
+	while($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$current['rowid'] = $obj->rowid;
+		$current['order'] = $obj->position;
+		$current['type'] = $obj->type;
+		$current['fk_menu'] = $obj->fk_menu;
+		$i++;
+	}
+
+	// Menu before
+	$sql = "SELECT m.rowid, m.position";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE (m.position < ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid < ".$_GET["menuId"]."))";
+	$sql.= " AND m.menu_handler='".$menu_handler."'";
+	$sql.= " AND m.entity = ".$conf->entity;
+	$sql.= " AND m.type = '".$current['type']."'";
+	$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
+	$sql.= " ORDER BY m.position, m.rowid";
+	dol_syslog("admin/menus/index.php ".$sql);
+	$result = $db->query($sql);
+	$num = $db->num_rows($result);
+	$i = 0;
+	while($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$previous['rowid'] = $obj->rowid;
+		$previous['order'] = $obj->position;
+		$i++;
+	}
+
+	$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " SET m.position = ".$previous['order'];
+	$sql.= " WHERE m.rowid = ".$current['rowid']; // Up the selected entry
+	dol_syslog("admin/menus/index.php ".$sql);
+	$db->query($sql);
+	$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " SET m.position = ".($current['order']!=$previous['order']?$current['order']:$current['order']+1);
+	$sql.= " WHERE m.rowid = ".$previous['rowid']; // Descend celui du dessus
+	dol_syslog("admin/menus/index.php ".$sql);
+	$db->query($sql);
+}
+
+if (isset($_GET["action"]) && $_GET["action"] == 'down')
+{
+	$current=array();
+	$next=array();
+
+	// Get current position
+	$sql = "SELECT m.rowid, m.position, m.type, m.fk_menu";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE m.rowid = ".$_GET["menuId"];
+	dol_syslog("admin/menus/index.php ".$sql);
+	$result = $db->query($sql);
+	$num = $db->num_rows($result);
+	$i = 0;
+	while($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$current['rowid'] = $obj->rowid;
+		$current['order'] = $obj->position;
+		$current['type'] = $obj->type;
+		$current['fk_menu'] = $obj->fk_menu;
+		$i++;
+	}
+
+	// Menu after
+	$sql = "SELECT m.rowid, m.position";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE (m.position > ".($current['order'])." OR (m.position = ".($current['order'])." AND rowid > ".$_GET["menuId"]."))";
+	$sql.= " AND m.menu_handler='".$menu_handler."'";
+	$sql.= " AND m.entity = ".$conf->entity;
+	$sql.= " AND m.type = '".$current['type']."'";
+	$sql.= " AND m.fk_menu = '".$current['fk_menu']."'";
+	$sql.= " ORDER BY m.position, m.rowid";
+	dol_syslog("admin/menus/index.php ".$sql);
+	$result = $db->query($sql);
+	$num = $db->num_rows($result);
+	$i = 0;
+	while($i < $num)
+	{
+		$obj = $db->fetch_object($result);
+		$next['rowid'] = $obj->rowid;
+		$next['order'] = $obj->position;
+		$i++;
+	}
+
+	$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " SET m.position = ".($current['order']!=$next['order']?$next['order']:$current['order']+1); // Down the selected entry
+	$sql.= " WHERE m.rowid = ".$current['rowid'];
+	dol_syslog("admin/menus/index.php ".$sql);
+	$db->query($sql);
+	$sql = "UPDATE ".MAIN_DB_PREFIX."menu as m";	// Up the next entry
+	$sql.= " SET m.position = ".$current['order'];
+	$sql.= " WHERE m.rowid = ".$next['rowid'];
+	dol_syslog("admin/menus/index.php ".$sql);
+	$db->query($sql);
+}
+
+if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes')
+{
+	$db->begin();
+
+	$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu";
+	$sql.= " WHERE rowid = ".$_GET['menuId'];
+	$resql=$db->query($sql);
+	if ($resql)
+	{
+		$db->commit();
+
+		Header("Location: ".DOL_URL_ROOT.'/admin/menus/index.php?menu_handler='.$menu_handler.'&mesg='.urlencode($langs->trans("MenuDeleted")));
+		exit ;
+	}
+	else
+	{
+		$db->rollback();
+
+		$reload = 0;
+		$_GET["action"]='';
+	}
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+$formadmin=new FormAdmin($db);
+$arrayofjs=array('/admin/menus/menu.js.php?lang='.$langs->defaultlang);
+
+llxHeader('',$langs->trans("Menus"),'','',0,0,$arrayofjs);
+
+
+print_fiche_titre($langs->trans("Menus"),'','setup');
+
+
+dol_htmloutput_mesg($mesg);
+
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
+$head[$h][1] = $langs->trans("MenuHandlers");
+$head[$h][2] = 'handler';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
+$head[$h][1] = $langs->trans("MenuAdmin");
+$head[$h][2] = 'editor';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
+$head[$h][1] = $langs->trans("Miscellanous");
+$head[$h][2] = 'misc';
+$h++;
+
+dol_fiche_head($head, 'editor', $langs->trans("Menus"));
+
+print $langs->trans("MenusEditorDesc")."<br>\n";
+print "<br>\n";
+
+
+// Confirmation for remove menu entry
+if ($_GET["action"] == 'delete')
+{
+	$sql = "SELECT m.titre";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE m.rowid = ".$_GET['menuId'];
+	$result = $db->query($sql);
+	$obj = $db->fetch_object($result);
+
+    $ret=$form->form_confirm("index.php?menu_handler=".$menu_handler."&menuId=".$_GET['menuId'],$langs->trans("DeleteMenu"),$langs->trans("ConfirmDeleteMenu",$obj->titre),"confirm_delete");
+    if ($ret == 'html') print '<br>';
+}
+
+
+print '<form name="newmenu" class="nocellnopadd" action="'.$_SERVER["PHP_SELF"].'">';
+print '<input type="hidden" action="change_menu_handler">';
+print $langs->trans("MenuHandler").': ';
+print $formadmin->select_menu_families($menu_handler,'menu_handler',array_merge($dirstandard,$dirsmartphone));
+print ' &nbsp; <input type="submit" class="button" value="'.$langs->trans("Refresh").'">';
+print '</form>';
+
+print '<br>';
+
+print '<table class="border" width="100%">';
+
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("TreeMenuPersonalized").'</td>';
+print '</tr>';
+
+print '<tr>';
+print '<td>';
+
+// ARBORESCENCE
+
+$rangLast = 0;
+$idLast = -1;
+if ($conf->use_javascript_ajax)
+{
+	/*-------------------- MAIN -----------------------
+	tableau des elements de l'arbre:
+	c'est un tableau a 2 dimensions.
+	Une ligne represente un element : data[$x]
+	chaque ligne est decomposee en 3 donnees:
+	  - l'index de l'élément
+	  - l'index de l'élément parent
+	  - la chaine a afficher
+	ie: data[]= array (index, index parent, chaine )
+	*/
+	//il faut d'abord declarer un element racine de l'arbre
+
+	$data[] = array(0,-1,"racine");
+
+	//puis tous les elements enfants
+
+
+	$sql = "SELECT m.rowid, m.fk_menu, m.titre, m.langs";
+	$sql.= " FROM ".MAIN_DB_PREFIX."menu as m";
+	$sql.= " WHERE menu_handler = '".$menu_handler."'";
+	$sql.= " AND entity = ".$conf->entity;
+	$sql.= " AND fk_menu >= 0";
+	$sql.= " ORDER BY m.position, m.rowid";		// Order is position then rowid (because we need a sort criteria when position is same)
+	$res  = $db->query($sql);
+
+	if ($res)
+	{
+		$num = $db->num_rows($res);
+
+		$i = 1;
+		while ($menu = $db->fetch_array($res))
+		{
+			if (! empty($menu['langs'])) $langs->load($menu['langs']);
+			$titre = $langs->trans($menu['titre']);
+			$data[] = array($menu['rowid'],$menu['fk_menu'],$titre);
+			$i++;
+		}
+	}
+
+	// Appelle de la fonction recursive (ammorce)
+	// avec recherche depuis la racine.
+	// array($menu['rowid'],$menu['fk_menu'],$titre);
+	tree_recur($data,0,0);
+
+	print '</td>';
+
+	print '</tr>';
+
+	print '</table>';
+
+
+	print '</div>';
+
+
+	/*
+	 * Boutons actions
+	 */
+	print '<div class="tabsAction">';
+	print '<a class="butAction" href="'.DOL_URL_ROOT.'/admin/menus/edit.php?menuId=0&amp;action=create&amp;menu_handler='.urlencode($menu_handler).'">'.$langs->trans("NewMenu").'</a>';
+	print '</div>';
+}
+else
+{
+	$langs->load("errors");
+	print '<div class="error">'.$langs->trans("ErrorFeatureNeedJavascript").'</div>';
+}
+
+$db->close();
+
+print '<br>';
+
+llxFooter();

+ 225 - 0
dolicloudimages/dolibarr/src/htdocs/admin/menus/menu.js.php

@@ -0,0 +1,225 @@
+<?php
+/* Copyright (C) 2010 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *		\file       htdocs/admin/menus/menu.js.php
+ *		\brief      File for js menu
+ */
+
+
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');	// Not disabled cause need to load personalized language
+//if (! defined('NOREQUIREDB'))   define('NOREQUIREDB','1');	// Not disabled to increase speed. Language code is found on url.
+if (! defined('NOREQUIRESOC'))    define('NOREQUIRESOC','1');
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');	// Not disabled cause need to do translations
+if (! defined('NOCSRFCHECK'))     define('NOCSRFCHECK',1);
+if (! defined('NOTOKENRENEWAL'))  define('NOTOKENRENEWAL',1);
+if (! defined('NOLOGIN'))         define('NOLOGIN',1);
+if (! defined('NOREQUIREMENU'))   define('NOREQUIREMENU',1);
+if (! defined('NOREQUIREHTML'))   define('NOREQUIREHTML',1);
+if (! defined('NOREQUIREAJAX'))   define('NOREQUIREAJAX','1');
+
+session_cache_limiter(FALSE);
+
+require_once("../../master.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php");
+
+// Define css type
+header('Content-type: application/javascript');
+// Important: Following code is to avoid page request by browser and PHP CPU at
+// each Dolibarr page access.
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
+else header('Cache-Control: no-cache');
+
+// On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1.
+if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x04)) { ob_start("ob_gzhandler"); }
+
+if (GETPOST('lang')) $langs->setDefaultLang(GETPOST('lang'));  // If language was forced on URL
+if (GETPOST('theme')) $conf->theme=GETPOST('theme');  // If theme was forced on URL
+$langs->load("main",0,0);
+?>
+
+
+// Tests pour navigateurs
+var OPE = (window.opera) ? true : false;
+var IE  = (document.all && !OPE) ? true : false;
+var MOZ = (!IE && !OPE) ? true : false;
+// -----------------------------------------------------
+// Fonction d'initialisation de l'arbre
+function arbre() {
+    // Choix de la balise contenant le texte. (strong par defaut).
+    balise = "STRONG";
+    // Presentation de l'arbre au depart : deployee ('yes') ou fermee ('no')
+    extend = "no";
+    // Textes du lien plier / deplier
+    plier_text = '<?php echo $langs->transnoentities("UndoExpandAll"); ?>';
+    plier_title = 'Replier tous les noeuds de l\'arbre'
+    deplier_text = '<?php echo $langs->transnoentities("ExpandAll"); ?>';
+    deplier_title = 'Deplier tous les noeuds de l\'arbre'
+    // Recuperation de tous les arbres de la page
+    uls = getElBy('ul','class','arbre');
+    for (uli=0;uli < uls.length;uli++)
+    {
+        ul = uls[uli];
+        linkSwitch(ul);
+        processULEL(ul);
+        plier(ul,'replier');
+    }
+
+}
+
+// -------------------------------------------------------
+// Creation des liens plier /deplier tout
+function linkSwitch(ul) {
+    var a=document.createElement('a');
+    a.setAttribute('href','#');
+    if (extend=='yes') {
+        a.appendChild(document.createTextNode(plier_text));
+        a.setAttribute('title',plier_title);
+    }
+    else {
+        a.appendChild(document.createTextNode(deplier_text));
+        a.setAttribute('title',deplier_title);
+    }
+    var parbre = document.createElement('p');
+    parbre.setAttribute('class','arbre-switch');
+    parbre.appendChild(a);
+    ul.parentNode.insertBefore(parbre,ul);
+    listenlink(ul);
+}
+// Gestion des Clics sur les liens plier / deplier tout
+function listenlink(ul) {
+    var link = ul.previousSibling.childNodes[0];
+    link.onclick = function() {
+        if (this.childNodes[0].nodeValue == plier_text) {
+            plier(ul,'replier');
+            this.childNodes[0].nodeValue = deplier_text;
+            this.setAttribute('title',deplier_title);
+        }
+        else {
+            plier(ul,'deplier');
+            this.childNodes[0].nodeValue = plier_text;
+            this.setAttribute('title',plier_title);
+        }
+        return false;
+    }
+}
+// Action Plier / deplier tout
+function plier(ul,act) {
+    for (var i=0; i < ul.childNodes.length; i++) {
+        var li = ul.childNodes[i];
+        if (li.nodeName == 'LI') {
+            for (var j=0; j < li.childNodes.length; j++) {
+                var child = li.childNodes[j];
+                if (child.nodeName==balise) {
+                    var strong = child;
+                }
+                if (child.nodeName=='UL') {
+                    if (act=='replier') {
+                        child.className='hide';
+                        strong.className='arbre-plier';
+                    }
+                    else {
+                        child.className='';
+                        strong.className='arbre-deplier';
+                    }
+                    var sub = child;
+                    plier(sub,act);
+                }
+            }
+        }
+    }
+}
+// ---------------------------------------------------------
+// Analyse de l'arbre
+function processULEL(ul) {
+    if (!ul.childNodes || ul.childNodes.length == 0) return;
+    // Iterate LIs
+    for (var itemi=0;itemi < ul.childNodes.length;itemi++) {
+        var item = ul.childNodes[itemi];
+        if (item.nodeName == "LI") {
+            // Contenu des balises LI
+            var a;
+            var subul;
+            subul = "";
+            for (var sitemi=0;sitemi < item.childNodes.length;sitemi++) {
+                // Uniquement pour moz-firefox
+                if (MOZ) {item.style.background = "";}
+                // Enfants des li : balise ou sous-ul
+                var sitem = item.childNodes[sitemi];
+                switch (sitem.nodeName) {
+                    case balise:
+                        a = sitem;
+                        break;
+                    case "UL":
+                        subul = sitem;
+                        if (extend != "yes") {sitem.className = 'hide';}
+                        processULEL(subul);
+                        break;
+                }
+            }
+            if (subul) {
+                if (extend!="yes") {
+                    a.className='arbre-plier';
+                }
+                else {
+                    a.className='arbre-deplier';
+                    subul.className='';
+
+                }
+                associateEL(a,subul);
+            }
+        }
+    }
+}
+// Swicth des noeuds
+function associateEL(a,ul) {
+    a.onclick = function () {
+        this.className = (ul.className=='hide') ? 'arbre-deplier' : 'arbre-plier';
+        ul.className = (ul.className=='hide') ? '' : 'hide';
+        return false;
+    }
+}
+// -----------------------------------------------------
+// Nom  : GetElBy(tag,attr,val)
+// By   : Rui Nibau
+// Date : aout 2005
+// Func : Tableau des elements 'tag' dont l'attribut 'attr' a la valeur 'val'.
+// -----------------------------------------------------
+function getElBy(tag,attr,val) {
+	var dbRes = [];
+	var dbEl = document.getElementsByTagName(tag);
+	for (e=0; e < dbEl.length; e++) {
+		if (attr == 'class') {if (dbEl[e].className==val) {dbRes.push(dbEl[e]);}}
+		else {if (dbEl[e].getAttribute(attr)==val) {dbRes.push(dbEl[e]);}}
+	}
+	return dbRes;
+}
+// -----------------------------------------------------
+// A l'affichage de la page, lancer la fonction arbre
+window.onload = function() {
+    arbre();
+}
+
+function imgDel(id)
+{
+	var delId='del'+id;
+
+		var imgDel = document.getElementById('del'+id);
+		if (imgDel != null) imgDel.style.display='block';
+
+	return true;
+}

+ 144 - 0
dolicloudimages/dolibarr/src/htdocs/admin/menus/other.php

@@ -0,0 +1,144 @@
+<?php
+/* Copyright (C) 2010 Regis Houssin  <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/menus/other.php
+ *      \ingroup    core
+ *      \brief      Menus options setup
+ */
+
+require("../../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("users");
+$langs->load("admin");
+$langs->load("other");
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+if ($_GET["action"] == 'activate_hidemenu')
+{
+	dolibarr_set_const($db, "MAIN_MENU_HIDE_UNAUTHORIZED", '1','chaine',0,'',$conf->entity);
+	Header("Location: ".$_SERVER["PHP_SELF"]);
+	exit;
+}
+else if ($_GET["action"] == 'disable_hidemenu')
+{
+	dolibarr_del_const($db, "MAIN_MENU_HIDE_UNAUTHORIZED",$conf->entity);
+	Header("Location: ".$_SERVER["PHP_SELF"]);
+	exit;
+}
+
+if ($_GET["action"] == 'activate_layoutmenu')
+{
+	dolibarr_set_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT", '1','chaine',0,'',$conf->entity);
+	Header("Location: ".$_SERVER["PHP_SELF"]);
+	exit;
+}
+else if ($_GET["action"] == 'disable_layoutmenu')
+{
+	dolibarr_del_const($db, "MAIN_MENU_USE_JQUERY_LAYOUT",$conf->entity);
+	Header("Location: ".$_SERVER["PHP_SELF"]);
+	exit;
+}
+
+
+/*
+ * View
+ */
+
+
+llxHeader('',$langs->trans("Setup"));
+
+print_fiche_titre($langs->trans("Menus"),'','setup');
+
+
+$h = 0;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus.php";
+$head[$h][1] = $langs->trans("MenuHandlers");
+$head[$h][2] = 'handler';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/index.php";
+$head[$h][1] = $langs->trans("MenuAdmin");
+$head[$h][2] = 'editor';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT."/admin/menus/other.php";
+$head[$h][1] = $langs->trans("Miscellanous");
+$head[$h][2] = 'misc';
+$h++;
+
+dol_fiche_head($head, 'misc', $langs->trans("Menus"));
+
+
+// Other Options
+$var=true;
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td colspan="3">'.$langs->trans("Parameters").'</td>';
+print '<td align="center" width="80">'.$langs->trans("Status").'</td>';
+print '</tr>';
+
+// Hide unauthorized menu
+$var=!$var;
+print "<tr ".$bc[$var].">";
+print '<td colspan="3">'.$langs->trans("HideUnauthorizedMenu").'</td>';
+print '<td align="center">';
+if ($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED == 0)
+{
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=activate_hidemenu">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+}
+if($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED == 1)
+{
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=disable_hidemenu">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
+}
+print "</td>";
+print '</tr>';
+
+// Use a flip-hide menu
+if ($conf->global->MAIN_FEATURES_LEVEL > 0)
+{
+	$var=!$var;
+	print "<tr ".$bc[$var].">";
+	print '<td colspan="3">'.$langs->trans("MenuUseLayout").'</td>';
+	print '<td align="center">';
+	if ($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT == 0)
+	{
+		print '<a href="'.$_SERVER["PHP_SELF"].'?action=activate_layoutmenu">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
+	}
+	if($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT == 1)
+	{
+		print '<a href="'.$_SERVER["PHP_SELF"].'?action=disable_layoutmenu">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
+	}
+	print "</td>";
+	print '</tr>';
+}
+
+print '</table>';
+
+$db->close();
+
+llxFooter();
+?>

+ 493 - 0
dolicloudimages/dolibarr/src/htdocs/admin/modules.php

@@ -0,0 +1,493 @@
+<?php
+/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2004-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004      Eric Seigne          <eric.seigne@ryxeo.com>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011	   Juanjo Menent        <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *  \file       htdocs/admin/modules.php
+ *  \brief      Page to activate/disable all modules
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+
+$langs->load("errors");
+$langs->load("admin");
+
+$mode=GETPOST('mode', 'alpha');
+if (!isset($mode)) {
+	if (isset($_SESSION['mode'])) {	$mode=$_SESSION['mode'];}
+	else {$mode=0;}
+}
+$mesg=GETPOST("mesg");
+$action=GETPOST('action', 'alpha');
+$value=GETPOST('value', 'alpha');
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+if ($action == 'set' && $user->admin)
+{
+    $result=activateModule($value);
+    $mesg='';
+    if ($result) $mesg=$result;
+    Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
+	exit;
+}
+
+if ($action == 'reset' && $user->admin)
+{
+    $result=unActivateModule($value);
+    $mesg='';
+    if ($result) $mesg=$result;
+    Header("Location: modules.php?mode=".$mode."&mesg=".urlencode($mesg));
+	exit;
+}
+
+
+/*
+ * View
+ */
+
+$_SESSION["mode"]=$mode;
+
+$help_url='EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$help_url);
+
+print_fiche_titre($langs->trans("ModulesSetup"),'','setup');
+
+
+// Search modules dirs
+$modulesdir = array();
+foreach ($conf->file->dol_document_root as $type => $dirroot)
+{
+	$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
+
+	$handle=@opendir($dirroot);
+	if (is_resource($handle))
+	{
+		while (($file = readdir($handle))!==false)
+		{
+		    if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
+		    {
+		    	if (is_dir($dirroot . '/' . $file . '/core/modules/'))
+		    	{
+		    		$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
+		    	}
+		    }
+		}
+		closedir($handle);
+	}
+}
+//var_dump($modulesdir);
+
+
+$filename = array();
+$modules = array();
+$orders = array();
+$categ = array();
+$dirmod = array();
+$i = 0;	// is a sequencer of modules found
+$j = 0;	// j is module number. Automatically affected if module number not defined.
+$modNameLoaded=array();
+
+foreach ($modulesdir as $dir)
+{
+	// Load modules attributes in arrays (name, numero, orders) from dir directory
+	//print $dir."\n<br>";
+	dol_syslog("Scan directory ".$dir." for modules");
+	$handle=@opendir($dir);
+	if (is_resource($handle))
+	{
+		while (($file = readdir($handle))!==false)
+		{
+			//print "$i ".$file."\n<br>";
+		    if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod'  && substr($file, dol_strlen($file) - 10) == '.class.php')
+		    {
+		        $modName = substr($file, 0, dol_strlen($file) - 10);
+
+		        if ($modName)
+		        {
+		        	if (! empty($modNameLoaded[$modName]))
+		        	{
+		        		$mesg="Error: Module ".$modName." was found twice: Into ".$modNameLoaded[$modName]." and ".$dir.". You probably have an old file on your disk.<br>";
+		                dol_syslog($mesg, LOG_ERR);
+						continue;
+		        	}
+
+		            try
+		            {
+		                $res=include_once($dir.$file);
+		                $objMod = new $modName($db);
+						$modNameLoaded[$modName]=$dir;
+
+    		            if ($objMod->numero > 0)
+    		            {
+    		                $j = $objMod->numero;
+    		            }
+    		            else
+    		            {
+    		                $j = 1000 + $i;
+    		            }
+
+    					$modulequalified=1;
+
+    					// We discard modules according to features level (PS: if module is activated we always show it)
+    					$const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
+    					if ($objMod->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0;
+    					if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0;
+
+    					if ($modulequalified)
+    					{
+    						$modules[$i] = $objMod;
+    			            $filename[$i]= $modName;
+    			            $orders[$i]  = $objMod->family."_".$j;   // Tri par famille puis numero module
+    						//print "x".$modName." ".$orders[$i]."\n<br>";
+    						if (isset($categ[$objMod->special])) $categ[$objMod->special]++;					// Array of all different modules categories
+    			            else $categ[$objMod->special]=1;
+    						$dirmod[$i] = $dir;
+    						$j++;
+    			            $i++;
+    					}
+    					else dol_syslog("Module ".get_class($objMod)." not qualified");
+		            }
+		            catch(Exception $e)
+		            {
+		                 dol_syslog("Failed to load ".$dir.$file." ".$e->getMessage(), LOG_ERR);
+		            }
+		        }
+		    }
+		}
+		closedir($handle);
+	}
+	else
+	{
+		dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING);
+	}
+}
+
+asort($orders);
+//var_dump($orders);
+//var_dump($categ);
+//var_dump($modules);
+
+// Affichage debut page
+
+if ($mode==0) { $tagmode = 'common';      print $langs->trans("ModulesDesc")."<br>\n"; }
+if ($mode==2) { $tagmode = 'other';       print $langs->trans("ModulesSpecialDesc")."<br>\n"; }
+if ($mode==1) { $tagmode = 'interfaces';  print $langs->trans("ModulesInterfaceDesc")."<br>\n"; }
+if ($mode==3) { $tagmode = 'functional';  print $langs->trans("ModulesJobDesc")."<br>\n"; }
+if ($mode==4) { $tagmode = 'marketplace'; print $langs->trans("ModulesMarketPlaceDesc")."<br>\n"; }
+print "<br>\n";
+
+
+$h = 0;
+
+$categidx=0;    // Main
+if (! empty($categ[$categidx]))
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
+	$head[$h][1] = $langs->trans("ModulesCommon");
+	$head[$h][2] = 'common';
+	$h++;
+}
+
+$categidx=2;    // Other
+if (! empty($categ[$categidx]))
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
+	$head[$h][1] = $langs->trans("ModulesOther");
+	$head[$h][2] = 'other';
+	$h++;
+}
+
+$categidx=1;    // Interfaces
+if (! empty($categ[$categidx]))
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
+	$head[$h][1] = $langs->trans("ModulesInterfaces");
+	$head[$h][2] = 'interfaces';
+	$h++;
+}
+
+$categidx=3;    // Not used
+if (! empty($categ[$categidx]))
+{
+	$head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
+	$head[$h][1] = $langs->trans("ModulesSpecial");
+	$head[$h][2] = 'functional';
+	$h++;
+}
+
+$categidx=4;
+//if (! empty($categ[$categidx]))
+//{
+    $head[$h][0] = DOL_URL_ROOT."/admin/modules.php?mode=".$categidx;
+    $head[$h][1] = $langs->trans("ModulesMarketPlaces");
+    $head[$h][2] = 'marketplace';
+    $h++;
+//}
+
+
+dol_fiche_head($head, $tagmode, $langs->trans("Modules"));
+
+
+if ($mesg) print '<div class="error">'.$mesg.'</div>';
+
+
+if ($mode != 4)
+{
+    print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
+    //print "<tr class=\"liste_titre\">\n";
+    print '<tr class="liste_total">'."\n";
+    //print "  <td>".$langs->trans("Family")."</td>\n";
+    print "  <td colspan=\"2\">".$langs->trans("Module")."</td>\n";
+    print "  <td>".$langs->trans("Description")."</td>\n";
+    print "  <td align=\"center\">".$langs->trans("Version")."</td>\n";
+    //print "  <td align=\"center\">".$langs->trans("DbVersion")."</td>\n";
+    print "  <td align=\"center\">".$langs->trans("Status")."</td>\n";
+    print "  <td align=\"right\">".$langs->trans("SetupShort")."</td>\n";
+    print "</tr>\n";
+
+
+    // Affichage liste modules
+
+    $var=true;
+    $oldfamily='';
+
+    $familylib=array(
+    'base'=>$langs->trans("ModuleFamilyBase"),
+    'crm'=>$langs->trans("ModuleFamilyCrm"),
+    'products'=>$langs->trans("ModuleFamilyProducts"),
+    'hr'=>$langs->trans("ModuleFamilyHr"),
+    'projects'=>$langs->trans("ModuleFamilyProjects"),
+    'financial'=>$langs->trans("ModuleFamilyFinancial"),
+    'ecm'=>$langs->trans("ModuleFamilyECM"),
+    'technic'=>$langs->trans("ModuleFamilyTechnic"),
+    'other'=>$langs->trans("ModuleFamilyOther")
+    );
+
+    foreach ($orders as $key => $value)
+    {
+        $tab=explode('_',$value);
+        $family=$tab[0]; $numero=$tab[1];
+
+        $modName = $filename[$key];
+    	$objMod  = $modules[$key];
+    	//var_dump($objMod);
+
+    	if ($objMod->special != $mode) continue;    // Discard if not for tab
+        if (! $objMod->getName())
+        {
+        	dol_syslog("Error for module ".$key." - Property name of module looks empty", LOG_WARNING);
+      		continue;
+        }
+
+        $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod)));
+
+        // Load all lang files of module
+        if (isset($objMod->langfiles) && is_array($objMod->langfiles))
+        {
+        	foreach($objMod->langfiles as $domain)
+        	{
+        		$langs->load($domain);
+        	}
+        }
+
+        // Print a separator if we change family
+        //print "<tr><td>xx".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
+        //if ($oldfamily && $family!=$oldfamily && $atleastoneforfamily) {
+        if ($family!=$oldfamily) {
+            print '<tr class="liste_titre">'."\n  <td colspan=\"6\">";
+            $familytext=empty($familylib[$family])?$family:$familylib[$family];
+            print $familytext;
+            print "</td>\n</tr>\n";
+            $atleastoneforfamily=0;
+            //print "<tr><td>yy".$oldfamily."-".$family."-".$atleastoneforfamily."<br></td><tr>";
+        }
+
+        if ($objMod->special == $mode)
+        {
+            $atleastoneforfamily++;
+
+            if ($family!=$oldfamily)
+            {
+                $familytext=empty($familylib[$family])?$family:$familylib[$family];
+                //print $familytext;
+                $oldfamily=$family;
+            }
+
+            $var=!$var;
+
+            //print "\n<!-- Module ".$objMod->numero." ".$objMod->getName()." found into ".$dirmod[$key]." -->\n";
+            print '<tr height="18" '.$bc[$var].">\n";
+
+            // Picto
+            print '  <td valign="top" width="14" align="center">';
+            $alttext='';
+            //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
+            //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
+            if (! empty($objMod->picto))
+            {
+            	if (preg_match('/^\//i',$objMod->picto)) print img_picto($alttext,$objMod->picto,' width="14px"',1);
+            	else print img_object($alttext,$objMod->picto,' width="14px"');
+            }
+            else
+            {
+            	print img_object($alttext,'generic');
+            }
+            print '</td>';
+
+            // Name
+            print '<td valign="top">'.$objMod->getName();
+            print "</td>\n";
+
+            // Desc
+            print "<td valign=\"top\">";
+            print nl2br($objMod->getDesc());
+            print "</td>\n";
+
+            // Version
+            print "<td align=\"center\" valign=\"top\" nowrap=\"nowrap\">";
+            print $objMod->getVersion();
+            print "</td>\n";
+
+            // Activate/Disable and Setup (2 columns)
+            if (! empty($conf->global->$const_name))
+            {
+                $disableSetup = 0;
+
+                print "<td align=\"center\" valign=\"top\">";
+
+            	// Module actif
+                if (! empty($objMod->always_enabled) || (($conf->global->MAIN_MODULE_MULTICOMPANY && $objMod->core_enabled) && ($user->entity || $conf->entity!=1)))
+                {
+                	print $langs->trans("Required");
+                	if ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->entity) $disableSetup++;
+                	print '</td>'."\n";
+                }
+                else
+                {
+                	print '<a href="modules.php?id='.$objMod->numero.'&amp;action=reset&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
+                	print img_picto($langs->trans("Activated"),'switch_on');
+                	print '</a></td>'."\n";
+                }
+
+                if (! empty($objMod->config_page_url) && !$disableSetup)
+                {
+                    if (is_array($objMod->config_page_url))
+                    {
+                        print '  <td align="right" valign="top">';
+                        $i=0;
+                        foreach ($objMod->config_page_url as $page)
+                        {
+    						$urlpage=$page;
+                            if ($i++)
+                            {
+                                print '<a href="'.$urlpage.'" title="'.$langs->trans($page).'">'.img_picto(ucfirst($page),"setup").'</a>&nbsp;';
+                            //    print '<a href="'.$page.'">'.ucfirst($page).'</a>&nbsp;';
+                            }
+                            else
+                            {
+                            	if (preg_match('/^([^@]+)@([^@]+)$/i',$urlpage,$regs))
+                            	{
+                           			print '<a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a>&nbsp;';
+                            	}
+                            	else
+                            	{
+                            		print '<a href="'.$urlpage.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a>&nbsp;';
+                            	}
+                            }
+                        }
+                        print "</td>\n";
+                    }
+                    else if (preg_match('/^([^@]+)@([^@]+)$/i',$objMod->config_page_url,$regs))
+                    {
+                       	print '<td align="right" valign="top"><a href="'.dol_buildpath('/'.$regs[2].'/admin/'.$regs[1],1).'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a></td>';
+                    }
+                    else
+                    {
+                        print '<td align="right" valign="top"><a href="'.$objMod->config_page_url.'" title="'.$langs->trans("Setup").'">'.img_picto($langs->trans("Setup"),"setup").'</a></td>';
+                    }
+                }
+                else
+                {
+                    print "<td>&nbsp;</td>";
+                }
+
+            }
+            else
+            {
+                print "<td align=\"center\" valign=\"top\">";
+
+                if (! empty($objMod->always_enabled))
+                {
+                    // Ne devrait pas arriver.
+                }
+
+                // Module non actif
+               	print '<a href="modules.php?id='.$objMod->numero.'&amp;action=set&amp;value=' . $modName . '&amp;mode=' . $mode . '">';
+               	print img_picto($langs->trans("Disabled"),'switch_off');
+               	print "</a></td>\n  <td>&nbsp;</td>\n";
+            }
+
+            print "</tr>\n";
+        }
+
+    }
+    print "</table>\n";
+}
+else
+{
+    // Marketplace
+    print "<table summary=\"list_of_modules\" class=\"noborder\" width=\"100%\">\n";
+    print "<tr class=\"liste_titre\">\n";
+    //print '<td>'.$langs->trans("Logo").'</td>';
+    print '<td colspan="2">'.$langs->trans("WebSiteDesc").'</td>';
+    print '<td>'.$langs->trans("URL").'</td>';
+    print '</tr>';
+
+    $var=!$var;
+    print "<tr ".$bc[$var].">\n";
+    $url='http://www.dolistore.com';
+    print '<td align="left"><a href="'.$url.'" target="_blank"><img border="0" width="180" src="'.DOL_URL_ROOT.'/theme/dolistore_logo.png"></a></td>';
+    print '<td>'.$langs->trans("DoliStoreDesc").'</td>';
+    print '<td><a href="'.$url.'" target="_blank">'.$url.'</a></td>';
+    print '</tr>';
+
+
+    print "</table>\n";
+}
+
+
+dol_fiche_end();
+
+// Pour eviter bug mise en page IE
+print '<div class="tabsAction">';
+print '</div>';
+
+llxFooter();
+
+$db->close();
+?>

+ 125 - 0
dolicloudimages/dolibarr/src/htdocs/admin/notification.php

@@ -0,0 +1,125 @@
+<?php
+/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.org>
+ *
+ * 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	    \file       htdocs/admin/notification.php
+ *		\ingroup    notification
+ *		\brief      Page to setup notification module
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/triggers/interface_50_modNotification_Notification.class.php");
+
+$langs->load("admin");
+$langs->load("other");
+
+// Security check
+if (!$user->admin)
+  accessforbidden();
+
+$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
+if ($action == 'setvalue' && $user->admin)
+{
+	$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity);
+  	if ($result >= 0)
+  	{
+  		$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+  	}
+  	else
+  	{
+		$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+
+
+/*
+ *	View
+ */
+
+llxHeader();
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
+
+print $langs->trans("NotificationsDesc").'<br><br>';	
+
+print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="setvalue">';
+
+$var=true;
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td>'.$langs->trans("Value").'</td>';
+print "</tr>\n";
+$var=!$var;
+print '<tr '.$bc[$var].'><td>';
+print $langs->trans("NotificationEMailFrom").'</td><td>';
+print '<input size="32" type="text" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
+if (! empty($conf->global->NOTIFICATION_EMAIL_FROM) && ! isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) print ' '.img_warning($langs->trans("BadEMail"));
+print '</td></tr>';
+print '</table>';
+
+print '<br>';
+
+print '<center><input type="submit" class="button" value="'.$langs->trans("Modify").'"></center>';
+
+print '</form>';
+print '<br>';
+
+
+print_fiche_titre($langs->trans("ListOfAvailableNotifications"),'','');
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Module").'</td>';
+print '<td>'.$langs->trans("Code").'</td>';
+print '<td>'.$langs->trans("Label").'</td>';
+print "</tr>\n";
+
+// Load array of available notifications
+$notificationtrigger=new InterfaceNotification($db);
+$listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
+
+foreach($listofnotifiedevents as $notifiedevent)
+{
+    $var=!$var;
+    $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
+    print '<tr '.$bc[$var].'>';
+    print '<td>'.$notifiedevent['elementtype'].'</td>';
+    print '<td>'.$notifiedevent['code'].'</td>';
+    print '<td>'.$label.'</td>';
+    print '</tr>';
+}
+print '</table>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

+ 91 - 0
dolicloudimages/dolibarr/src/htdocs/admin/osc-languages.php

@@ -0,0 +1,91 @@
+<?php
+/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ *
+ * 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 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file 		htdocs/admin/osc-languages.php
+ * \ingroup    	boutique
+ * \brief      	Page d'administration/configuration du module Boutique
+ */
+
+require("../main.inc.php");
+
+$langs->load("admin");
+
+if (!$user->admin)
+accessforbidden();
+
+
+llxHeader();
+
+
+if (! dol_strlen(OSC_DB_NAME))
+{
+	print "Non dispo";
+	llxFooter();
+}
+
+if ($sortfield == "") {
+	$sortfield="lower(p.label),p.price";
+}
+if ($sortorder == "") {
+	$sortorder="ASC";
+}
+
+if ($page == -1) { $page = 0 ; }
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+
+
+print_barre_liste("Liste des langues oscommerce", $page, "osc-languages.php");
+
+$sql = "SELECT l.languages_id, l.name, l.code FROM ".$conf->global->OSC_DB_NAME.".".$conf->global->OSC_DB_TABLE_PREFIX."languages as l";
+$sql.= $db->plimit($limit, $offset);
+
+print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
+print "<tr class=\"liste_titre\">";
+print "<td>id</td>";
+print "<td>Name</td>";
+print "<td>Code</td>";
+print "</TR>\n";
+
+$resql=$db->query($sql);
+if ($resql)
+{
+	$num = $db->num_rows($resql);
+	$i = 0;
+
+	$var=True;
+	while ($i < $num) {
+		$objp = $db->fetch_object($resql);
+		$var=!$var;
+		print "<TR $bc[$var]>";
+		print "<TD>$objp->languages_id</TD>\n";
+		print "<TD>$objp->name</TD>\n";
+		print "<TD>$objp->code</TD>\n";
+		print "</TR>\n";
+		$i++;
+	}
+	$db->free();
+}
+
+print "</TABLE>";
+
+
+$db->close();
+
+llxFooter();
+?>

+ 358 - 0
dolicloudimages/dolibarr/src/htdocs/admin/pdf.php

@@ -0,0 +1,358 @@
+<?php
+/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2012 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2011 Regis Houssin        <regis@dolibarr.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/admin/pdf.php
+ *       \brief      Page to setup PDF options
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/usergroups.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/class/html.formadmin.class.php");
+
+$langs->load("admin");
+$langs->load("languages");
+$langs->load("other");
+
+$langs->load("companies");
+$langs->load("products");
+$langs->load("members");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+/*
+ * Actions
+ */
+
+if ($action == 'update')
+{
+	dolibarr_set_const($db, "MAIN_PDF_FORMAT",    $_POST["MAIN_PDF_FORMAT"],'chaine',0,'',$conf->entity);
+
+	dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS",    $_POST["MAIN_PROFID1_IN_ADDRESS"],'chaine',0,'',$conf->entity);
+    dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS",    $_POST["MAIN_PROFID2_IN_ADDRESS"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS",    $_POST["MAIN_PROFID3_IN_ADDRESS"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS",    $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity);
+	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT",    $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity);
+
+	Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
+	exit;
+}
+
+
+/*
+ * View
+ */
+
+$wikihelp='EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
+llxHeader('',$langs->trans("Setup"),$wikihelp);
+
+$form=new Form($db);
+$formother=new FormOther($db);
+$formadmin=new FormAdmin($db);
+
+print_fiche_titre($langs->trans("PDF"),'','setup');
+
+print $langs->trans("PDFDesc")."<br>\n";
+print "<br>\n";
+
+$noCountryCode = (empty($mysoc->country_code) ? true : false);
+
+if ($action == 'edit')	// Edit
+{
+    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<input type="hidden" name="action" value="update">';
+
+    clearstatcache();
+
+
+    // Misc options
+    print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
+	$var=true;
+    print '<table summary="more" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    $selected=$conf->global->MAIN_PDF_FORMAT;
+    if (empty($selected)) $selected=dol_getDefaultFormat();
+
+    // Show pdf format
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
+    print $formadmin->select_paper_format($selected,'MAIN_PDF_FORMAT');
+    print '</td></tr>';
+
+	print '</table>';
+
+	print '<br>';
+
+
+    // Addresses
+    print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
+	$var=true;
+    print '<table summary="more" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    // Show prof id 1 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
+    	if ($pid1 == '-') $pid1=false;
+    }
+    else
+    {
+    	$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid1)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
+    	print $form->selectyesno('MAIN_PROFID1_IN_ADDRESS',isset($conf->global->MAIN_PROFID1_IN_ADDRESS)?$conf->global->MAIN_PROFID1_IN_ADDRESS:0,1,$noCountryCode);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 2 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
+    	if ($pid2 == '-') $pid2=false;
+    }
+    else
+    {
+    	$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid2)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
+    	print $form->selectyesno('MAIN_PROFID2_IN_ADDRESS',isset($conf->global->MAIN_PROFID2_IN_ADDRESS)?$conf->global->MAIN_PROFID2_IN_ADDRESS:0,1,$noCountryCode);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 3 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
+    	if ($pid3 == '-') $pid3=false;
+    }
+    else
+    {
+    	$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid3)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
+    	print $form->selectyesno('MAIN_PROFID3_IN_ADDRESS',isset($conf->global->MAIN_PROFID3_IN_ADDRESS)?$conf->global->MAIN_PROFID3_IN_ADDRESS:0,1,$noCountryCode);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 4 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
+    	if ($pid4 == '-') $pid4=false;
+    }
+    else
+    {
+    	$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid4)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
+    	print $form->selectyesno('MAIN_PROFID4_IN_ADDRESS',isset($conf->global->MAIN_PROFID4_IN_ADDRESS)?$conf->global->MAIN_PROFID4_IN_ADDRESS:0,1,$noCountryCode);
+    	print '</td></tr>';
+    }
+
+	print '</table>';
+
+    print '<br>';
+
+    // Other
+    print_fiche_titre($langs->trans("Other"),'','').'<br>';
+	$var=true;
+    print '<table summary="more" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    // Hide any PDF informations
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
+	print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1);
+    print '</td></tr>';
+
+	print '</table>';
+
+    print '<br><center>';
+    print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
+    print '</center>';
+
+    print '</form>';
+    print '<br>';
+}
+else	// Show
+{
+    $var=true;
+
+    // Misc options
+    print_fiche_titre($langs->trans("DictionnaryPaperFormat"),'','').'<br>';
+	$var=true;
+    print '<table summary="more" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    // Show pdf format
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("DictionnaryPaperFormat").'</td><td>';
+
+    $pdfformatlabel='';
+    if (empty($conf->global->MAIN_PDF_FORMAT))
+    {
+        include_once(DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php');
+        $pdfformatlabel=dol_getDefaultFormat();
+    }
+    else $pdfformatlabel=$conf->global->MAIN_PDF_FORMAT;
+    if (! empty($pdfformatlabel))
+    {
+    	$sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format";
+        $sql.=" WHERE code LIKE '%".$db->escape($pdfformatlabel)."%'";
+
+        $resql=$db->query($sql);
+        if ($resql)
+        {
+            $obj=$db->fetch_object($resql);
+            $pdfformatlabel=$obj->label.' - '.round($obj->width).'x'.round($obj->height).' '.$obj->unit;
+        }
+    }
+    print $pdfformatlabel;
+    print '</td></tr>';
+
+	print '</table>';
+
+	print '<br>';
+
+	print_fiche_titre($langs->trans("PDFAddressForging"),'','').'<br>';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    // Show prof id 1 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid1=$langs->transcountry("ProfId1",$mysoc->country_code);
+    	if ($pid1 == '-') $pid1=false;
+    }
+    else
+    {
+    	$pid1 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid1)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid1.'</td><td>';
+    	print yn($conf->global->MAIN_PROFID1_IN_ADDRESS,1);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 2 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid2=$langs->transcountry("ProfId2",$mysoc->country_code);
+    	if ($pid2 == '-') $pid2=false;
+    }
+    else
+    {
+    	$pid2 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid2)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid2.'</td><td>';
+    	print yn($conf->global->MAIN_PROFID2_IN_ADDRESS,1);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 3 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid3=$langs->transcountry("ProfId3",$mysoc->country_code);
+    	if ($pid3 == '-') $pid3=false;
+    }
+    else
+    {
+    	$pid3 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid3)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid3.'</td><td>';
+    	print yn($conf->global->MAIN_PROFID3_IN_ADDRESS,1);
+    	print '</td></tr>';
+    }
+
+    // Show prof id 4 in address into pdf
+    $var=!$var;
+    if (! $noCountryCode)
+    {
+    	$pid4=$langs->transcountry("ProfId4",$mysoc->country_code);
+    	if ($pid4 == '-') $pid4=false;
+    }
+    else
+    {
+    	$pid4 = img_warning().' <font class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("CompanyCountry")).'</font>';
+    }
+    if ($pid4)
+    {
+    	print '<tr '.$bc[$var].'><td>'.$langs->trans("ShowProfIdInAddress").' - '.$pid4.'</td><td>';
+    	print yn($conf->global->MAIN_PROFID4_IN_ADDRESS,1);
+    	print '</td></tr>';
+    }
+
+    print '</table>'."\n";
+
+    print '<br>';
+
+    // Other
+    print_fiche_titre($langs->trans("Other"),'','').'<br>';
+	$var=true;
+    print '<table summary="more" class="noborder" width="100%">';
+    print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
+
+    // Hide any PDF informations
+    $var=!$var;
+    print '<tr '.$bc[$var].'><td>'.$langs->trans("HideAnyVATInformationOnPDF").'</td><td>';
+    print yn($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT,1);
+    print '</td></tr>';
+
+	print '</table>';
+
+
+    print '<div class="tabsAction">';
+    print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
+    print '</div>';
+	print '<br>';
+}
+
+
+$db->close();
+
+llxFooter();
+?>

+ 221 - 0
dolicloudimages/dolibarr/src/htdocs/admin/perms.php

@@ -0,0 +1,221 @@
+<?php
+/* Copyright (C) 2003      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2004-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2011      Herve Prot           <herve.prot@symeos.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *   	\file       htdocs/admin/perms.php
+ *      \ingroup    core
+ *		\brief      Page d'administration/configuration des permissions par defaut
+ */
+
+require("../main.inc.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
+
+$langs->load("admin");
+$langs->load("users");
+$langs->load("other");
+
+if (!$user->admin) accessforbidden();
+
+
+/*
+ * Actions
+ */
+
+if ($_GET["action"] == 'add')
+{
+    $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=1";
+    $sql.= " WHERE id = ".$_GET["pid"];
+    $sql.= " AND entity = ".$conf->entity;
+    $db->query($sql);
+}
+
+if ($_GET["action"] == 'remove')
+{
+    $sql = "UPDATE ".MAIN_DB_PREFIX."rights_def SET bydefault=0";
+    $sql.= " WHERE id = ".$_GET["pid"];
+    $sql.= " AND entity = ".$conf->entity;
+    $db->query($sql);
+}
+
+
+/*
+ * View
+ */
+
+llxHeader('',$langs->trans("DefaultRights"));
+
+print_fiche_titre($langs->trans("SecuritySetup"),'','setup');
+
+print $langs->trans("DefaultRightsDesc");
+print " ".$langs->trans("OnlyActiveElementsAreShown")."<br>\n";
+print "<br>\n";
+
+$head=security_prepare_head();
+
+dol_fiche_head($head, 'default', $langs->trans("Security"));
+
+
+print '<table class="noborder" width="100%">';
+
+
+$db->begin();
+
+// Charge les modules soumis a permissions
+$modules = array();
+$modulesdir = dolGetModulesDirs();
+
+foreach ($modulesdir as $dir)
+{
+    // Load modules attributes in arrays (name, numero, orders) from dir directory
+    //print $dir."\n<br>";
+    $handle=@opendir(dol_osencode($dir));
+    if (is_resource($handle))
+    {
+        while (($file = readdir($handle))!==false)
+        {
+            if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php')
+            {
+                $modName = substr($file, 0, dol_strlen($file) - 10);
+
+                if ($modName)
+                {
+                	include_once($dir.$file);
+    	            $objMod = new $modName($db);
+
+    	            // Load all lang files of module
+    	            if (isset($objMod->langfiles) && is_array($objMod->langfiles))
+    	            {
+    	            	foreach($objMod->langfiles as $domain)
+    	            	{
+    	            		$langs->load($domain);
+    	            	}
+    	            }
+    	            // Load all permissions
+    	            if ($objMod->rights_class)
+    	            {
+    	                $ret=$objMod->insert_permissions(0);
+    	                $modules[$objMod->rights_class]=$objMod;
+    	                //print "modules[".$objMod->rights_class."]=$objMod;";
+    	            }
+                }
+            }
+        }
+    }
+}
+
+$db->commit();
+
+// Affiche lignes des permissions
+$sql = "SELECT r.id, r.libelle, r.module, r.perms, r.subperms, r.bydefault";
+$sql.= " FROM ".MAIN_DB_PREFIX."rights_def as r";
+$sql.= " WHERE r.libelle NOT LIKE 'tou%'";    // On ignore droits "tous"
+$sql.= " AND entity IN (".(! empty($conf->multicompany->transverse_mode)?"1,":"").$conf->entity.")";
+if (empty($conf->global->MAIN_USE_ADVANCED_PERMS)) $sql.= " AND r.perms NOT LIKE '%_advance'";  // Hide advanced perms if option is not enabled
+$sql.= " ORDER BY r.module, r.id";
+
+$result = $db->query($sql);
+if ($result)
+{
+    $num	= $db->num_rows($result);
+    $i		= 0;
+    $var	= True;
+    $oldmod	= "";
+    
+    while ($i < $num)
+    {
+        $obj = $db->fetch_object($result);
+
+        // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
+        if (! $modules[$obj->module])
+        {
+            $i++;
+            continue;
+        }
+
+        // Check if permission we found is inside a module definition. If not, we discard it.
+        $found=false;
+        foreach($modules[$obj->module]->rights as $key => $val)
+        {
+        	$rights_class=$objMod->rights_class;
+        	if ($val[4] == $obj->perms && (empty($val[5]) || $val[5] == $obj->subperms)) 
+        	{
+        		$found=true;
+        		break;
+        	}
+        }
+		if (! $found) 
+		{
+			$i++;
+			continue;	
+		}
+
+        // Break found, it's a new module to catch
+        if ($oldmod <> $obj->module)
+        {
+        	$oldmod	= $obj->module;
+            $objMod	= $modules[$obj->module];
+            $picto	= ($objMod->picto?$objMod->picto:'generic');
+
+            print '<tr class="liste_titre">';
+            print '<td>'.$langs->trans("Module").'</td>';
+            print '<td>'.$langs->trans("Permission").'</td>';
+            print '<td align="center">'.$langs->trans("Default").'</td>';
+            print '<td align="center">&nbsp;</td>';
+            print "</tr>\n";
+        }
+
+        $var=!$var;
+        print '<tr '. $bc[$var].'>';
+
+        print '<td>'.img_object('',$picto).' '.$objMod->getName();
+        print '<a name="'.$objMod->getName().'">&nbsp;</a>';
+
+        $perm_libelle=($conf->global->MAIN_USE_ADVANCED_PERMS && ($langs->trans("PermissionAdvanced".$obj->id)!=("PermissionAdvanced".$obj->id))?$langs->trans("PermissionAdvanced".$obj->id):(($langs->trans("Permission".$obj->id)!=("Permission".$obj->id))?$langs->trans("Permission".$obj->id):$obj->libelle));
+        print '<td>'.$perm_libelle. '</td>';
+
+        print '<td align="center">';
+        if ($obj->bydefault == 1)
+        {
+            print img_picto($langs->trans("Active"),'tick');
+            print '</td><td>';
+            print '<a href="perms.php?pid='.$obj->id.'&amp;action=remove#'.$objMod->getName().'">'.img_edit_remove().'</a>';
+        }
+        else
+        {
+            print '&nbsp;';
+            print '</td><td>';
+            print '<a href="perms.php?pid='.$obj->id.'&amp;action=add#'.$objMod->getName().'">'.img_edit_add().'</a>';
+        }
+
+        print '</td></tr>';
+        $i++;
+    }
+}
+
+print '</table>';
+
+print '</div>';
+
+
+$db->close();
+
+llxFooter();
+?>

+ 275 - 0
dolicloudimages/dolibarr/src/htdocs/admin/prelevement.php

@@ -0,0 +1,275 @@
+<?PHP
+/* Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2005-2010 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2010-2012 Juanjo Menent        <jmenent@2byte.es>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *	\file       htdocs/admin/prelevement.php
+ *	\ingroup    prelevement
+ *	\brief      Page configuration des prelevements
+ */
+
+require('../main.inc.php');
+require_once(DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php");
+require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
+require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php");
+
+$langs->load("admin");
+$langs->load("withdrawals");
+
+// Security check
+if (!$user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+
+/*
+ * Actions
+ */
+
+if ($action == "set")
+{
+    $db->begin();
+    for ($i = 0 ; $i < 2 ; $i++)
+    {
+    	$res = dolibarr_set_const($db, GETPOST("nom$i",'alpha'), GETPOST("value$i",'alpha'),'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+    }
+
+    $id=GETPOST('PRELEVEMENT_ID_BANKACCOUNT','int');
+    $account = new Account($db, $id);
+
+    if($account->fetch($id)>0)
+    {
+        $res = dolibarr_set_const($db, "PRELEVEMENT_ID_BANKACCOUNT", $id,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_BANQUE", $account->code_banque,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_CODE_GUICHET", $account->code_guichet,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_NUMERO_COMPTE", $account->number,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_NUMBER_KEY", $account->cle_rib,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_IBAN", $account->iban,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_BIC", $account->bic,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+        $res = dolibarr_set_const($db, "PRELEVEMENT_RAISON_SOCIALE", $account->proprio,'chaine',0,'',$conf->entity);
+        if (! $res > 0) $error++;
+    }
+    else $error++;
+
+    if (! $error)
+    {
+        $db->commit();
+        $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
+    }
+    else
+    {
+        $db->rollback();
+        $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
+    }
+}
+
+if ($action == "addnotif")
+{
+    $bon = new BonPrelevement($db);
+    $bon->AddNotification($db,GETPOST('user','int'),$action);
+
+    Header("Location: prelevement.php");
+    exit;
+}
+
+if ($action == "deletenotif")
+{
+    $bon = new BonPrelevement($db);
+    $bon->DeleteNotificationById(GETPOST('notif','int'));
+
+    Header("Location: prelevement.php");
+    exit;
+}
+
+
+/*
+ *	View
+ */
+
+$form=new Form($db);
+
+llxHeader('',$langs->trans("WithdrawalsSetup"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+
+print_fiche_titre($langs->trans("WithdrawalsSetup"),$linkback,'setup');
+
+print '<form method="post" action="prelevement.php?action=set">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td width="30%">'.$langs->trans("Parameter").'</td>';
+print '<td width="40%">'.$langs->trans("Value").'</td>';
+print "</tr>";
+
+//User
+print '<tr class="impair"><td>'.$langs->trans("ResponsibleUser").'</td>';
+print '<td align="left">';
+print '<input type="hidden" name="nom0" value="PRELEVEMENT_USER">';
+print $form->select_users($conf->global->PRELEVEMENT_USER,'value0',1);
+print '</td>';
+print '</tr>';
+
+//Profid1 of Transmitter
+print '<tr class="pair"><td>'.$langs->trans("NumeroNationalEmetter").' - '.$langs->transcountry('ProfId1',$mysoc->country_code).'</td>';
+print '<td align="left">';
+print '<input type="hidden" name="nom1" value="PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR">';
+print '<input type="text"   name="value1" value="'.$conf->global->PRELEVEMENT_NUMERO_NATIONAL_EMETTEUR.'" size="9" ></td>';
+print '</tr>';
+
+// Bank account (from Banks module)
+print '<tr class="impair"><td>'.$langs->trans("BankToReceiveWithdraw").'</td>';
+print '<td align="left">';
+print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT,'PRELEVEMENT_ID_BANKACCOUNT',0,"courant=1",1);
+print '</td></tr>';
+print '</table>';
+print '<br>';
+
+print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
+
+print '</form>';
+
+print '<br>';
+
+/*
+ * Notifications
+ */
+
+if ($conf->global->MAIN_MODULE_NOTIFICATION)
+{
+    $langs->load("mails");
+    print_titre($langs->trans("Notifications"));
+
+    $sql = "SELECT rowid, name, firstname, fk_societe, email";
+    $sql.= " FROM ".MAIN_DB_PREFIX."user";
+    $sql.= " WHERE entity IN (0,".$conf->entity.")";
+
+    $resql=$db->query($sql);
+    if ($resql)
+    {
+        $num = $db->num_rows($resql);
+        $var = true;
+        $i = 0;
+        while ($i < $num)
+        {
+            $obj = $db->fetch_object($resql);
+            $var=!$var;
+            if (!$obj->fk_societe)
+            {
+                $username= $obj->firstname.' '.$obj->name;
+                $internalusers[$obj->rowid] = $username;
+            }
+
+            $i++;
+        }
+        $db->free($resql);
+    }
+
+    // Get list of triggers for module withdraw
+    $sql = "SELECT rowid, code, label";
+    $sql.= " FROM ".MAIN_DB_PREFIX."c_action_trigger";
+    $sql.= " WHERE elementtype = 'withdraw'";
+    $sql.= " ORDER BY rang ASC";
+
+    $resql = $db->query($sql);
+    if ($resql)
+    {
+        $num = $db->num_rows($resql);
+        $i = 0;
+        $var = false;
+        while ($i < $num)
+        {
+            $obj = $db->fetch_object($resql);
+            $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
+            $actions[$obj->rowid]=$label;
+            $i++;
+        }
+        $db->free($resql);
+    }
+
+
+    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=addnotif">';
+    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+    print '<table class="noborder" width="100%">';
+    print '<tr class="liste_titre">';
+    print '<td>'.$langs->trans("User").'</td>';
+    print '<td>'.$langs->trans("Value").'</td>';
+    print '<td align="right">'.$langs->trans("Action").'</td>';
+    print "</tr>\n";
+
+    print '<tr class="impair"><td align="left">';
+    print $form->selectarray('user',$internalusers);//  select_users(0,'user',0);
+    print '</td>';
+
+    print '<td>';
+    print $form->selectarray('action',$actions);//  select_users(0,'user',0);
+    print '</td>';
+
+    print '<td align="right"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
+}
+// List of current notifications for objet_type='withdraw'
+$sql = "SELECT u.name, u.firstname";
+$sql.= ", nd.rowid, ad.code, ad.label";
+$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
+$sql.= ", ".MAIN_DB_PREFIX."notify_def as nd";
+$sql.= ", ".MAIN_DB_PREFIX."c_action_trigger as ad";
+$sql.= " WHERE u.rowid = nd.fk_user";
+$sql.= " AND nd.fk_action = ad.rowid";
+$sql.= " AND u.entity IN (0,".$conf->entity.")";
+
+$resql = $db->query($sql);
+if ($resql)
+{
+    $num = $db->num_rows($resql);
+    $i = 0;
+    $var = false;
+    while ($i < $num)
+    {
+        $obj = $db->fetch_object($resql);
+        $var=!$var;
+
+        print "<tr $bc[$var]>";
+        print '<td>'.$obj->firstname." ".$obj->name.'</td>';
+        $label=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->label);
+        print '<td>'.$label.'</td>';
+        print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=deletenotif&amp;notif='.$obj->rowid.'">'.img_delete().'</a></td>';
+        print '</tr>';
+        $i++;
+    }
+    $db->free($resql);
+}
+
+print '</table>';
+print '</form>';
+
+dol_htmloutput_mesg($mesg);
+
+$db->close();
+
+llxFooter();
+?>

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.