diff --git a/ChangeLog b/ChangeLog index ae767c91649..bc38c9e6847 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,9 +4,20 @@ English Dolibarr ChangeLog ***** ChangeLog for 17.0.0 compared to 16.0.0 ***** +For users: +--------------- + +... + + For developers or integrators: ------------------------------ +... + + +WARNING: + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product @@ -19,25 +30,23 @@ For users: NEW: PHP 8.1 compatibility NEW: Support for recurring purchase invoices. NEW: #20292 Include German public holidays -NEW: Can show ZATCA QRCode on PDFs -NEW: Can show Swiss QR Code on PDFs +NEW: Can show ZATCA QR-Code on PDFs +NEW: Can show Swiss QR-Code on PDFs NEW: #17123 added ExtraFields for Stock Mouvement -NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties +NEW: #20609 new massaction to assign a sale representatives on a selection of thirdparties NEW: #20653 edit discount pourcentage for all lines in one shot NEW: Accept 'auto' for ref of object on import of purchase order/proposal NEW: Accountancy - Add more filters and info on page to bind accounting accounts -NEW: Accountancy - Add subledger account when we generate a transaction with a deposit invoice +NEW: Accountancy - Add subledger account when generate a transaction with a deposit invoice NEW: Accountancy - Add a massaction to preselect an account (customer and supplier list) NEW: ACE Editor is restored at same cursor position after a save. NEW: Add "addMoreActionsButtons" hook to subscription form NEW: Add an option in GUI to show a Quick add button into top menu bar -NEW: Module Recruitment - Add a public page with all list of open job positions. -NEW: Module Recruitment - Add a tab with list of application on the jobposition file. NEW: Add a workflow to auto link contract on a ticket NEW: Add column date of Signature on proposal list NEW: Add column template invoice in invoice list NEW: Add column "Total HT" to products array on document creation card -NEW: ADD configuration for text color of button action +NEW: Add configuration for text color of button action NEW: Add constant to hide categories in TakePos NEW: Add constant to show category description in TakePos NEW: Add constant to show only the products in stock in TakePos @@ -45,7 +54,7 @@ NEW: Add entity filter in exports NEW: Show the event block on recurring invoices #20870 NEW: Add filter "opportunity status" on statistics of projects. NEW: Add firstname, lastname and max number of attendees for module "Event Organization" -NEW: add margin info in proposal and order list +NEW: Add margin info in proposal and order list NEW: Add massaction "Edit Extrafield" for Product NEW: Add more fields to detect duplicate during import of thirdparties NEW: Add option to foce delivery on email for purchase order receipt to yes @@ -56,14 +65,12 @@ NEW: Add possibility with constant MAIN_LOGIN_BADCHARUNAUTHORIZED to define bad NEW: Add private and public notes on tax files. NEW: Add status "Obsolete" to KM articles NEW: Add substitutions "user numbers" -NEW: Add the possibility to add sub-BOMs to BOM NEW: allow a ticket to be automatically marked as read when created from backend. NEW: allow cut&paste as real numeric value to excel NEW: A public form to send a message and create a lead is available NEW: automatically set totally received status in reception NEW: Auto set invoice paid when adding credit not and remain to pay is 0 NEW: Availibility dictionnary has a new column unit and number -NEW: barcode rule to insert product in takepos NEW: Can change value of AWP during the inventory NEW: Can enter price with tax for predefined products on purchase objects NEW: Can filter on a thirdparty on product statistics @@ -79,7 +86,7 @@ NEW: create third-party with contact if not found on public ticket NEW: Default value for MAIN_SECURITY_CSRF_WITH_TOKEN is now 2 (GET are also protected agains CSRF attacks) NEW: deposit payment terms: add field into dictionary admin page to define default percentage of deposit. NEW: Dictionaries - add possibility to manage countries in EEC -NEW: display errors in a message box after generating documents +NEW: Display errors in a message box after generating documents NEW: Display physical and virtual stock of the products when creating OF from a BOM NEW: Display product ref in "Object link" product tab for BOM NEW: Enhance the import. Can use 'auto' for the ref (import of orders) @@ -91,10 +98,13 @@ NEW: leave requests: add field into type dictionary to block request if balance NEW: MAIN_MAIL_AUTOCOPY_TO can accept several email and special keys NEW: MAIN_SEARCH_CAT_OR_BY_DEFAULT const for search by category NEW: Mass action "Close shipments" +NEW: Module BOM - Add tabs for nets Bom +NEW: Module BOM - Add the possibility to add sub-BOMs to BOM +NEW: Module Recruitment - Add a public page with all list of open job positions. +NEW: Module Recruitment - Add a tab with list of application on the jobposition file. NEW: Module website now supports the multicompany module NEW: More mode for THEME_TOPMENU_DISABLE_IMAGE (2, 3, ...) NEW: Add option to move checkbox column as first column on Thirdparty list (only few screens) -NEW: Add tabs for nets Bom NEW: on redirect of page in website module, GET parameters are kept. NEW: optional display warning icons on ticket list NEW: option to default check "notify tier at creation" in ticket module @@ -106,15 +116,15 @@ NEW: Send email to the supplier order contact NEW: New permission to report time on timesheet. NEW: SEPA XML - option to place payment Type Info at Credit transfer Transaction level NEW: Show number of votes into the label of tab "Results" of a survey -NEW: Show product reference in Takepos NEW: Some core tables are created only at module activation NEW: split consumption line on MO NEW: stock filter in reassort lists NEW: stock limit in stock export CSV -NEW: Sub-bom are availables NEW: Supplier order - Show ref supplier of reception in linked object block NEW: support user_modif in order -NEW: TakePos - pagination on search results +NEW: TakePOS - barcode rule to insert product in TakePOS +NEW: TakePOS - pagination on search results +NEW: TakePOS - show product reference NEW: The backup tools has an "lowmemory" option for mysqldump on large database NEW: The 'reposition' class works on ajax constantonoff that make redirects NEW: Thirdparty - Add rules "customer accountancy code" is mandatory to validate invoice @@ -129,7 +139,7 @@ NEW: Added MMK currency (Myanmar Kyat) Modules NEW: Module Partnership Management -NEW: Experimental module Event Organization Management +NEW: Experimental Module Event Organization Management For developers or integrators: @@ -144,7 +154,6 @@ NEW: Suggest a way to run upgrade per entities. NEW: Support html content for multiselect component. NEW: ModuleBuilder - Add tabs view in module builder NEW: ModuleBuilder - More feature that can be modifed after module generation -NEW: Hook getNomUrl available everywhere in tooltip of ref links NEW: Identification of tr is possible with by attribute data-id on some pages NEW: Import with select boxes V2 NEW: Can update rank of invoice, proposal and order lines with API update @@ -171,6 +180,9 @@ NEW: Add a protection into PHPunit to avoid to forget a var_dump NEW: Add datem and type parameters to API to create movements NEW: Add hidden option on contract PDF line to hide qty and price NEW: Option MAIL_MASS_ACTION_ADD_LAST_IF_MAIN_DOC_NOT_FOUND to send last document in mass mailing action + +Hooks: +NEW: Hook getNomUrl available everywhere in tooltip of ref links NEW: Add hooks: selectContactListWhere hook, selectThirdpartyListWhere hook NEW: TakePos - add hooks complete product display NEW: TakePos - add hooks for cart display @@ -192,6 +204,8 @@ NEW: Add hooks select product list and select thirdparty list function NEW: Add hook to getSellPrice function +WARNING: + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * There is a new specific permission to be allowed to enter timesheets. If you use timesheet, don't forget to give the new permission (disable and enable the module project if it is not visible). @@ -209,6 +223,81 @@ Following changes may create regressions for some external modules, but were nec * The context hook 'suppliercard' when on the supplier tab of a thirdparty has been renamed into 'thirdpartysupplier' +***** ChangeLog for 15.0.3 compared to 15.0.2 ***** + +FIX: 15.0: modules cannot declare more than 1 cron job using the same method with different parameters +FIX: 15 fix graph ficheinter status +FIX: #18704 +FIX: #20444 +FIX: #20448 missing preg_replace for vat rate when adding a free line +FIX: #20476 migration postgresql 13.0.x to 14.0.x packaging type +FIX: #20487 missing letter D in constant THIRDPARTIES_DISABLE_RELATED_… +FIX: #20487 missing letter D in constant THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB +FIX: #20527 Accountancy - Unbalanced entry proposed when an employee are declared on a social contribution +FIX: #20527 Accountancy Unbalanced entry proposed when an employee are declared on social contribution +FIX: #20621 signature online with proposal with n page. +FIX: #20696 +FIX: #20828 +FIX: #20886 : manage durations in list_print_total.tpl.php +FIX: #20902 +FIX: #21051 +FIX: #21093 +FIX: #21138 +FIX: #21140 +FIX: #21174 +FIX: #21323 +FIX: #21472 On the bank transfer lists, a change of page switches to the lists of the direct debit module +FIX: #21495 +FIX: #21518 +FIX: Accountancy - Label of VAT account is empty +FIX: Accountancy - Model account list - Problem of CSRF +FIX: Accountancy - Partitioning of the entity on an automatic binding +FIX: add missing thead, th and id on table +FIX: backport commit 5b3fcc5e43979b1b0789bf81fb8f1b2b59c93056, chkbxlst cannot be emptied +FIX: Bank account not set when creating invoice from order +FIX: Bank transfer - Link on code supplier invoice was bad +FIX: Can convert a partially closed down payment when close for +FIX: class center linkedObjectblock order date +FIX: count elements in invoice list (Issue #21444) +FIX: Customer price non numeric warning when 0 vat. +FIX: errors in getLinesArray() +FIX: False alert of WAF when there is "set" into some URL action=update. +FIX: Intervention graph by status on ficheinter Index page +FIX: Intervention url link into Commerce index +FIX: Fix get origin from other than supplier proposal when add a new supplier proposal +FIX: Fix show errors in card +FIX: fourn/commande/card.php Added "$object" parameter to $formfile->showdocuments call +FIX: french traductions for payment methods +FIX: hook for dol_format_address +FIX: Index page for "Sales" give wrong URL link to Intervention +FIX: issue Dolibarr#21495 for v15 +FIX: label and get_substitutionarray_each_var_object on ODT generation +FIX: load product stock in inventory lines +FIX: missing morecss for multiselectarray +FIX: missins time spent list menu +FIX: new member subscription: bank account and payment mode might be hidden +FIX: ODT generation of BOM document +FIX: ODT tags for subobjects {object_subobject_yyy} was not working. +FIX: qty received label in Squille PDF model +FIX: rank duplicate on mass action invoice from multiple orders +FIX: regression + add $forceentity parameter +FIX: regression PR #20713 +FIX: security breach if we have same ref number in multiple entities +FIX: selection of type of invoice +FIX: Send remind to pay invoice only on validated invoices +FIX: Show sellist type of extrafield when none category selected +FIX: signature online with proposal with n page. +FIX: sql error when PRODUCT_USE_SUPPLIER_PACKAGING enabled. +FIX: sql order +FIX: trash icon on crontask list to do not work +FIX: v15 linked object block center order date +FIX: Warning on attribut +FIX: We must remove empty values of $features array in fetchByProductCombination2ValuePairs() because some products can use only several attributes in their variations and not necessarily all. In this case, fetch doesn't work without my correction +FIX: with callback function +FIX: xml file for company with special chars in name +FIX: Zatca QR code must use company name/vat + + ***** ChangeLog for 15.0.2 compared to 15.0.1 ***** FIX: #19777 #20281 @@ -489,6 +578,8 @@ NEW: we need to be able to put more filters on deleteByParentField() function NEW: make it easier to set the `keyword`, `keywords` and `description` attributes of an ecm file object NEW: Experimental feature to manage user sessions in database + +WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field diff --git a/build/README b/build/README index 626953f9376..19cf4ad1ec2 100644 --- a/build/README +++ b/build/README @@ -13,32 +13,12 @@ It is here only to build Dolibarr packages, and those generated packages will no There are several tools: +-------------------------------------------------------------------------------------------------- - To build full Dolibarr packages, launch the script > Launch command perl makepack-dolibarr.pl --------------------------------------------------------------------------------------------------- - - -Prerequisites to build tgz, debian and rpm packages: -> apt-get install tar dpkg dpatch p7zip-full rpm zip - - --------------------------------------------------------------------------------------------------- - -Prerequisites to build autoexe DoliWamp package: -> apt-get install wine q4wine -> Launch "wine cmd" to check a drive Z: pointing to / exists. -> Install InnoSetup - For example by running isetup-5.5.8.exe (https://www.jrsoftware.org) https://files.jrsoftware.org/is/5/ -> Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB - For example by running wampserver3.2.0_x64.exe (https://www.wampserver.com). - See file build/exe/doliwamp.iss to know the doliwamp version currently setup. -> Add path to ISCC into PATH windows var: - Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH -> To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded), - open file build/exe/doliwamp.iss and click on button "Compile". - The .exe file will be build into directory build. +See makepack-howto.txt for prerequisites. -------------------------------------------------------------------------------------------------- diff --git a/build/exe/doliwamp/.gitignore b/build/exe/doliwamp/.gitignore index ce74d54f78e..f9a2ea83b34 100644 --- a/build/exe/doliwamp/.gitignore +++ b/build/exe/doliwamp/.gitignore @@ -1 +1 @@ -/doliwamp.tmp.iss +/doliwamp.tmp.iss* diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index c316e0f91d6..10cc1561011 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -24,7 +24,6 @@ OutputBaseFilename=__FILENAMEEXEDOLIWAMP__ ;OutputManifestFile=build\doliwampbuild.log ; Define full path from which all relative path are defined ; You must modify this to put here your dolibarr root directory -;SourceDir=Z:\home\ldestailleur\git\dolibarrxxx SourceDir=..\..\.. AppId=doliwamp AppPublisher=DoliCloud @@ -32,7 +31,7 @@ AppPublisherURL=https://www.dolicloud.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql software. -AppCopyright=Copyright (C) 2008-2022 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2022 Laurent Destailleur (DoliCloud), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING @@ -81,7 +80,7 @@ Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm: Name: "{app}\logs" Name: "{app}\tmp" Name: "{app}\dolibarr_documents" -Name: "{app}\bin\apache\apache2.4.41\logs" +Name: "{app}\bin\apache\apache2.4.51\logs" [Files] ; Stop/start @@ -101,16 +100,10 @@ Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversi ; Apache, Php, Mysql ; Put here path of Wampserver applications -; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 -; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 -; Value OK: apache 2.4.9, php 5.5.12, mysql 5.0.45 instead of 5.6.17 (wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-32b.exe) -; Value OK: apache 2.4.41, php 7.3.12, mariadb10.4.10 (wampserver3.2.0_x64.exe) -;Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" -Source: "C:\wamp64\bin\apache\apache2.4.41\*.*"; DestDir: "{app}\bin\apache\apache2.4.41"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" -;Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" -Source: "C:\wamp64\bin\php\php7.3.12\*.*"; DestDir: "{app}\bin\php\php7.3.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" -;Source: "C:\Program Files\Wamp\bin\mysql\mysql5.0.45\*.*"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe" -Source: "C:\wamp64\bin\mariadb\mariadb10.4.10\*.*"; DestDir: "{app}\bin\mariadb\mariadb10.4.10"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe" +; Value OK: apache 2.4.51, php 7.3.33, mariadb10.6.5 (wampserver3.2.6_x64.exe) +Source: "C:\wamp64\bin\apache\apache2.4.51\*.*"; DestDir: "{app}\bin\apache\apache2.4.51"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log" +Source: "C:\wamp64\bin\php\php7.3.33\*.*"; DestDir: "{app}\bin\php\php7.3.33"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log" +Source: "C:\wamp64\bin\mariadb\mariadb10.6.5\*.*"; DestDir: "{app}\bin\mariadb\mariadb10.6.5"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe" ; Mysql data files (does not overwrite if exists) ; We must copy them because the tool mysql_install_db.exe to generate them at first install does not return to prompt so make install hang @@ -125,12 +118,10 @@ Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ". ; Config files Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; -;Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.9\conf"; Flags: ignoreversion; -Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.41\conf"; Flags: ignoreversion; +Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.51\conf"; Flags: ignoreversion; Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion; -Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mariadb\mariadb10.4.10"; Flags: ignoreversion; -;Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion; -Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php7.3.12"; Flags: ignoreversion; +Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mariadb\mariadb10.6.5"; Flags: ignoreversion; +Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php7.3.33"; Flags: ignoreversion; Source: "build\exe\doliwamp\index.php.install"; DestDir: "{app}\www"; Flags: ignoreversion; Source: "build\exe\doliwamp\install.forced.php.install"; DestDir: "{app}\www\dolibarr\htdocs\install"; Flags: ignoreversion; Source: "build\exe\doliwamp\openssl.conf"; DestDir: "{app}"; Flags: ignoreversion; @@ -236,12 +227,9 @@ procedure InitializeWizard(); begin //version des applis, a modifier pour chaque version de WampServer 2 - //apacheVersion := '2.4.9'; - //phpVersion := '5.5.12' ; - apacheVersion := '2.4.41'; - phpVersion := '7.3.12' ; - //mysqlVersion := '5.0.45'; - mysqlVersion := '10.4.10'; + apacheVersion := '2.4.51'; + phpVersion := '7.3.33' ; + mysqlVersion := '10.6.5'; smtpServer := 'localhost'; apachePort := '80'; @@ -375,9 +363,9 @@ begin // Migration of database -// datadir := pathWithSlashes+'/bin/mariadb/marradb10.4.10/data'; -// exedirold := pathWithSlashes+'/bin/mariadb/marradb10.4.10/'; -// exedirnew := pathWithSlashes+'/bin/mariadb/marradb10.4.10/'; +// datadir := pathWithSlashes+'/bin/mariadb/mariadb10.6.5/data'; +// exedirold := pathWithSlashes+'/bin/mariadb/mariadb10.6.5/'; +// exedirnew := pathWithSlashes+'/bin/mariadb/mariadb10.6.5/'; // If we have a new database version, we should only copy old my.ini file into new directory // and change only all basedir= strings to use new version. Like this, data dir is still correct. @@ -1027,7 +1015,7 @@ Filename: "{app}\rundoliwamp.bat"; Description: {cm:LaunchNow}; Flags: shellexec [UninstallDelete] Type: files; Name: "{app}\*.*" -Type: files; Name: "{app}\bin\mariadb\mariadb10.4.10\*.*" +Type: files; Name: "{app}\bin\mariadb\mariadb10.6.5\*.*" Type: filesandordirs; Name: "{app}\alias" Type: filesandordirs; Name: "{app}\apps" Type: filesandordirs; Name: "{app}\bin\apache" diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 556ce9d0a7e..3024d3b1e61 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -65,7 +65,7 @@ $DIR||='.'; $DIR =~ s/([^\/\\])[\\\/]+$/$1/; $SOURCE="$DIR/.."; $DESTI="$SOURCE/build"; -if ($SOURCE !~ /^\//) +if ($SOURCE !~ /^\// && $SOURCE !~ /^[a-z]:/i) { print "Error: Launch the script $PROG.$Extension with its full path from /.\n"; print "$PROG.$Extension aborted.\n"; @@ -76,15 +76,23 @@ if (! $ENV{"DESTIBETARC"} || ! $ENV{"DESTISTABLE"}) { print "Error: Missing environment variables.\n"; print "You must define the environment variable DESTIBETARC and DESTISTABLE to point to the\ndirectories where you want to save the generated packages.\n"; + print "$PROG.$Extension aborted.\n"; + print "\n"; + print "You can set them with\n"; + print "On Linux:\n"; + print "export DESTIBETARC='/tmp'; export DESTISTABLE='/tmp';\n"; + print "On Windows:\n"; + print "set DESTIBETARC=c:/tmp\n"; + print "set DESTISTABLE=c:/tmp\n"; + print "\n"; print "Example: DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild'\n"; print "Example: DESTISTABLE='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/stable'\n"; - print "$PROG.$Extension aborted.\n"; sleep 2; exit 1; } if (! -d $ENV{"DESTIBETARC"} || ! -d $ENV{"DESTISTABLE"}) { - print "Error: Directory of environment variable DESTIBETARC or DESTISTABLE does not exist.\n"; + print "Error: Directory of environment variable DESTIBETARC ($ENV{'DESTIBETARC'}) or DESTISTABLE ($ENV{'DESTISTABLE'}) does not exist.\n"; print "$PROG.$Extension aborted.\n"; sleep 2; exit 1; @@ -94,7 +102,7 @@ if (! -d $ENV{"DESTIBETARC"} || ! -d $ENV{"DESTISTABLE"}) # -------------- if ("$^O" =~ /linux/i || (-d "/etc" && -d "/var" && "$^O" !~ /cygwin/i)) { $OS='linux'; $CR=''; } elsif (-d "/etc" && -d "/Users") { $OS='macosx'; $CR=''; } -elsif ("$^O" =~ /cygwin/i || "$^O" =~ /win32/i) { $OS='windows'; $CR="\r"; } +elsif ("$^O" =~ /cygwin/i || "$^O" =~ /win32/i || "$^O" =~ /msys/i) { $OS='windows'; $CR="\r"; } if (! $OS) { print "Error: Can't detect your OS.\n"; print "Can't continue.\n"; @@ -390,7 +398,7 @@ if ($nboftargetok) { $olddir=getcwd(); chdir("$SOURCE"); - print "Clean $SOURCE/htdocs\n"; + print "Clean $SOURCE/htdocs/includes/autoload.php\n"; $ret=`rm -f $SOURCE/htdocs/includes/autoload.php`; $ret=`git ls-files . --exclude-standard --others`; @@ -1074,28 +1082,52 @@ if ($nboftargetok) { print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n"; unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"; - print "Check that in your Wine setup, you have created a Z: drive that point to your / directory.\n"; - + if ($OS eq 'windows') { + print "Check that ISCC.exe is in your PATH.\n"; + } else { + print "Check that in your Wine setup, you have created a Z: drive that point to your / directory.\n"; + } + $SOURCEBACK=$SOURCE; $SOURCEBACK =~ s/\//\\/g; - print "Prepare file \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss from \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.iss\"\n"; - $ret=`cat "$SOURCE/build/exe/doliwamp/doliwamp.iss" | sed -e 's/__FILENAMEEXEDOLIWAMP__/$FILENAMEEXEDOLIWAMP/g' > "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"`; + print "Prepare file \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\" from \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.iss\"\n"; + + #$ret=`cat "$SOURCE/build/exe/doliwamp/doliwamp.iss" | sed -e 's/__FILENAMEEXEDOLIWAMP__/$FILENAMEEXEDOLIWAMP/g' > "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"`; + open(IN, '<' . $SOURCE."/build/exe/doliwamp/doliwamp.iss") or die $!; + open(OUT, '>' . "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss") or die $!; + while() + { + $_ =~ s/__FILENAMEEXEDOLIWAMP__/$FILENAMEEXEDOLIWAMP/g; + print OUT $_; + } + close(IN); + close(OUT); - print "Compil exe $FILENAMEEXEDOLIWAMP.exe file from iss file \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\"\n"; - $cmd= "wine ISCC.exe \"Z:$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\""; + print "Compil exe $FILENAMEEXEDOLIWAMP.exe file from iss file \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\" on OS $OS\n"; + + if ($OS eq 'windows') { + $cmd= "ISCC.exe \"$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\""; + } else { + #$cmd= "wine ISCC.exe \"Z:$SOURCEBACK\\build\\exe\\doliwamp\\doliwamp.tmp.iss\""; + } print "$cmd\n"; $ret= `$cmd`; - #print "$ret\n"; + print "ret=$ret\n"; # Move to final dir print "Move \"$SOURCE\\build\\$FILENAMEEXEDOLIWAMP.exe\" to $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe\n"; rename("$SOURCE/build/$FILENAMEEXEDOLIWAMP.exe","$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"); print "Move $SOURCE/build/$FILENAMEEXEDOLIWAMP.exe to $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe\n"; - $ret=`mv "$SOURCE/build/$FILENAMEEXEDOLIWAMP.exe" "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"`; + + use File::Copy; + + #$ret=`mv "$SOURCE/build/$FILENAMEEXEDOLIWAMP.exe" "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"`; + $ret=move("$SOURCE/build/$FILENAMEEXEDOLIWAMP.exe", "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"); print "Remove tmp file $SOURCE/build/exe/doliwamp/doliwamp.tmp.iss\n"; - $ret=`rm "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"`; + #$ret=`rm "$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"`; + $ret=unlink("$SOURCE/build/exe/doliwamp/doliwamp.tmp.iss"); next; } @@ -1242,7 +1274,7 @@ if ($nboftargetok) { print "\n----- Summary -----\n"; foreach my $target (sort keys %CHOOSEDTARGET) { - if ($target eq '-CHKSUM') { print "Checksum was generated"; next; } + if ($target eq '-CHKSUM') { print "Checksum was generated\n"; next; } if ($CHOOSEDTARGET{$target} < 0) { print "Package $target not built (bad requirement).\n"; } else { diff --git a/build/makepack-howto.txt b/build/makepack-howto.txt index d4e37e32629..be88302cd1d 100644 --- a/build/makepack-howto.txt +++ b/build/makepack-howto.txt @@ -1,7 +1,34 @@ ----- Dolibarr Makepack How To ----- This documentation describe steps to build a BETA or RELEASE versions -of Dolibarr. There is a chapter for BETA version and a chapter for -RELEASE version. +of Dolibarr. There is a chapter for BETA version and a chapter for RELEASE version. + + +***** Prerequisites For Linux ***** + +Prerequisites to build tgz, debian and rpm packages: +> apt-get install perl tar dpkg dpatch p7zip-full rpm zip php-cli + +Prerequisites to build autoexe DoliWamp package: +> apt-get install wine q4wine +> Launch "wine cmd" to check a drive Z: pointing to / exists. +> Install InnoSetup + For example by running isetup-5.5.8.exe (https://www.jrsoftware.org) https://files.jrsoftware.org/is/5/ +> Install WampServer into "C:\wamp64" to have Apache, PHP and MariaDB + For example by running wampserver3.2.0_x64.exe (https://www.wampserver.com). + See file build/exe/doliwamp.iss to know the doliwamp version currently setup. +> Add path to ISCC into PATH windows var: + Launch wine cmd, then regedit and add entry int HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment\PATH +> To build manually the .exe from Windows (running from makepack-dolibarr.pl script is however recommanded), + open file build/exe/doliwamp.iss and click on button "Compile". + The .exe file will be build into directory build. + + +***** Prerequisites For Windows ***** + +Install Perl +Install WampServer-3.2.*-64.exe +isetup-5.5.8.exe + ***** Actions to do a BETA ***** This files describe steps made by Dolibarr packaging team to make a diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 27130244d00..1c6716408b7 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -227,6 +227,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ticket %_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/variants +%_datadir/dolibarr/htdocs/webhook %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/workstation diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index aeddd5526f8..f6d81feaea4 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -54,7 +54,7 @@ BuildRequires: desktop-file-utils Group: Applications/Productivity Requires: apache-base, apache-mod_php, php-cgi, php-cli, php-bz2, php-gd, php-ldap, php-imap, php-mysqli, php-openssl, fonts-ttf-dejavu Requires: mysql, mysql-client -%else%_datadir/dolibarr/htdocs/datapolicy +%else %if 0%{?suse_version} # Voir http://en.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros Group: Productivity/Office/Management @@ -67,7 +67,7 @@ Requires: httpd, php >= 5.3.0, php-cli, php-gd, php-ldap, php-imap, php-mbstring Requires: mysql-server, mysql Requires: php-mysqli >= 4.1.0 %endif -%endif%_datadir/dolibarr/htdocs/eventorganization +%endif %endif @@ -125,7 +125,7 @@ cui hai bisogno ed essere facile da usare. %if 0%{?sles_version} %{__rm} -rf $RPM_BUILD_ROOT -%{__mkdir} $RPM_BUILD_ROOT%_datadir/dolibarr/htdocs/datapolicy +%{__mkdir} $RPM_BUILD_ROOT% %{__mkdir} $RPM_BUILD_ROOT%{_sysconfdir} %{__mkdir} $RPM_BUILD_ROOT%{_sysconfdir}/%{name} %else @@ -308,6 +308,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ticket %_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/variants +%_datadir/dolibarr/htdocs/webhook %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/workstation diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index a1e4dffc781..a371e3ab02f 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -224,6 +224,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ticket %_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/variants +%_datadir/dolibarr/htdocs/webhook %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/workstation diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index aed2d76ed29..bd6834582ac 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -66,7 +66,7 @@ ed essere facile da usare. Programmo web, progettato per poter fornire solo ciò di cui hai bisogno ed essere facile da usare. - +%_datadir/dolibarr/htdocs/webhook #---- prep %prep @@ -235,6 +235,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/ticket %_datadir/dolibarr/htdocs/user %_datadir/dolibarr/htdocs/variants +%_datadir/dolibarr/htdocs/webhook %_datadir/dolibarr/htdocs/webservices %_datadir/dolibarr/htdocs/website %_datadir/dolibarr/htdocs/workstation diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index fd0ff2e72da..9f873195465 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -674,7 +674,7 @@ if ($id) { // Can an entry be erased or disabled ? $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default - $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); + $url = $_SERVER["PHP_SELF"].'?token='.newToken().($page ? '&page='.$page : '').'&sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : ''); if ($param) { $url .= '&'.$param; } diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 90adc84dfd5..bc229dd69f7 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -197,7 +197,7 @@ $arrayfields = array( 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1), + 't.date_validated'=>array('label'=>$langs->trans("DateValidationAndLock"), 'checked'=>1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); @@ -769,16 +769,18 @@ if ($action == 'export_file') { $form_question['separator'] = array('name'=>'separator', 'type'=>'separator'); - // If 0 or not set, we NOT check by default. - $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE)); - $form_question['notifiedvalidationdate'] = array( - 'name' => 'notifiedvalidationdate', - 'type' => 'checkbox', - 'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")), - 'value' => $checked, - ); + if (!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { + // If 0 or not set, we NOT check by default. + $checked = (isset($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) || !empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE)); + $form_question['notifiedvalidationdate'] = array( + 'name' => 'notifiedvalidationdate', + 'type' => 'checkbox', + 'label' => $langs->trans('NotifiedValidationDate', $langs->transnoentitiesnoconv("MenuAccountancyClosure")), + 'value' => $checked, + ); - $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator'); + $form_question['separator2'] = array('name'=>'separator2', 'type'=>'separator'); + } $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300, 600); } diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index d638a7c0c84..bb864fc39e3 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -166,7 +166,7 @@ $arrayfields = array( 't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1), 't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), - 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1), + 't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1, 'enabled'=>!getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")), 't.import_key'=>array('label'=>$langs->trans("ImportId"), 'checked'=>0, 'position'=>1100), ); diff --git a/htdocs/accountancy/closure/index.php b/htdocs/accountancy/closure/index.php index f02eda61bf6..a1d75440b56 100644 --- a/htdocs/accountancy/closure/index.php +++ b/htdocs/accountancy/closure/index.php @@ -112,6 +112,7 @@ if ($action == 'validate_movements_confirm' && !empty($user->rights->accounting- } } + /* * View */ @@ -178,20 +179,40 @@ for ($i = 1; $i <= 12; $i++) { } print ''.$langs->trans("Total").''; -$sql = "SELECT COUNT(b.rowid) as detail,"; -for ($i = 1; $i <= 12; $i++) { - $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; - if ($j > 12) { - $j -= 12; +if (getDolGlobalString("ACCOUNTANCY_DISABLE_CLOSURE_LINE_BY_LINE")) { + // TODO Analyse is done by finding record not into a closed period + $sql = "SELECT COUNT(b.rowid) as detail,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) { + $j -= 12; + } + $sql .= " SUM(".$db->ifsql("MONTH(b.doc_date)=".$j, "1", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; } - $sql .= " SUM(".$db->ifsql("MONTH(b.doc_date)=".$j, "1", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; + $sql .= " COUNT(b.rowid) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; + $sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; + $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy + // Loop on each closed period + $sql .= " AND b.doc_date BETWEEN 0 AND 0"; +} else { + // Analyse closed record using the unitary flag/date on each record + $sql = "SELECT COUNT(b.rowid) as detail,"; + for ($i = 1; $i <= 12; $i++) { + $j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1; + if ($j > 12) { + $j -= 12; + } + $sql .= " SUM(".$db->ifsql("MONTH(b.doc_date)=".$j, "1", "0").") AS month".str_pad($j, 2, "0", STR_PAD_LEFT).","; + } + $sql .= " COUNT(b.rowid) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; + $sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; + $sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; + $sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy + $sql .= " AND date_validated IS NULL"; } -$sql .= " COUNT(b.rowid) as total"; -$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; -$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'"; -$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'"; -$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy -$sql .= " AND date_validated IS NULL"; dol_syslog('htdocs/accountancy/closure/index.php', LOG_DEBUG); $resql = $db->query($sql); diff --git a/htdocs/accountancy/journal/expensereportsjournal.php b/htdocs/accountancy/journal/expensereportsjournal.php index c80586fa3d0..dbd1c892086 100644 --- a/htdocs/accountancy/journal/expensereportsjournal.php +++ b/htdocs/accountancy/journal/expensereportsjournal.php @@ -328,7 +328,7 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label $account_label = $accountingaccount->label; // get compte id and label diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 7c0a8b90f7d..e4c292d2670 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -457,7 +457,7 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label $label_account = $accountingaccount->label; $bookkeeping = new BookKeeping($db); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 426bc6d7795..599eeb627b5 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -479,7 +479,7 @@ if ($action == 'writebookkeeping') { foreach ($arrayofvat[$key] as $k => $mt) { if ($mt) { - $accountingaccount->fetch($k, null, true); // TODO Use a cache for label + $accountingaccount->fetch(null, $k, true); // TODO Use a cache for label $label_account = $accountingaccount->label; $bookkeeping = new BookKeeping($db); diff --git a/htdocs/accountancy/journal/variousjournal.php b/htdocs/accountancy/journal/variousjournal.php index 49b4fc2c98c..af32b85d8fa 100644 --- a/htdocs/accountancy/journal/variousjournal.php +++ b/htdocs/accountancy/journal/variousjournal.php @@ -236,7 +236,7 @@ if ($some_mandatory_steps_of_setup_were_not_done) { print ' : ' . $langs->trans("AccountancyAreaDescMisc", 4, '' . $langs->transnoentitiesnoconv("MenuAccountancy") . '-' . $langs->transnoentitiesnoconv("Setup") . "-" . $langs->transnoentitiesnoconv("MenuDefaultAccounts") . ''); print ''; } -print '
'; +print '
'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') { print ''; } diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 6199991f29c..884c6e67be2 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,14 +178,14 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { print ''; print ''.$langs->trans("Parameter").''; - print ''.$langs->trans("Value").''; + print ''.$langs->trans("Value").''; print "\n"; // Force Type $adht = new AdherentType($db); print ''; print $langs->trans("ForceMemberType"); - print ''; + print ''; $listofval = array(); $listofval += $adht->liste_array(1); $forcetype = empty($conf->global->MEMBER_NEWFORM_FORCETYPE) ? -1 : $conf->global->MEMBER_NEWFORM_FORCETYPE; @@ -197,7 +197,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { $morphys["mor"] = $langs->trans("Moral"); print ''; print $langs->trans("ForceMemberNature"); - print ''; + print ''; $forcenature = empty($conf->global->MEMBER_NEWFORM_FORCEMORPHY) ? 0 : $conf->global->MEMBER_NEWFORM_FORCEMORPHY; print $form->selectarray("MEMBER_NEWFORM_FORCEMORPHY", $morphys, $forcenature, 1); print "\n"; @@ -205,21 +205,21 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { // Amount print ''; print $langs->trans("DefaultAmount"); - print ''; - print ''; + print ''; + print ''; print "\n"; // Can edit print ''; print $langs->trans("CanEditAmount"); - print ''; + print ''; print $form->selectyesno("MEMBER_NEWFORM_EDITAMOUNT", (!empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT) ? $conf->global->MEMBER_NEWFORM_EDITAMOUNT : 0), 1); print "\n"; // Jump to an online payment page print ''; print $langs->trans("MEMBER_NEWFORM_PAYONLINE"); - print ''; + print ''; $listofval = array(); $listofval['-1'] = $langs->trans('No'); $listofval['all'] = $langs->trans('Yes').' ('.$langs->trans("VisitorCanChooseItsPaymentMode").')'; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index c60308138d2..2e04a29b69f 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1227,12 +1227,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { print ''.$langs->trans("Password").'pass).'">'; } - // Morphy - $morphys["phy"] = $langs->trans("Physical"); - $morphys["mor"] = $langs->trans("Moral"); - print ''.$langs->trans("MemberNature").''; - print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1); - print ""; // Type print ''.$langs->trans("Type").''; @@ -1244,6 +1238,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } print ""; + // Morphy + $morphys["phy"] = $langs->trans("Physical"); + $morphys["mor"] = $langs->trans("Moral"); + print ''.$langs->trans("MemberNature").''; + print $form->selectarray("morphy", $morphys, (GETPOSTISSET("morphy") ? GETPOST("morphy", 'alpha') : $object->morphy), 0, 0, 0, '', 0, 0, 0, '', '', 1); + print ""; + // Company print ''.$langs->trans("Company").'company).'">'; @@ -1511,7 +1512,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; + $labeltouse = getDolGlobalString("ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION"); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c860a19d588..dec7584b68e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -670,11 +670,10 @@ class Adherent extends CommonObject $this->town = ($this->town ? $this->town : $this->town); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); - $this->setUpperOrLowerCase(); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private); $this->url = $this->url ?clean_url($this->url, 0) : ''; - + $this->setUpperOrLowerCase(); // Check parameters if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($this->email)) { $langs->load("errors"); diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 3075225abb9..1995485eb4e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -63,6 +63,7 @@ $search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $search_filter = GETPOST("search_filter", 'alpha'); $search_status = GETPOST("search_status", 'intcomma'); +$search_morphy = GETPOST("search_morphy", 'alpha'); $search_import_key = trim(GETPOST("search_import_key", "alpha")); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -382,6 +383,9 @@ if ($search_status != '') { // Peut valoir un nombre ou liste de nombre separes par virgules $sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")"; } +if ($search_morphy != '') { + $sql .= natural_search("d.morphy", $search_morphy); +} if ($search_ref) { $sql .= natural_search("d.ref", $search_ref); } @@ -731,6 +735,11 @@ if (!empty($arrayfields['d.login']['checked'])) { } if (!empty($arrayfields['d.morphy']['checked'])) { print ''; + $arraymorphy = array('mor'=>$langs->trans("Moral"), 'phy'=>$langs->trans("Physical")); + print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1); + print ''; +} +if (!empty($arrayfields['t.libelle']['checked'])) { print ''; } if (!empty($arrayfields['t.libelle']['checked'])) { diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 6056e1320f0..3fa4c4b3e7f 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -598,7 +598,11 @@ while ($i < min($num, $limit)) { if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; } - $totalarray['val']['d.amount'] += $obj->subscription; + if (empty($totalarray['val']['d.amount'])) { + $totalarray['val']['d.amount'] = $obj->subscription; + } else { + $totalarray['val']['d.amount'] += $obj->subscription; + } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index ce36d97d06a..e3f2c7307f7 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -207,21 +207,11 @@ $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'
'; print info_admin($message); -if (!empty($conf->use_javascript_ajax)) { - print "\n".''; -} +$constname = 'MAIN_AGENDA_XCAL_EXPORTKEY'; + +// Add button to autosuggest a key +include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; +print dolJSToSetRandomPassword($constname); // End of page llxFooter(); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 57c32d79318..1a4f5873e33 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -396,7 +396,7 @@ if ($resql) { } } } else { - print $langs->trans("ChooseABarCode"); + print ''.$langs->trans("ChooseABarCode").''; } print ''; @@ -439,7 +439,7 @@ if (!isset($_SERVER['WINDIR'])) { print ''; print ''.$langs->trans("GenbarcodeLocation").''; print ''; - print ''; + print ''; if (!empty($conf->global->GENBARCODE_LOCATION) && !@file_exists($conf->global->GENBARCODE_LOCATION)) { $langs->load("errors"); print '
'.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).''; diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index 459d9c47227..b19db5a3d5e 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -466,13 +466,13 @@ print ''; //Use draft Watermark -print "
"; +print ''; print ''; -print ""; +print ''; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/bom_extrafields.php b/htdocs/admin/bom_extrafields.php index c8ebafd4be8..0691f91b592 100644 --- a/htdocs/admin/bom_extrafields.php +++ b/htdocs/admin/bom_extrafields.php @@ -64,7 +64,7 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; * View */ - +$help_url = ''; llxHeader('', $langs->trans("BOMsSetup"), $help_url); diff --git a/htdocs/admin/clicktodial.php b/htdocs/admin/clicktodial.php index 326e7028bbf..8f98b4d25e9 100644 --- a/htdocs/admin/clicktodial.php +++ b/htdocs/admin/clicktodial.php @@ -47,8 +47,9 @@ if (!in_array('clicktodial', $conf->modules)) { if ($action == 'setvalue' && $user->admin) { $result1 = dolibarr_set_const($db, "CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", GETPOST("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS"), 'chaine', 0, '', $conf->entity); $result2 = dolibarr_set_const($db, "CLICKTODIAL_URL", GETPOST("CLICKTODIAL_URL"), 'chaine', 0, '', $conf->entity); + $result3 = dolibarr_set_const($db, "CLICKTODIAL_KEY_FOR_CIDLOOKUP", GETPOST("CLICKTODIAL_KEY_FOR_CIDLOOKUP"), 'chaine', 0, '', $conf->entity); - if ($result1 >= 0 && $result2 >= 0) { + if ($result1 >= 0 && $result2 >= 0 && $result3 >= 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -80,7 +81,7 @@ print ''; print '
'; print ''; print ''; -print ''; +print ''; print ''; print "\n"; @@ -89,21 +90,21 @@ print ''; print ''; +print ''; +print ''; +print ''; +print ''; + print '
'.$langs->trans("Name").''.$langs->trans("Name").''.$langs->trans("Value").'
'; print $langs->trans("ClickToDialUseTelLink").''; print $form->selectyesno("CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS", $conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS, 1).'
'; print '
'; -print $langs->trans("ClickToDialUseTelLinkDesc"); +print ''.$langs->trans("ClickToDialUseTelLinkDesc").''; print '
'; print $langs->trans("DefaultLink").''; -print 'global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS ? ' disabled="disabled"' : '').' value="'.$conf->global->CLICKTODIAL_URL.'">
'; +print '
'; print ajax_autoselect('CLICKTODIAL_URL'); print '
'; print $langs->trans("ClickToDialUrlDesc").'
'; print '
'; print ''; print $langs->trans("Examples").':
'; -print 'https://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__
'; -print 'sip:__PHONETO__@my.sip.server'; +print '* https://myphoneserver/phoneurl?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__
'; +print '* sip:__PHONETO__@my.sip.server'; print '
'; //if (! empty($user->clicktodial_url)) @@ -114,6 +115,37 @@ print ''; print '
'.$langs->trans("SecurityKey").''; + +global $dolibarr_main_url_root; + +// 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 + +// Url for CIDLookup +//print '
'; +//print $langs->trans("URLToLaunchCronJobs").':
'; +$url = $urlwithroot.'/public/clicktodial/cidlookup.php?securitykey='.getDolGlobalString('CLICKTODIAL_KEY_FOR_CIDLOOKUP', 'ValueToDefine').'&phone=...'; +//print img_picto('', 'globe').' '.$url."
\n"; +//print '
'; +//print '
'; + + +print ''.$langs->trans("CIDLookupURL").''; +print '
'.$url; +print '
'; +print '
'; +print ''; +if (!empty($conf->use_javascript_ajax)) { + print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +} +print '
'; print '
'; @@ -156,6 +188,11 @@ if (!empty($conf->global->CLICKTODIAL_URL)) { } } +// Add button to autosuggest a key +include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; +print dolJSToSetRandomPassword('CLICKTODIAL_KEY_FOR_CIDLOOKUP'); + + // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 1369c5667a8..a2aa663f189 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -625,13 +625,13 @@ print '
'; //Use draft Watermark -print "
"; +print ''; print ''; -print ""; +print ''; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftOrders"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 1426c323c01..a5a68a0bb49 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -220,7 +220,7 @@ if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; print ''; } -print ''; +print ''; print "\n"; print ''; @@ -273,7 +273,7 @@ if ($result) { print ''; // Date last change - print ''; + print ''; print dol_print_date($db->jdate($obj->tms), 'dayhour'); print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index e8a1fc85790..a2db7bf8fcf 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -458,7 +458,7 @@ print ''."\n"; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''."\n"; print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6453210e596..fa5d6deae97 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2090,6 +2090,8 @@ if ($id > 0) { $valuetoshow = $langs->trans($obj->{$value}); } elseif ($value == 'block_if_negative') { $valuetoshow = yn($obj->{$value}); + } elseif ($value == 'icon') { + $valuetoshow = $obj->{$value}." ".img_picto("", $obj->{$value}); } elseif ($value == 'type_duration') { $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); $valuetoshow =$TDurationTypes[$obj->{$value}]; diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 521a24f490d..de6210ba531 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -206,7 +206,7 @@ class PrestaShopWebservice */ public function printDebug($title, $content) { - echo '
'.$title.'
'.htmlentities($content).'
'; + echo '
'.dol_escape_htmltag($title).'
'.dol_escape_htmltag($content).'
'; } /** diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index ee6c2ae6b52..05df4187130 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -273,21 +273,10 @@ if ($action == 'edit') { if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } + + // Add button to autosuggest a key + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index cb49404a8b9..0a9009889f8 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -451,7 +451,7 @@ print "\n"; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; -print ''; +print ''; print "\n"; print ''; diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 0c54eade6da..64cf24ca6fa 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -468,7 +468,7 @@ print ''."\n"; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftExpenseReports"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; -print ''; +print ''; print ''."\n"; if (!empty($conf->project->enabled)) { diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index accb3d850a0..f866eef7802 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -761,7 +761,7 @@ print ' print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftBill"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 36a55be9a95..79896d0ed74 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -525,7 +525,7 @@ print "'; print $form->textwithpicto($langs->trans("WatermarkOnDraftInterventionCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index f208e2a658a..c3c58984dc0 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -551,7 +551,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; - print ''; + print ''; print ''."\n"; } diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index f5bbb5c648f..cfe40c006b7 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -57,7 +57,7 @@ $type = 'myobject'; $arrayofparameters = array( 'HRM_MAXRANK'=>array('type'=>'integer','enabled'=>1), - 'HRM_DEFAULT_SKILL_DESCRIPTION'=>array('type'=>'textarea','enabled'=>1), + 'HRM_DEFAULT_SKILL_DESCRIPTION'=>array('type'=>'varchar','enabled'=>1), ); $error = 0; @@ -540,21 +540,10 @@ if ($action == 'edit') { if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } + + // Add button to autosuggest a key + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 37735a43ed3..da2df89b21a 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -107,21 +107,11 @@ llxHeader('', $langs->trans("MailingSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); -if (!empty($conf->use_javascript_ajax)) { - print "\n".''; -} +$constname = 'MAILING_EMAIL_UNSUBSCRIBE_KEY'; + +// Add button to autosuggest a key +include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; +print dolJSToSetRandomPassword($constname); print '
'; print ''; diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index f065760f62d..67bf775bdd9 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -870,7 +870,7 @@ if ($action == 'edit') { if (!empty($dnsinfo) && is_array($dnsinfo)) { foreach ($dnsinfo as $info) { if (strpos($info['txt'], 'v=spf') !== false) { - $text .= ($text ? '

' : '').$langs->trans("ActualMailSPFRecordFound", $info['txt']); + $text .= ($text ? '

' : '').$langs->trans("ActualMailSPFRecordFound", $companyemail, $info['txt']); } } } diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index 40af4c4ae2a..79ddda792e0 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -427,11 +427,15 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_EMAILING]; + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')]; if (empty($text)) { $text = $langs->trans("Undefined").img_warning(); } - print $text; + if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') == 'default') { + print ''.$text.''; + } else { + print $text; + } print ''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && $conf->global->MAIN_MAIL_SENDMODE_EMAILING != 'default') { diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index 481fcad212c..a439bdabcf0 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -394,11 +394,15 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_MAIL_SENDMODE").''; - $text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE_TICKET]; + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET')]; if (empty($text)) { $text = $langs->trans("Undefined").img_warning(); } - print $text; + if (getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET') == 'default') { + print ''.$text.''; + } else { + print $text; + } print ''; if (!empty($conf->global->MAIN_MAIL_SENDMODE_TICKET) && $conf->global->MAIN_MAIL_SENDMODE_TICKET != 'default') { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 0c53bebfc52..16500c62d59 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Regis Houssin + * Copyright (C) 2022 Charlene Benke * * 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 @@ -505,7 +506,7 @@ if ($mode == 'feature') { $text .= '
'; $text .= '
'.$langs->trans("AddHooks").': '; - if (isset($objMod->module_parts) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) { + if (isset($objMod->module_parts) && isset($objMod->module_parts['hooks']) && is_array($objMod->module_parts['hooks']) && count($objMod->module_parts['hooks'])) { $i = 0; foreach ($objMod->module_parts['hooks'] as $key => $val) { if ($key === 'entity') { diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index f4283373b95..2d543cb1faa 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -465,7 +465,7 @@ print "'; print $form->textwithpicto($langs->trans("WatermarkOnDraftMOs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php index 38245b5e204..760df948d34 100644 --- a/htdocs/admin/notification.php +++ b/htdocs/admin/notification.php @@ -188,6 +188,7 @@ print ''; print ''; print ''; +print '
'; print ''; print ''; print ''; @@ -198,7 +199,7 @@ print ''; print ''; print ''; @@ -224,7 +225,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER", $arrval, getDolGlobalString('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_USER')); } print ''; print ''; @@ -236,11 +237,12 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX", $arrval, getDolGlobalString('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_FIX')); } print ''; print ''; print '
'.$langs->trans("Parameter").'
'; print $langs->trans("NotificationEMailFrom").''; print img_picto('', 'email', 'class="pictofixedwidth"'); -print ''; +print ''; if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) { print ' '.img_warning($langs->trans("ErrorBadEMail")); } @@ -212,7 +213,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval, $conf->global->NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT); + print $form->selectarray("NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT", $arrval, getDolGlobalString('NOTIFICATION_EMAIL_DISABLE_CONFIRM_MESSAGE_CONTACT')); } print '
'; +print '
'; print $form->buttonsSaveCancel("Save", ''); @@ -387,6 +389,7 @@ if (!empty($conf->societe->enabled)) { } print '
'; +print '
'; print ''; print ''; print ''; @@ -449,7 +452,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { $param = 'NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_'.$reg[1]; $value = GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key') ?GETPOST('NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key', 'alpha') : $conf->global->$param; - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. $arrayemail = explode(',', $value); $showwarning = 0; foreach ($arrayemail as $keydet => $valuedet) { @@ -468,7 +471,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { } // New entry input fields if (empty($inputfieldalreadyshown) || !$codehasnotrigger) { - $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. + $s = ''; // Do not use type="email" here, we must be able to enter a list of email with , separator. print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'
'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2); } print ''; @@ -501,6 +504,7 @@ foreach ($listofnotifiedevents as $notifiedevent) { print ''; } print '
'.$langs->trans("Module").'
'; +print '
'; print $form->buttonsSaveCancel("Save", ''); diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index fe8db9818f7..c324f33ba92 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -693,7 +693,7 @@ print "'; print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index 1ca874c69b5..5479b43f6ca 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -467,7 +467,7 @@ print "\n"; print ''; print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $htmltext).'
'; -print ''; +print ''; print "\n"; */ print ''; diff --git a/htdocs/admin/security_file.php b/htdocs/admin/security_file.php index 67c6914f1cf..62b91ad55b3 100644 --- a/htdocs/admin/security_file.php +++ b/htdocs/admin/security_file.php @@ -128,7 +128,7 @@ if (isset($max)) { } print ''; print ''; -print ' '.$langs->trans("Kb"); +print ' '.$langs->trans("Kb"); print ''; print ''; @@ -138,7 +138,7 @@ print ''.$langs->trans("UMask").''; print $form->textwithpicto('', $langs->trans("UMaskExplanation")); print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/admin/security_other.php b/htdocs/admin/security_other.php index a3d54e2a132..79190725c16 100644 --- a/htdocs/admin/security_other.php +++ b/htdocs/admin/security_other.php @@ -61,8 +61,13 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { dol_print_error($db); } } elseif ($action == 'updateform') { - $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + $res1 = 1; $res2 = 1; + if (GETPOSTISSET('MAIN_APPLICATION_TITLE')) { + $res1 = dolibarr_set_const($db, "MAIN_APPLICATION_TITLE", GETPOST("MAIN_APPLICATION_TITLE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('MAIN_SESSION_TIMEOUT')) { + $res2 = dolibarr_set_const($db, "MAIN_SESSION_TIMEOUT", GETPOST("MAIN_SESSION_TIMEOUT", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + } if ($res1 && $res2) { setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); } @@ -165,11 +170,11 @@ if (ini_get("session.gc_probability") == 0) { } print ''; print ''; -print ' '.strtolower($langs->trans("Seconds")); +print ' '.strtolower($langs->trans("Seconds")); print ''; print ''; - +/* if (empty($conf->global->MAIN_APPLICATION_TITLE)) { $conf->global->MAIN_APPLICATION_TITLE = ""; } @@ -177,9 +182,10 @@ print ''; print ''.$langs->trans("MAIN_APPLICATION_TITLE").''; print ''; print ''; -print ' '; +print ' '; print ''; print ''; +*/ print ''; diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index bb0617c6700..76a881f9415 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -492,7 +492,7 @@ print "'; print $form->textwithpicto($langs->trans("WatermarkOnDraftProposal"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; print ''; -print ''; +print ''; print ''; print ''; print "\n"; diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 2f272cd986f..8e80a13673e 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -295,7 +295,7 @@ print ''; if (!empty($conf->loghandlers['mod_syslog_file']) && !empty($conf->cron->enabled)) { print ''.$langs->trans("SyslogFileNumberOfSaves").''; - print ''; + print ''; print ' ('.$langs->trans('ConfigureCleaningCronjobToSetFrequencyOfSaves').')'; } diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 96cb98809ef..9a27feb3d7a 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -89,6 +89,7 @@ $configfileparameters = array( 'separator', '?dolibarr_mailing_limit_sendbyweb', '?dolibarr_mailing_limit_sendbycli', + '?dolibarr_mailing_limit_sendbyday', '?dolibarr_strict_mode' ); $configfilelib = array( diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index 72e8db6bb4e..457d71d98d9 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -106,6 +106,14 @@ if (!$base) { print 'Collation'; print "\n"; + $arrayoffilesrich = dol_dir_list(DOL_DOCUMENT_ROOT.'/install/mysql/tables/', 'files', 0, '\.sql$'); + $arrayoffiles = array(); + foreach ($arrayoffilesrich as $value) { + //print $shortsqlfilename.' '; + $shortsqlfilename = preg_replace('/\-[a-z]+\./', '.', $value['name']); + $arrayoffiles[] = $shortsqlfilename; + } + $sql = "SHOW TABLE STATUS"; $resql = $db->query($sql); @@ -119,7 +127,8 @@ if (!$base) { print ''.($i+1).''; print ''.$obj->Name.''; $tablename = preg_replace('/^'.MAIN_DB_PREFIX.'/', 'llx_', $obj->Name); - if (dol_is_file(DOL_DOCUMENT_ROOT.'/install/mysql/tables/'.$tablename.'.sql')) { + + if (in_array($tablename.'.sql', $arrayoffiles)) { $img = "info"; //print img_picto($langs->trans("ExternalModule"), $img); } else { diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index e58cf45dd7e..8a982f6e0bd 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -360,6 +360,7 @@ $configfileparameters = array( 'dolibarr_main_restrict_ip' => 'Restrict access to some IPs only', '?dolibarr_mailing_limit_sendbyweb' => 'Limit nb of email sent by page', '?dolibarr_mailing_limit_sendbycli' => 'Limit nb of email sent by cli', + '?dolibarr_mailing_limit_sendbyday' => 'Limit nb of email sent per day', '?dolibarr_strict_mode' => 'Strict mode is on/off', '?dolibarr_nocsrfcheck' => 'Disable CSRF security checks' ); diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 0fd654b5d28..fdb3117423b 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -183,7 +183,8 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { } // enable captcha by default - $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA', 1, 'chaine', 0, '', $conf->entity); + // TODO Add a visible option in this setup page for this + $res = dolibarr_set_const($db, 'MAIN_SECURITY_ENABLECAPTCHA_TICKET', 1, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; $errors[] = $db->lasterror(); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 709b60068f7..b23a35442ef 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -58,7 +58,7 @@ if ($action == 'set_default') { } elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") { + if (getDolGlobalString('USERGROUP_ADDON_PDF_ODT') == "$value") { dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); } } @@ -202,7 +202,7 @@ foreach ($dirmodels as $reldir) { // Defaut print ''; - if ($conf->global->USERGROUP_ADDON_PDF == $name) { + if (getDolGlobalString('USERGROUP_ADDON_PDF') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index 963b76c238a..9dec7a8eeec 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -338,21 +338,10 @@ if ($action == 'edit') { if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } + + // Add button to autosuggest a key + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); diff --git a/htdocs/api/index.php b/htdocs/api/index.php index afb0289aa32..8543e284533 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -257,6 +257,8 @@ if (!empty($reg[1]) && $reg[1] == 'explorer' && ($reg[2] == '/swagger.json' || $ continue; } + //dol_syslog("We scan to search api file with into ".$dir_part.$file_searched); + $regapi = array(); if (is_readable($dir_part.$file_searched) && preg_match("/^api_(.*)\.class\.php$/i", $file_searched, $regapi)) { $classname = ucwords($regapi[1]); diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 29ee4b074fb..448473003b3 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -519,21 +519,10 @@ if ($action == 'edit') { if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } + + // Add button to autosuggest a key + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 95fb287d2b8..ff0ecbf0d01 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2014-2022 Laurent Destailleur * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ * \ingroup member * \brief Page to make mass init of barcode */ + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -322,26 +323,29 @@ if (isModEnabled('societe')) { dol_print_error($db); } - print $langs->trans("CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv("ThirdParties")).'
'."\n"; + print $langs->trans("CurrentlyNWithoutBarCode", $nbthirdpartyno, $nbthirdpartytotal, $langs->transnoentitiesnoconv("ThirdParties"))."\n"; $disabledthirdparty = $disabledthirdparty1 = 0; if (is_object($modBarCodeThirdparty)) { - print $langs->trans("BarCodeNumberManager").": "; + print '
'.$langs->trans("BarCodeNumberManager").": "; $objthirdparty = new Societe($db); print ''.(isset($modBarCodeThirdparty->name) ? $modBarCodeThirdparty->name : $modBarCodeThirdparty->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeThirdparty->getNextValue($objthirdparty).'
'; $disabledthirdparty = 0; + print '
'; } else { $disabledthirdparty = 1; $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); - print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; + print '
'.$langs->trans("NoBarcodeNumberingTemplateDefined"); + print '
'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").''; + print '
'; } if (empty($nbthirdpartyno)) { $disabledthirdparty1 = 1; } $moretagsthirdparty1 = (($disabledthirdparty || $disabledthirdparty1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); - print '
'; + print '
'; $moretagsthirdparty2 = (($nbthirdpartyno == $nbthirdpartytotal) ? ' disabled' : ''); print '   '; print ''; @@ -391,28 +395,30 @@ if ($conf->product->enabled || $conf->product->service) { dol_print_error($db); } - print $langs->trans("CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv("ProductsOrServices")).'
'."\n"; + print $langs->trans("CurrentlyNWithoutBarCode", $nbproductno, $nbproducttotal, $langs->transnoentitiesnoconv("ProductsOrServices"))."\n"; $disabledproduct = $disabledproduct1 = 0; if (is_object($modBarCodeProduct)) { - print $langs->trans("BarCodeNumberManager").": "; + print '
'.$langs->trans("BarCodeNumberManager").": "; $objproduct = new Product($db); print ''.(isset($modBarCodeProduct->name) ? $modBarCodeProduct->name : $modBarCodeProduct->nom).' - '.$langs->trans("NextValue").': '.$modBarCodeProduct->getNextValue($objproduct).'
'; $disabledproduct = 0; + print '
'; } else { $disabledproduct = 1; $titleno = $langs->trans("NoBarcodeNumberingTemplateDefined"); - print ''.$langs->trans("NoBarcodeNumberingTemplateDefined").' ('.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").')
'; + print '
'.$langs->trans("NoBarcodeNumberingTemplateDefined"); + print '
'.$langs->trans("ToGenerateCodeDefineAutomaticRuleFirst").''; + print '
'; } if (empty($nbproductno)) { $disabledproduct1 = 1; } - print '
'; //print ' '.$langs->trans("ResetBarcodeForAllRecords").'
'; $moretagsproduct1 = (($disabledproduct || $disabledproduct1) ? ' disabled title="'.dol_escape_htmltag($titleno).'"' : ''); - print ''; + print ''; $moretagsproduct2 = (($nbproductno == $nbproducttotal) ? ' disabled' : ''); print '   '; print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index f74a1d69263..ac73ab58475 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -98,7 +98,7 @@ class BOM extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1',), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'noteditable'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of BOM", 'showoncombobox'=>'1', 'csslist'=>'nowraponall'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'minwidth300 maxwidth400', 'csslist'=>'tdoverflowmax200'), 'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth175', 'csslist'=>'minwidth175 center'), //'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')), diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index dad25199566..bcfa5c541fd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -827,7 +827,7 @@ class Categorie extends CommonObject /** * Return list of fetched instance of elements having this category * - * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', 'knowledge_management' ...) + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', 'knowledge_management', ...) * @param int $onlyids Return only ids of objects (consume less memory) * @param int $limit Limit * @param int $offset Offset @@ -1215,9 +1215,10 @@ class Categorie extends CommonObject while ((empty($protection) || $i < $protection) && !empty($this->motherof[$cursor_categ])) { //print '  cursor_categ='.$cursor_categ.' i='.$i.' '.$this->motherof[$cursor_categ].'
'."\n"; $this->cats[$id_categ]['fullpath'] = '_'.$this->motherof[$cursor_categ].$this->cats[$id_categ]['fullpath']; - $this->cats[$id_categ]['fulllabel'] = $this->cats[$this->motherof[$cursor_categ]]['label'].' >> '.$this->cats[$id_categ]['fulllabel']; + $this->cats[$id_categ]['fulllabel'] = (empty($this->cats[$this->motherof[$cursor_categ]]) ? 'NotFound' : $this->cats[$this->motherof[$cursor_categ]]['label']).' >> '.$this->cats[$id_categ]['fulllabel']; //print '  Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].' '.$this->cats[$id_categ]['fulllabel'].'
'."\n"; - $i++; $cursor_categ = $this->motherof[$cursor_categ]; + $i++; + $cursor_categ = $this->motherof[$cursor_categ]; } //print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'
'."\n"; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 7d12f571c06..7e8a1252095 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -381,7 +381,7 @@ if ($cats < 0) { $fulltree = $categstatic->get_full_arbo($type, $object->id, 1); // Load possible missing includes - if ($conf->global->CATEGORY_SHOW_COUNTS) { + if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { if ($type == Categorie::TYPE_MEMBER) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; } @@ -407,11 +407,9 @@ if ($cats < 0) { $desc = dol_htmlcleanlastbr($val['description']); $counter = ''; - if ($conf->global->CATEGORY_SHOW_COUNTS) { + if (getDolGlobalString('CATEGORY_SHOW_COUNTS')) { // we need only a count of the elements, so it is enough to consume only the id's from the database - $elements = $type == Categorie::TYPE_ACCOUNT - ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account" - : $categstatic->getObjectsInCateg($type, 1); + $elements = $categstatic->getObjectsInCateg($type, 1); $counter = "".(is_array($elements) ? count($elements) : '0').""; } @@ -1047,7 +1045,7 @@ if ($type == Categorie::TYPE_USER) { print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e543b7e6bd1..ed25d89db67 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -409,9 +409,13 @@ if (empty($reshook) && $action == 'add') { $error++; } + + if (!$error) { $db->begin(); + + // Creation of action/event $idaction = $object->create($user); @@ -474,15 +478,15 @@ if (empty($reshook) && $action == 'add') { $db->commit(); } - if (!empty($backtopage)) { - dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); - } elseif ($idaction) { - header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); - } else { - header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); - } - exit; + // if (!empty($backtopage)) { + // dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + // header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + // } elseif ($idaction) { + // header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); + // } else { + // header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); + // } + // exit; } else { // If error $db->rollback(); @@ -496,6 +500,151 @@ if (empty($reshook) && $action == 'add') { setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } + + $selectedrecurrulefreq = 'no'; + $selectedrecurrulebymonthday = ''; + $selectedrecurrulebyday = ''; + $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; + + if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg1)) { + $selectedrecurrulefreq = $reg1[1]; + } + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg2)) { + $selectedrecurrulebymonthday = $reg2[1]; + } + if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg3)) { + $selectedrecurrulebyday = $reg3[1]; + } + + // If event is recurrent + $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + if ($userepeatevent && !empty($selectedrecurrulefreq) && $selectedrecurrulefreq != 'no') { + // We set first date of recurrence and offsets + if ($selectedrecurrulefreq == 'WEEKLY' && !empty($selectedrecurrulebyday)) { + $firstdatearray = dol_get_first_day_week(GETPOST("apday", 'int'), GETPOST("apmonth", 'int'), GETPOST("apyear", 'int')); + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstdatearray['month'], $firstdatearray['first_day'], $firstdatearray['year'], $tzforfullday ? $tzforfullday : 'tzuser'); + $datep = dol_time_plus_duree($datep, $selectedrecurrulebyday + 6, 'd');//We begin the week after + $dayoffset = 7; + $monthoffset = 0; + } elseif ($selectedrecurrulefreq == 'MONTHLY' && !empty($selectedrecurrulebymonthday)) { + $firstday = $selectedrecurrulebymonthday; + $firstmonth = GETPOST("apday") > $selectedrecurrulebymonthday ? GETPOST("apmonth", 'int') + 1 : GETPOST("apmonth", 'int');//We begin the week after + $datep = dol_mktime($fulldayevent ? '00' : GETPOST("aphour", 'int'), $fulldayevent ? '00' : GETPOST("apmin", 'int'), $fulldayevent ? '00' : GETPOST("apsec", 'int'), $firstmonth, $firstday, GETPOST("apyear", 'int'), $tzforfullday ? $tzforfullday : 'tzuser'); + $dayoffset = 0; + $monthoffset = 1; + } else { + $error++; + } + // End date + $repeateventlimitdate = dol_mktime('23', '59', '59', GETPOSTISSET("limitmonth", 'int') ? GETPOST("limitmonth", 'int') : 01, GETPOSTISSET("limitday", 'int') ? GETPOST("limitday", 'int') : 01, GETPOSTISSET("limityear", 'int') && GETPOST("limityear", 'int') < 2100 ? GETPOST("limityear", 'int') : 2100, $tzforfullday ? $tzforfullday : 'tzuser'); + // Set date of end of event + $deltatime = num_between_day($object->datep, $datep); + $datef = dol_time_plus_duree($datef, $deltatime, 'd'); + + while ($datep <= $repeateventlimitdate && !$error) { + $finalobject = clone $object; + + + $finalobject->datep = $datep; + $finalobject->datef = $datef; + // Creation of action/event + $idaction = $finalobject->create($user); + + if ($idaction > 0) { + if (!$finalobject->error) { + // Category association + $categories = GETPOST('categories', 'array'); + $finalobject->setCategories($categories); + + unset($_SESSION['assignedtouser']); + + $moreparam = ''; + if ($user->id != $finalobject->userownerid) { + $moreparam = "filtert=-1"; // We force to remove filter so created record is visible when going back to per user view. + } + + // Create reminders + if ($addreminder == 'on') { + $actionCommReminder = new ActionCommReminder($db); + + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, $offsetunit); + + $actionCommReminder->dateremind = $dateremind; + $actionCommReminder->typeremind = $remindertype; + $actionCommReminder->offsetunit = $offsetunit; + $actionCommReminder->offsetvalue = $offsetvalue; + $actionCommReminder->status = $actionCommReminder::STATUS_TODO; + $actionCommReminder->fk_actioncomm = $finalobject->id; + if ($remindertype == 'email') { + $actionCommReminder->fk_email_template = $modelmail; + } + + // the notification must be created for every user assigned to the event + foreach ($finalobject->userassigned as $userassigned) { + $actionCommReminder->fk_user = $userassigned['id']; + $res = $actionCommReminder->create($user); + + if ($res <= 0) { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans('ErrorReminderActionCommCreation'); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + break; + } + } + } + + // Modify $moreparam so we are sure to see the event we have just created, whatever are the default value of filter on next page. + /*$moreparam .= ($moreparam ? '&' : '').'search_actioncode=0'; + $moreparam .= ($moreparam ? '&' : '').'search_status=-1'; + $moreparam .= ($moreparam ? '&' : '').'search_filtert='.$object->userownerid; + */ + $moreparam .= ($moreparam ? '&' : '').'disabledefaultvalues=1'; + + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } else { + // If error + $db->rollback(); + $langs->load("errors"); + $error = $langs->trans($finalobject->error); + setEventMessages($error, null, 'errors'); + $action = 'create'; $donotclearsession = 1; + } + } else { + $db->rollback(); + setEventMessages($finalobject->error, $finalobject->errors, 'errors'); + $action = 'create'; $donotclearsession = 1; + } + + // If event is not recurrent, we stop here + if (!($userepeatevent && GETPOSTISSET('recurrulefreq') && GETPOST('recurrulefreq') != 'no' && GETPOSTISSET("limityear") && GETPOSTISSET("limitmonth") && GETPOSTISSET("limitday"))) { + break; + } + + // increment date for recurrent events + $datep = dol_time_plus_duree($datep, $dayoffset, 'd'); + $datep = dol_time_plus_duree($datep, $monthoffset, 'm'); + $datef = dol_time_plus_duree($datef, $dayoffset, 'd'); + $datef = dol_time_plus_duree($datef, $monthoffset, 'm'); + } + } + if (!empty($backtopage) && !$error) { + dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + header("Location: ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); + } elseif ($idaction) { + header("Location: ".DOL_URL_ROOT.'/comm/action/card.php?id='.$idaction.($moreparam ? '&'.$moreparam : '')); + } else { + header("Location: ".DOL_URL_ROOT.'/comm/action/index.php'.($moreparam ? '?'.$moreparam : '')); + } + exit; } } @@ -916,10 +1065,11 @@ $formproject = new FormProjets($db); $arrayrecurrulefreq = array( 'no'=>$langs->trans("OnceOnly"), 'MONTHLY'=>$langs->trans("EveryMonth"), - 'WEEKLY'=>$langs->trans("EveryWeek"), - //'DAYLY'=>$langs->trans("EveryDay") + 'WEEKLY'=>$langs->trans("EveryWeek") + // 'DAILY'=>$langs->trans("EveryDay") ); + $help_url = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:M&omodulodulo_Agenda'; llxHeader('', $langs->trans("Agenda"), $help_url); @@ -1037,20 +1187,31 @@ if ($action == 'create') { print '        
'; print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); print ''; + $selectedrecurrulefreq = 'no'; $selectedrecurrulebymonthday = ''; $selectedrecurrulebyday = ''; + $object->recurrule = GETPOSTISSET('recurrulefreq') ? "FREQ=".GETPOST('recurrulefreq', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYMONTHDAY') ? "_BYMONTHDAY".GETPOST('BYMONTHDAY', 'alpha') : ""; + $object->recurrule .= GETPOSTISSET('BYDAY') ? "_BYDAY".GETPOST('BYDAY', 'alpha') : ""; + + $reg = array(); if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { $selectedrecurrulefreq = $reg[1]; } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { + if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY(\d+)/i', $object->recurrule, $reg)) { $selectedrecurrulebymonthday = $reg[1]; } if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { $selectedrecurrulebyday = $reg[1]; } + print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // print ''; + // For recursive event + + // If recurrulefreq is MONTHLY print ''; //print ''; } @@ -1545,64 +1721,64 @@ if ($id > 0) { print '
'; - } + // // Recurring event + // $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); + // if ($userepeatevent) { + // // Repeat + // //print ''; + // } print ''; // Date start - end @@ -1903,13 +2079,22 @@ if ($id > 0) { } else { print dol_get_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); + $formconfirm = ''; + // Clone event if ($action == 'clone') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.GETPOST('id'), $langs->trans('ToClone'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', $formquestion, 'yes', 1); - - print $formconfirm; + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.GETPOST('id'), $langs->trans('ToClone'), $langs->trans('ConfirmCloneEvent', $object->label), 'confirm_clone', array(), 'yes', 1); } + // Call Hook formConfirm + $parameters = array(); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) $formconfirm.=$hookmanager->resPrint; + elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint; + + // Print form confirm + print $formconfirm; + $linkback = ''; // Link to other agenda views $linkback .= ''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 22419629333..9a7114a6113 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -285,17 +285,17 @@ class ActionComm extends CommonObject // Properties for links to other objects /** - * @var int Id of linked object + * @var int Id of linked object */ public $fk_element; // Id of record /** - * @var int Id of record alternative for API + * @var int Id of record alternative for API */ public $elementid; /** - * @var string Type of record. This if property ->element of object linked to. + * @var string Type of record. This if property ->element of object linked to. */ public $elementtype; @@ -1558,13 +1558,13 @@ class ActionComm extends CommonObject } $canread = 0; - if ($user->rights->agenda->myactions->read && $this->authorid == $user->id) { + if (!empty($user->rights->agenda->myactions->read) && $this->authorid == $user->id) { $canread = 1; // Can read my event } - if ($user->rights->agenda->myactions->read && array_key_exists($user->id, $this->userassigned)) { + if (!empty($user->rights->agenda->myactions->read) && array_key_exists($user->id, $this->userassigned)) { $canread = 1; // Can read my event i am assigned } - if ($user->rights->agenda->allactions->read) { + if (!empty($user->rights->agenda->allactions->read)) { $canread = 1; // Can read all event of other } if (!$canread) { @@ -2093,8 +2093,8 @@ class ActionComm extends CommonObject } if (!empty($conf->global->AGENDA_EXPORT_FIX_TZ)) { - $timestampStart = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); - $timestampEnd = - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + $timestampStart = $timestampStart - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); + $timestampEnd = $timestampEnd - ($conf->global->AGENDA_EXPORT_FIX_TZ * 3600); } $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 9fcb8375193..2afad30c454 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -111,7 +111,7 @@ $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOST("search_projectid", "int", 3) ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'aZ09') : GETPOST("type", 'aZ09'); $maxprint = GETPOSTISSET("maxprint") ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW; $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -759,12 +759,14 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1') { +if ($status == '-1' || $status == 'na') { + // Not applicable $sql .= " AND a.percent = -1"; -} // Not applicable +} if ($status == '50') { + // Running already started $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} // Running already started +} if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 18f62872630..87def7240f5 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -101,7 +101,7 @@ $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo', 'na' or -1 $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -627,12 +627,14 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1') { +if ($status == '-1' || $status == 'na') { + // Not applicable $sql .= " AND a.percent = -1"; -} // Not applicable +} if ($status == '50') { + // Running already started $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} // Running already started +} if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4b51a519223..173ee8a6510 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -914,8 +914,10 @@ if ($object->id > 0) { * Latest orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { + $param =""; + $sql = "SELECT s.nom, s.rowid"; - $sql .= ", c.rowid as cid, c.total_ht"; + $sql .= ", c.rowid as cid, c.entity, c.total_ht"; $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; $sql .= ", c.ref, c.ref_client, c.fk_statut, c.facture"; @@ -1024,7 +1026,7 @@ if ($object->id > 0) { */ if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { $sql = 'SELECT e.rowid as id'; - $sql .= ', e.ref'; + $sql .= ', e.ref, e.entity'; $sql .= ', e.date_creation'; $sql .= ', e.fk_statut as statut'; $sql .= ', s.nom'; @@ -1033,7 +1035,7 @@ if ($object->id > 0) { $sql .= " WHERE e.fk_soc = s.rowid AND s.rowid = ".((int) $object->id); $sql .= " AND e.entity IN (".getEntity('expedition').")"; $sql .= ' GROUP BY e.rowid'; - $sql .= ', e.ref'; + $sql .= ', e.ref, e.entity'; $sql .= ', e.date_creation'; $sql .= ', e.fk_statut'; $sql .= ', s.nom'; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index d46a02132a1..748c5fabf10 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -801,13 +801,20 @@ if ($action == 'create') { // MAILING_NO_USING_PHPMAIL may be defined or not. // MAILING_LIMIT_SENDBYWEB is always defined to something != 0 (-1=forbidden). // MAILING_LIMIT_SENDBYCLI may be defined ot not (-1=forbidden, 0 or undefined=no limit). + // MAILING_LIMIT_SENDBYDAY may be defined ot not (0 or undefined=no limit). if (!empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail') { // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent. // You ensure that every user is using its own SMTP server when using the mass emailing module. $linktoadminemailbefore = ''; $linktoadminemailend = ''; setEventMessages($langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]), null, 'warnings'); - setEventMessages($langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']), null, 'warnings'); + $messagetoshow = $langs->trans("MailSendSetupIs2", '{s1}', '{s2}', '{s3}', '{s4}'); + $messagetoshow = str_replace('{s1}', $linktoadminemailbefore, $messagetoshow); + $messagetoshow = str_replace('{s2}', $linktoadminemailend, $messagetoshow); + $messagetoshow = str_replace('{s3}', $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $messagetoshow); + $messagetoshow = str_replace('{s4}', $listofmethods['smtps'], $messagetoshow); + setEventMessages($messagetoshow, null, 'warnings'); + if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS)) { setEventMessages($langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS), null, 'warnings'); } @@ -836,14 +843,21 @@ if ($action == 'create') { } $text = ''; - if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { - $text .= $langs->trans("MailingNeedCommand"); - $text .= '
'; + + if (isset($conf->global->MAILING_LIMIT_SENDBYDAY) && $conf->global->MAILING_LIMIT_SENDBYDAY >= 0) { + $text .= $langs->trans('WarningLimitSendByDay', $conf->global->MAILING_LIMIT_SENDBYDAY); $text .= '

'; } $text .= $langs->trans('ConfirmSendingEmailing').'
'; $text .= $langs->trans('LimitSendingEmailing', $conf->global->MAILING_LIMIT_SENDBYWEB); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', '', '', 1, 330, 600); + + if (!isset($conf->global->MAILING_LIMIT_SENDBYCLI) || $conf->global->MAILING_LIMIT_SENDBYCLI >= 0) { + $text .= '

'; + $text .= $langs->trans("MailingNeedCommand"); + $text .= '
'; + } + + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('SendMailing'), $text, 'sendallconfirmed', '', '', 1, 330, 600, 0, $langs->trans("Confirm"), $langs->trans("Cancel")); } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 62dd24aaaf7..ea6ec241b16 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -41,7 +41,7 @@ class AdvanceTargetingMailing extends CommonObject /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'advtargetemailing'; + public $table_element = 'mailing_advtarget'; /** * @var int ID @@ -159,7 +159,7 @@ class AdvanceTargetingMailing extends CommonObject // Put here code to add control on parameters values // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."advtargetemailing("; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_advtarget("; $sql .= "name,"; $sql .= "entity,"; $sql .= "fk_element,"; @@ -188,7 +188,7 @@ class AdvanceTargetingMailing extends CommonObject } if (!$error) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."advtargetemailing"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing_advtarget"); } // Commit or rollback @@ -227,7 +227,7 @@ class AdvanceTargetingMailing extends CommonObject $sql .= " t.fk_user_mod,"; $sql .= " t.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as t"; $sql .= " WHERE t.rowid = ".((int) $id); dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -282,7 +282,7 @@ class AdvanceTargetingMailing extends CommonObject $sql .= " t.fk_user_mod,"; $sql .= " t.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as t"; if (!empty($id)) { $sql .= " WHERE t.fk_element = ".((int) $id)." AND type_element = 'mailing'"; } else { @@ -345,7 +345,7 @@ class AdvanceTargetingMailing extends CommonObject $sql .= " t.fk_user_mod,"; $sql .= " t.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_advtarget as t"; if (!empty($id)) { $sql .= " WHERE t.fk_element = ".((int) $id)." AND type_element = '".$this->db->escape($type_element)."'"; } else { @@ -410,7 +410,7 @@ class AdvanceTargetingMailing extends CommonObject // Put here code to add a control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."advtargetemailing SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_advtarget SET"; $sql .= " name=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "''").","; $sql .= " entity=".$conf->entity.","; @@ -458,7 +458,7 @@ class AdvanceTargetingMailing extends CommonObject $this->db->begin(); if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."advtargetemailing"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_advtarget"; $sql .= " WHERE rowid=".((int) $this->id); dol_syslog(get_class($this)."::delete sql=".$sql); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index ecde836c428..757b6373f3f 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -277,7 +277,7 @@ if ($resql) { print ''; // Title - print ''; + print ''; // Date creation print ''; - print ''; + print ''; // Accountancy code print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; $columntitle = "WithdrawalsReceipts"; + $columntitlethirdparty = "CustomerCode"; + $columncodethirdparty = "s.code_client"; if ($type == 'bank-transfer') { $columntitle = "BankTransferReceipts"; + $columntitlethirdparty = "SupplierCode"; + $columncodethirdparty = "s.code_fournisseur"; } print ''; @@ -223,7 +231,7 @@ if ($result) { print_liste_field_titre("Line", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "f.ref", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder); - print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", '', $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($columntitlethirdparty, $_SERVER["PHP_SELF"], $columncodethirdparty, '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "p.datec", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "pl.amount", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre(''); @@ -256,9 +264,17 @@ if ($result) { print ''; print '\n"; + $link_to_bill = '/compta/facture/card.php?facid='; + $link_title = 'Invoice'; + $link_picto = 'bill'; + if ($type == 'bank-transfer') { + $link_to_bill = '/fourn/facture/card.php?facid='; + $link_title = 'SupplierInvoice'; + $link_picto = 'supplier_invoice'; + } + print ''; + print img_object($langs->trans($link_title), $link_picto); + print ' '.$obj->invoiceref."\n"; print ''; print ''; @@ -266,7 +282,15 @@ if ($result) { print $company->getNomUrl(1); print "\n"; - print '\n"; + + print '\n"; print '\n"; diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index c80acb39f8e..ee370b9532e 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -132,6 +132,9 @@ if ($result) { if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } + if ($type == 'bank-transfer') { + $param .= '&type=bank-transfer'; + } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 5cdc0d0c6e4..0ef31fe36a4 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -567,19 +567,22 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); +$objsoc = new Societe($db); +if ($socid > 0) { + $objsoc->fetch($socid); +} + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contactnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->lastname) { $title = $object->lastname; } $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); + +llxHeader('', $title, $help_url); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; -$objsoc = new Societe($db); -if ($socid > 0) { - $objsoc->fetch($socid); -} - if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- // When used with CANVAS @@ -621,8 +624,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Show tabs $head = contact_prepare_head($object); - - llxHeader('', $title, $help_url); } if ($user->rights->societe->contact->creer) { @@ -643,9 +644,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } $linkback = ''; - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); - - llxHeader('', $title, $help_url); print load_fiche_titre($title, $linkback, 'address'); @@ -1199,6 +1197,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { + $arrayselected = array(); print ''; print ''; @@ -1565,10 +1566,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans('Modify').''; } - if (!$object->user_id && $user->rights->user->user->creer) { - print ''.$langs->trans("CreateDolibarrLogin").''; - } - // Activer if ($object->statut == 0 && $user->rights->societe->contact->creer) { print ''.$langs->trans("Reactivate").''; diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 9fa3602ee4b..799b53cdad0 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -571,7 +571,6 @@ class Contact extends CommonObject $this->fax = trim($this->fax); $this->zip = (empty($this->zip) ? '' : trim($this->zip)); $this->town = (empty($this->town) ? '' : trim($this->town)); - $this->setUpperOrLowerCase(); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); if (empty($this->statut)) { $this->statut = 0; @@ -579,6 +578,7 @@ class Contact extends CommonObject if (empty($this->civility_code) && !is_numeric($this->civility_id)) { $this->civility_code = $this->civility_id; // For backward compatibility } + $this->setUpperOrLowerCase(); $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 41a6a74dd4b..0ba88228666 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -167,7 +167,7 @@ if ($object->thirdparty->client) { } } -if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) { +if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions'); } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 801c859924e..8d60b37611f 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -342,6 +342,9 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); +$morejs=array(); +$morecss = array(); + if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $contactstatic->loadCacheOfProspStatus(); } @@ -370,6 +373,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; +$sql .= " p.import_key,"; $sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; $sql .= " co.label as country, co.code as country_code"; // Add fields from extrafields @@ -1071,6 +1075,7 @@ while ($i < min($num, $limit)) { $contactstatic->country = $obj->country; $contactstatic->country_code = $obj->country_code; $contactstatic->photo = $obj->photo; + $contactstatic->import_key = $obj->import_key; $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel; @@ -1306,9 +1311,10 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } + // Import key if (!empty($arrayfields['p.import_key']['checked'])) { print '\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 317aebecfd1..eb3a29bb3e9 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1263,9 +1263,9 @@ if ($action == 'create') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("CloseAContract"), $langs->trans("ConfirmCloseContract"), "confirm_close", '', 0, 1); } elseif ($action == 'activate') { $formquestion = array( - array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), /*'value' => $form->selectDate('', '', $usehm, $usehm, '', "active", 1, 0),*/ /*'socid', '(s.client=1 OR s.client=2 OR s.client=3)'*/), + array('type' => 'date', 'name' => 'd_start', 'label' => $langs->trans("DateServiceActivate"), 'value' => dol_now()), array('type' => 'date', 'name' => 'd_end', 'label' => $langs->trans("DateEndPlanned"), /*'value' => $form->selectDate('', "end", $usehm, $usehm, '', "active", 1, 0),*/ '', ''), - array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300') + array('type' => 'text', 'name' => 'comment', 'label' => $langs->trans("Comment"), 'value' => '', '', '', 'class' => 'minwidth300', 'moreattr'=>'autofocus') ); $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=".$object->id, $langs->trans("ActivateAllOnContract"), $langs->trans("ConfirmActivateAllOnContract"), "confirm_activate", $formquestion, 'yes', 1, 280); } elseif ($action == 'clone') { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 322f3f4652e..1e8da8a9a81 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -668,7 +668,7 @@ class Contrat extends CommonObject if (!$id) { $sql .= " WHERE entity IN (".getEntity('contract').")"; } else { - $sql .= " WHERE rowid=".(int) $id; + $sql .= " WHERE rowid = ".(int) $id; } if ($ref_customer) { $sql .= " AND ref_customer = '".$this->db->escape($ref_customer)."'"; @@ -677,7 +677,7 @@ class Contrat extends CommonObject $sql .= " AND ref_supplier = '".$this->db->escape($ref_supplier)."'"; } if ($ref) { - $sql .= " AND ref='".$this->db->escape($ref)."'"; + $sql .= " AND ref = '".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -724,10 +724,13 @@ class Contrat extends CommonObject // Retrieve all extrafields // fetch optionals attributes and labels - $this->fetch_optionals(); + $result = $this->fetch_optionals(); // Lines - $result = $this->fetch_lines(); + if ($result >= 0 && !empty($this->table_element_line)) { + $result = $this->fetch_lines(); + } + if ($result < 0) { $this->error = $this->db->lasterror(); return -3; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 506a1465fdc..39dba81976f 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -61,7 +61,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { continue; // The field was not submited to be saved } } else { - if (!GETPOSTISSET($key)) { + if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) { continue; // The field was not submited to be saved } } @@ -91,6 +91,12 @@ if ($action == 'add' && !empty($permissiontoadd)) { } elseif ($object->fields[$key]['type'] == 'reference') { $tmparraykey = array_keys($object->param_list); $value = $tmparraykey[GETPOST($key)].','.GETPOST($key.'2'); + } elseif (preg_match('/^chkbxlst:(.*)/', $object->fields[$key]['type'])) { + $value = ''; + $values_arr = GETPOST($key, 'array'); + if (!empty($values_arr)) { + $value = implode(',', $values_arr); + } } else { if ($key == 'lang') { $value = GETPOST($key, 'aZ09') ?GETPOST($key, 'aZ09') : ""; @@ -134,6 +140,8 @@ if ($action == 'add' && !empty($permissiontoadd)) { } if (!$error) { + $db->begin(); + $result = $object->create($user); if ($result > 0) { // Creation OK @@ -141,14 +149,19 @@ if ($action == 'add' && !empty($permissiontoadd)) { $categories = GETPOST('categories', 'array:int'); $object->setCategories($categories); } + $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation + $db->commit(); + if (empty($noback)) { header("Location: " . $urltogo); exit; } } else { + $db->rollback(); + $error++; // Creation KO if (!empty($object->errors)) { @@ -177,7 +190,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { continue; } } else { - if (!GETPOSTISSET($key)) { + if (!GETPOSTISSET($key) && !preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) { continue; // The field was not submited to be saved } } @@ -215,6 +228,12 @@ if ($action == 'update' && !empty($permissiontoadd)) { $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0); } elseif ($object->fields[$key]['type'] == 'reference') { $value = array_keys($object->param_list)[GETPOST($key)].','.GETPOST($key.'2'); + } elseif (preg_match('/^chkbxlst:/', $object->fields[$key]['type'])) { + $value = ''; + $values_arr = GETPOST($key, 'array'); + if (!empty($values_arr)) { + $value = implode(',', $values_arr); + } } else { if ($key == 'lang') { $value = GETPOST($key, 'aZ09'); diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 69d46dae51c..385b36bdbce 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -34,7 +34,7 @@ if (!empty($permissioncreate) && empty($permissiontoadd)) { } // Build doc -if ($action == 'builddoc' && $permissiontoadd) { +if ($action == 'builddoc' && ($permissiontoadd || !empty($usercangeneretedoc))) { if (is_numeric(GETPOST('model', 'alpha'))) { $error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Model")); } else { diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 0056120c6bd..1f2143d4b72 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -42,6 +42,9 @@ if (!defined('NOREQUIRETRAN')) { require '../../main.inc.php'; +$action = GETPOST('action'); + + /* * View */ @@ -52,10 +55,10 @@ top_httphead(); //print ''."\n"; // Registering the location of boxes -if (isset($_GET['action']) && !empty($_GET['action'])) { - if ($_GET['action'] == 'getrandompassword' && ($user->admin || $user->rights->api->apikey->generate)) { +if ($action) { + if ($action == 'getrandompassword' && ($user->admin || $user->rights->api->apikey->generate)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generic = $_GET['generic'] ? true : false; + $generic = GETPOST('generic') ? true : false; echo getRandomPassword($generic); } } diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index c1199477f58..090fc52cb4f 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -64,7 +64,7 @@ $arrayresult = array(); // Define $searchform -if (!empty($conf->adherent->enabled) && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) { +if (isModEnabled('adherent') && empty($conf->global->MAIN_SEARCHFORM_ADHERENT_DISABLED) && $user->rights->adherent->lire) { $arrayresult['searchintomember'] = array('position'=>8, 'shortcut'=>'M', 'img'=>'object_member', 'label'=>$langs->trans("SearchIntoMembers", $search_boxvalue), 'text'=>img_picto('', 'object_member', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMembers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/adherents/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } @@ -72,44 +72,43 @@ if (((!empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_P $arrayresult['searchintothirdparty'] = array('position'=>10, 'shortcut'=>'T', 'img'=>'object_company', 'label'=>$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'text'=>img_picto('', 'object_company', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoThirdparties", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/societe/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->societe->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->rights->societe->lire) { +if (isModEnabled('societe') && empty($conf->global->MAIN_SEARCHFORM_CONTACT_DISABLED) && $user->hasRight('societe', 'lire')) { $arrayresult['searchintocontact'] = array('position'=>15, 'shortcut'=>'A', 'img'=>'object_contact', 'label'=>$langs->trans("SearchIntoContacts", $search_boxvalue), 'text'=>img_picto('', 'object_contact', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContacts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contact/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (((!empty($conf->product->enabled) && $user->rights->produit->lire) || (!empty($conf->service->enabled) && $user->rights->service->lire)) -&& empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { +if (((!empty($conf->product->enabled) && $user->hasRight('produit', 'lire')) || (!empty($conf->service->enabled) && $user->hasRight('service', 'lire'))) && empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_DISABLED)) { $arrayresult['searchintoproduct'] = array('position'=>30, 'shortcut'=>'P', 'img'=>'object_product', 'label'=>$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'text'=>img_picto('', 'object_product', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProductsOrServices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); // search on lot/serial numbers - if ( ! empty($conf->productbatch->enabled) ) { + if (isModEnabled('productbatch')) { $arrayresult['searchintobatch'] = array('position'=>32, 'shortcut'=>'B', 'img'=>'object_lot', 'label'=>$langs->trans("SearchIntoBatch", $search_boxvalue), 'text'=>img_picto('', 'object_lot', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoBatch", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/product/stock/productlot_list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } } -if (!empty($conf->mrp->enabled) && $user->rights->mrp->read && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED)) { +if (isModEnabled('mrp') && $user->hasRight('mrp', 'read') && empty($conf->global->MAIN_SEARCHFORM_MRP_DISABLED)) { $arrayresult['searchintomo'] = array('position'=>35, 'shortcut'=>'', 'img'=>'object_mrp', 'label'=>$langs->trans("SearchIntoMO", $search_boxvalue), 'text'=>img_picto('', 'object_mrp', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoMO", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/mrp/mo_list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->project->enabled) && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->rights->projet->lire) { +if (isModEnabled('project') && empty($conf->global->MAIN_SEARCHFORM_PROJECT_DISABLED) && $user->hasRight('projet', 'lire')) { $arrayresult['searchintoprojects'] = array('position'=>40, 'shortcut'=>'Q', 'img'=>'object_project', 'label'=>$langs->trans("SearchIntoProjects", $search_boxvalue), 'text'=>img_picto('', 'object_project', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoProjects", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->project->enabled) && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->rights->projet->lire) { +if (isModEnabled('project') && empty($conf->global->MAIN_SEARCHFORM_TASK_DISABLED) && $user->hasRight('projet', 'lire')) { $arrayresult['searchintotasks'] = array('position'=>45, 'img'=>'object_projecttask', 'label'=>$langs->trans("SearchIntoTasks", $search_boxvalue), 'text'=>img_picto('', 'object_projecttask', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTasks", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/projet/tasks/list.php'.($search_boxvalue ? '?search_all='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->propal->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->rights->propal->lire) { +if (isModEnabled('propal') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_PROPAL_DISABLED) && $user->hasRight('propal', 'lire')) { $arrayresult['searchintopropal'] = array('position'=>60, 'img'=>'object_propal', 'label'=>$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'text'=>img_picto('', 'object_propal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/comm/propal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->commande->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->rights->commande->lire) { +if (isModEnabled('commande') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_ORDER_DISABLED) && $user->hasRight('commande', 'lire')) { $arrayresult['searchintoorder'] = array('position'=>70, 'img'=>'object_order', 'label'=>$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'text'=>img_picto('', 'object_order', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerOrders", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/commande/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->expedition->enabled) && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->rights->expedition->lire) { +if (isModEnabled('expedition') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_SHIPMENT_DISABLED) && $user->hasRight('expedition', 'lire')) { $arrayresult['searchintoshipment'] = array('position'=>80, 'img'=>'object_shipment', 'label'=>$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'text'=>img_picto('', 'object_shipment', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerShipments", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expedition/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { +if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->hasRight('facture', 'lire')) { $arrayresult['searchintoinvoice'] = array('position'=>90, 'img'=>'object_bill', 'label'=>$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'text'=>img_picto('', 'object_bill', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoCustomerInvoices", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/compta/facture/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->supplier_proposal->enabled) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) { +if (isModEnabled('supplier_proposal') && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_PROPAL_DISABLED) && $user->rights->supplier_proposal->lire) { $arrayresult['searchintosupplierpropal'] = array('position'=>100, 'img'=>'object_supplier_proposal', 'label'=>$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'text'=>img_picto('', 'object_supplier_proposal', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoSupplierProposals", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/supplier_proposal/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)) && empty($conf->global->MAIN_SEARCHFORM_SUPPLIER_ORDER_DISABLED)) { @@ -120,7 +119,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S } // Customer payments -if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->rights->facture->lire) { +if (isModEnabled('facture') && empty($conf->global->MAIN_SEARCHFORM_CUSTOMER_INVOICE_DISABLED) && $user->hasRight('facture', 'lire')) { $arrayresult['searchintocustomerpayments'] = array( 'position'=>170, 'img'=>'object_payment', @@ -140,7 +139,7 @@ if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_S } // Miscellaneous payments -if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) { +if (isModEnabled('banque') && empty($conf->global->MAIN_SEARCHFORM_MISC_PAYMENTS_DISABLED) && $user->rights->banque->lire) { $arrayresult['searchintomiscpayments'] = array( 'position'=>180, 'img'=>'object_payment', @@ -149,24 +148,24 @@ if (!empty($conf->banque->enabled) && empty($conf->global->MAIN_SEARCHFORM_MISC_ 'url'=>DOL_URL_ROOT.'/compta/bank/various_payment/list.php?leftmenu=tax_various'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->contrat->enabled) && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { +if (isModEnabled('contrat') && empty($conf->global->MAIN_SEARCHFORM_CONTRACT_DISABLED) && $user->rights->contrat->lire) { $arrayresult['searchintocontract'] = array('position'=>130, 'img'=>'object_contract', 'label'=>$langs->trans("SearchIntoContracts", $search_boxvalue), 'text'=>img_picto('', 'object_contract', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoContracts", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/contrat/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->ficheinter->enabled) && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) { +if (isModEnabled('ficheinter') && empty($conf->global->MAIN_SEARCHFORM_FICHINTER_DISABLED) && $user->rights->ficheinter->lire) { $arrayresult['searchintointervention'] = array('position'=>140, 'img'=>'object_intervention', 'label'=>$langs->trans("SearchIntoInterventions", $search_boxvalue), 'text'=>img_picto('', 'object_intervention', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoInterventions", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/fichinter/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->ticket->enabled) && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) { +if (isModEnabled('ticket') && empty($conf->global->MAIN_SEARCHFORM_TICKET_DISABLED) && $user->rights->ticket->read) { $arrayresult['searchintotickets'] = array('position'=>145, 'img'=>'object_ticket', 'label'=>$langs->trans("SearchIntoTickets", $search_boxvalue), 'text'=>img_picto('', 'object_ticket', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoTickets", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/ticket/list.php?mainmenu=ticket'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } // HR -if (!empty($conf->user->enabled) && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { +if (isModEnabled('user') && empty($conf->global->MAIN_SEARCHFORM_USER_DISABLED) && $user->rights->user->user->lire) { $arrayresult['searchintouser'] = array('position'=>200, 'shortcut'=>'U', 'img'=>'object_user', 'label'=>$langs->trans("SearchIntoUsers", $search_boxvalue), 'text'=>img_picto('', 'object_user', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoUsers", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/user/list.php'.($search_boxvalue ? '?sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->expensereport->enabled) && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { +if (isModEnabled('expensereport') && empty($conf->global->MAIN_SEARCHFORM_EXPENSEREPORT_DISABLED) && $user->rights->expensereport->lire) { $arrayresult['searchintoexpensereport'] = array('position'=>210, 'img'=>'object_trip', 'label'=>$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'text'=>img_picto('', 'object_trip', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoExpenseReports", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/expensereport/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } -if (!empty($conf->holiday->enabled) && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) { +if (isModEnabled('holiday') && empty($conf->global->MAIN_SEARCHFORM_HOLIDAY_DISABLED) && $user->rights->holiday->read) { $arrayresult['searchintoleaves'] = array('position'=>220, 'img'=>'object_holiday', 'label'=>$langs->trans("SearchIntoLeaves", $search_boxvalue), 'text'=>img_picto('', 'object_holiday', 'class="pictofixedwidth"').' '.$langs->trans("SearchIntoLeaves", $search_boxvalue), 'url'=>DOL_URL_ROOT.'/holiday/list.php?mainmenu=hrm'.($search_boxvalue ? '&sall='.urlencode($search_boxvalue) : '')); } diff --git a/htdocs/core/boxes/box_accountancy_last_manual_entries.php b/htdocs/core/boxes/box_accountancy_last_manual_entries.php index 96abd8699f3..a15728a04f0 100644 --- a/htdocs/core/boxes/box_accountancy_last_manual_entries.php +++ b/htdocs/core/boxes/box_accountancy_last_manual_entries.php @@ -60,7 +60,7 @@ class box_accountancy_last_manual_entries extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); + $this->hidden = empty($user->rights->accounting->mouvements->lire); } /** diff --git a/htdocs/core/boxes/box_accountancy_suspense_account.php b/htdocs/core/boxes/box_accountancy_suspense_account.php index f40c6e8a41b..3ea5b191799 100644 --- a/htdocs/core/boxes/box_accountancy_suspense_account.php +++ b/htdocs/core/boxes/box_accountancy_suspense_account.php @@ -60,7 +60,7 @@ class box_accountancy_suspense_account extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->accounting->mouvements->lire); + $this->hidden = empty($user->rights->accounting->mouvements->lire); } /** diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index 551b892f0f7..fb0f93086d2 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -62,7 +62,7 @@ class box_actions extends ModeleBoxes $this->enabled = $conf->agenda->enabled; - $this->hidden = !($user->rights->agenda->myactions->read); + $this->hidden = !($user->hasRight('agenda', 'myactions', 'read')); } /** diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index ea43eff12fc..49690dc893e 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -63,8 +63,8 @@ class box_activity extends ModeleBoxes $this->enabled = ($conf->global->MAIN_FEATURES_LEVEL); // Not enabled by default due to bugs (see previous comments) $this->hidden = !((isModEnabled('facture') && $user->rights->facture->lire) - || (!empty($conf->commande->enabled) && $user->rights->commande->lire) - || (!empty($conf->propal->enabled) && $user->rights->propale->lire) + || (isModEnabled('commande') && $user->rights->commande->lire) + || (isModEnabled('propal') && $user->rights->propale->lire) ); } diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index a9a4f8746da..2ace554eb55 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -60,7 +60,7 @@ class box_boms extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->bom->read); + $this->hidden = empty($user->rights->bom->read); } /** diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 1a3a1183032..3e8abd587c0 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -56,7 +56,7 @@ class box_bookmarks extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->bookmark->lire); + $this->hidden = empty($user->rights->bookmark->lire); } /** diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index b5656c36292..f4aec2075d7 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -60,7 +60,7 @@ class box_commandes extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->commande->lire); + $this->hidden = empty($user->rights->commande->lire); } /** diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 5570051a065..606f8409161 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -68,7 +68,7 @@ class box_comptes extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !($user->rights->banque->lire); + $this->hidden = empty($user->rights->banque->lire); } /** diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index ea35a080d0e..f257d7db18d 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -63,7 +63,7 @@ class box_contacts extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->societe->lire && $user->rights->societe->contact->lire); + $this->hidden = !($user->hasRight('societe', 'lire') && $user->hasRight('societe', 'contact', 'lire')); } /** diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index dddafffdc02..99ea5541c98 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -59,7 +59,7 @@ class box_contracts extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); + $this->hidden = !($user->hasRight('contrat', 'lire')); } /** diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 4b85ce9d396..83615c17fd3 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -112,32 +112,32 @@ class box_dolibarr_state_board extends ModeleBoxes 'dolresource' ); $conditions = array( - 'users' => $user->rights->user->user->lire, - 'members' => !empty($conf->adherent->enabled) && $user->rights->adherent->lire, - 'customers' => !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), - 'prospects' => !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), + 'users' => $user->hasRight('user', 'user', 'lire'), + 'members' => isModEnabled('adherent') && $user->rights->adherent->lire, + 'customers' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS), + 'prospects' => isModEnabled('societe') && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS), 'suppliers' => ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire) ) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS), - 'contacts' => !empty($conf->societe->enabled) && $user->rights->societe->contact->lire, - 'products' => !empty($conf->product->enabled) && $user->rights->produit->lire, - 'services' => !empty($conf->service->enabled) && $user->rights->service->lire, - 'proposals' => !empty($conf->propal->enabled) && $user->rights->propale->lire, - 'orders' => !empty($conf->commande->enabled) && $user->rights->commande->lire, - 'invoices' => isModEnabled('facture') && $user->rights->facture->lire, - 'donations' => !empty($conf->don->enabled) && $user->rights->don->lire, - 'contracts' => !empty($conf->contrat->enabled) && $user->rights->contrat->lire, - 'interventions' => !empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire, - 'supplier_orders' => !empty($conf->supplier_order->enabled) && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), - 'supplier_invoices' => !empty($conf->supplier_invoice->enabled) && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), - 'supplier_proposals' => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), - 'projects' => !empty($conf->project->enabled) && $user->rights->projet->lire, - 'expensereports' => !empty($conf->expensereport->enabled) && $user->rights->expensereport->lire, - 'holidays' => !empty($conf->holiday->enabled) && $user->rights->holiday->read, - 'ticket' => !empty($conf->ticket->enabled) && $user->rights->ticket->read, - 'dolresource' => !empty($conf->resource->enabled) && $user->rights->resource->read + 'contacts' => isModEnabled('societe') && $user->hasRight('societe', 'contact', 'lire'), + 'products' => isModEnabled('product') && $user->hasRight('produit', 'lire'), + 'services' => isModEnabled('service') && $user->hasRight('service', 'lire'), + 'proposals' => isModEnabled('propal') && $user->hasRight('propale', 'lire'), + 'orders' => isModEnabled('commande') && $user->hasRight('commande', 'lire'), + 'invoices' => isModEnabled('facture') && $user->hasRight('facture', 'lire'), + 'donations' => isModEnabled('don') && $user->hasRight('don', 'lire'), + 'contracts' => isModEnabled('contrat') && $user->hasRight('contrat', 'lire'), + 'interventions' => isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire'), + 'supplier_orders' => isModEnabled('supplier_order') && $user->rights->fournisseur->commande->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_ORDERS_STATS), + 'supplier_invoices' => isModEnabled('supplier_invoice') && $user->rights->fournisseur->facture->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_INVOICES_STATS), + 'supplier_proposals' => isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_PROPOSAL_STATS), + 'projects' => isModEnabled('project') && $user->hasRight('projet', 'lire'), + 'expensereports' => isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire'), + 'holidays' => isModEnabled('holiday') && $user->hasRight('holiday', 'read'), + 'ticket' => isModEnabled('ticket') && $user->hasRight('ticket', 'read'), + 'dolresource' => isModEnabled('resource') && $user->hasRight('resource', 'read') ); $classes = array( 'users' => 'User', diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index 43087949e47..e34e89c97eb 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -58,7 +58,7 @@ class box_factures extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = empty($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 5fc3bdafa38..06124d4ab35 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -59,7 +59,7 @@ class box_factures_fourn extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->hasRight('fournisseur', 'facture', 'lire')); } /** diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index d8c9321411d..ad6c6c97c27 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -58,7 +58,7 @@ class box_factures_fourn_imp extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = !($user->hasRight('fournisseur', 'facture', 'lire')); } /** diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 6d6893f8ae2..a6103c26257 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -61,7 +61,7 @@ class box_factures_imp extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = empty($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index b0f0e691471..f69ccb0ad94 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -59,7 +59,7 @@ class box_ficheinter extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->ficheinter->lire); + $this->hidden = !($user->hasRight('ficheinter', 'lire')); } /** diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index ab425ceac87..3341e08107d 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -69,7 +69,7 @@ class box_goodcustomers extends ModeleBoxes $this->enabled = 0; // not enabled by default. Very slow on large database } - $this->hidden = !($user->rights->societe->lire); + $this->hidden = empty($user->rights->societe->lire); } /** diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 8179e134bcf..03b0e1d087b 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -56,7 +56,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = empty($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index 9126cfcfb37..5a9b84829f2 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -54,7 +54,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->facture->lire); + $this->hidden = empty($user->rights->facture->lire); } /** diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index fc91cb692c1..75e51e071f8 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -56,7 +56,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->facture->lire); + $this->hidden = empty($user->rights->fournisseur->facture->lire); } /** diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 885ec469632..c4205901528 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -56,7 +56,7 @@ class box_graph_orders_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->commande->lire); + $this->hidden = empty($user->rights->commande->lire); } /** diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index db7400c1c5a..433ba660365 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -56,7 +56,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); + $this->hidden = empty($user->rights->fournisseur->commande->lire); } /** diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index afed778912f..44f94fd48d1 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -61,8 +61,8 @@ class box_graph_product_distribution extends ModeleBoxes $this->hidden = !( (isModEnabled('facture') && !empty($user->rights->facture->lire)) - || (!empty($conf->commande->enabled) && !empty($user->rights->commande->lire)) - || (!empty($conf->propal->enabled) && !empty($user->rights->propale->lire)) + || (isModEnabled('commande') && !empty($user->rights->commande->lire)) + || (isModEnabled('propal') && !empty($user->rights->propale->lire)) ); } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index cb9a543bc19..13f3a29ec16 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -56,7 +56,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->propale->lire); + $this->hidden = empty($user->rights->propale->lire); } /** diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index cff19388c17..812fcab7b64 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -60,7 +60,7 @@ class box_mos extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->bom->read); + $this->hidden = empty($user->rights->bom->read); } /** diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 909ff32acb9..80d465f0f87 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -62,7 +62,7 @@ class box_project extends ModeleBoxes $this->db = $db; $this->boxlabel = "OpenedProjects"; - $this->hidden = !($user->rights->projet->lire); + $this->hidden = empty($user->rights->projet->lire); } /** diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index cdaf629ae3f..8e8efc8d8f3 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -61,7 +61,7 @@ class box_propales extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->propale->lire); + $this->hidden = !($user->hasRight('propale', 'lire')); } /** diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index e9cca792de1..25fa5ca2b1f 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -58,7 +58,7 @@ class box_services_expired extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->contrat->lire); + $this->hidden = !($user->hasRight('contrat', 'lire')); } /** diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index ba95fe14356..4e54f3c5992 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -60,7 +60,7 @@ class box_shipments extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->expedition->lire); + $this->hidden = empty($user->rights->expedition->lire); } /** diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index 6ee0c5ef8a3..f3db3526bb6 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -58,7 +58,7 @@ class box_supplier_orders extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->hasRight('fournisseur', 'commande', 'lire')); } /** diff --git a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php index 32151828b83..ce0161582de 100644 --- a/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php +++ b/htdocs/core/boxes/box_supplier_orders_awaiting_reception.php @@ -58,7 +58,7 @@ class box_supplier_orders_awaiting_reception extends ModeleBoxes $this->db = $db; - $this->hidden = !($user->rights->fournisseur->commande->lire); + $this->hidden = !($user->hasRight('fournisseur', 'commande', 'lire')); } /** diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 82e917b102a..3f3c9d83a62 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -64,7 +64,7 @@ class box_task extends ModeleBoxes $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || !($user->rights->projet->lire)); + $this->hidden = (!empty($conf->global->PROJECT_HIDE_TASKS) || empty($user->rights->projet->lire)); } /** diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index e57bb1f14d9..bab64d5a000 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -66,7 +66,7 @@ class box_validated_projects extends ModeleBoxes $this->db = $db; $this->boxlabel = "ProjectTasksWithoutTimeSpent"; - $this->hidden = !($user->rights->projet->lire); + $this->hidden = empty($user->rights->projet->lire); if ($conf->global->MAIN_FEATURES_LEVEL < 2) { $this->enabled = 0; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bee63613bca..d0b64fdca77 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -895,7 +895,12 @@ abstract class CommonDocGenerator //Add value to store price with currency $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_currency' => $object->array_options['options_'.$key.'_currency'])); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select') { - $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; + $valueofselectkey = $object->array_options['options_'.$key]; + if (array_key_exists($valueofselectkey, $extrafields->attributes[$object->table_element]['param'][$key]['options'])) { + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$valueofselectkey]; + } else { + $object->array_options['options_'.$key] = ''; + } } elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $valArray = explode(',', $object->array_options['options_'.$key]); $output = array(); @@ -945,7 +950,11 @@ abstract class CommonDocGenerator } } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + if (array_key_exists('option_'.$key, $object->array_options)) { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + } else { + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => '')); + } } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4d83acfe44c..2d393ab9dc3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -588,6 +588,10 @@ abstract class CommonObject public $alreadypaid; + private $labelStatus; + private $labelStatusShort; + + /** * @var array List of child tables. To test if we can delete object. */ @@ -755,6 +759,8 @@ abstract class CommonObject $this->address = dol_strtoupper($this->address); $this->town = dol_strtoupper($this->town); } + $this->email = dol_strtolower($this->email); + $this->personal_email = dol_strtolower($this->personal_email); } /** @@ -5470,7 +5476,7 @@ abstract class CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. - $sav_charset_output = $outputlangs->charset_output; + $sav_charset_output = empty($outputlangs->charset_output) ? '' : $outputlangs->charset_output; if (in_array(get_class($this), array('Adherent'))) { $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams); @@ -6763,6 +6769,9 @@ abstract class CommonObject } elseif (preg_match('/^(sellist):(.*):(.*)/i', $val['type'], $reg)) { $param['options'] = array($reg[2].':'.$reg[3] => 'N'); $type = 'sellist'; + } elseif (preg_match('/^chkbxlst:(.*)/i', $val['type'], $reg)) { + $param['options'] = array($reg[1] => 'N'); + $type = 'chkbxlst'; } elseif (preg_match('/varchar\((\d+)\)/', $val['type'], $reg)) { $param['options'] = array(); $type = 'varchar'; @@ -6865,7 +6874,7 @@ abstract class CommonObject $out = ''; } elseif (preg_match('/varchar/', $type)) { $out = ' 0 ? ' maxlength="'.$size.'"' : '').' value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>'; - } elseif (in_array($type, array('mail', 'phone', 'url'))) { + } elseif (in_array($type, array('email', 'mail', 'phone', 'url', 'ip'))) { $out = ''; } elseif (preg_match('/^text/', $type)) { if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field @@ -6916,7 +6925,9 @@ abstract class CommonObject if ((string) $keyb == '') { continue; } - if (strpos($valb, "|") !== false) list($valb, $parent) = explode('|', $valb); + if (strpos($valb, "|") !== false) { + list($valb, $parent) = explode('|', $valb); + } $out .= ''; - $num = $this->db->num_rows($resql); - $i = 0; - while ($i < $num) { - $labeltoshow = ''; - $obj = $this->db->fetch_object($resql); - - // Several field into label (eq table:code|libelle:rowid) - $notrans = false; - $fields_label = explode('|', $InfoFieldList[1]); - if (count($fields_label) > 1) { - $notrans = true; - foreach ($fields_label as $field_toshow) { - $labeltoshow .= $obj->$field_toshow.' '; - } - } else { - $labeltoshow = $obj->{$InfoFieldList[1]}; + $sqlwhere = ''; + $sql = "SELECT " . $keyList; + $sql .= " FROM " . $this->db->prefix() . $InfoFieldList[0]; + if (!empty($InfoFieldList[4])) { + // can use SELECT request + if (strpos($InfoFieldList[4], '$SEL$') !== false) { + $InfoFieldList[4] = str_replace('$SEL$', 'SELECT', $InfoFieldList[4]); } - $labeltoshow = dol_trunc($labeltoshow, 45); - if ($value == $obj->rowid) { - foreach ($fields_label as $field_toshow) { - $translabel = $langs->trans($obj->$field_toshow); - if ($translabel != $obj->$field_toshow) { - $labeltoshow = dol_trunc($translabel).' '; - } else { - $labeltoshow = dol_trunc($obj->$field_toshow).' '; - } - } - $out .= ''; + // current object id can be use into filter + if (strpos($InfoFieldList[4], '$ID$') !== false && !empty($objectid)) { + $InfoFieldList[4] = str_replace('$ID$', $objectid, $InfoFieldList[4]); } else { - if (!$notrans) { - $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - if ($translabel != $obj->{$InfoFieldList[1]}) { - $labeltoshow = dol_trunc($translabel, 18); - } else { - $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}); + $InfoFieldList[4] = str_replace('$ID$', '0', $InfoFieldList[4]); + } + + //We have to join on extrafield table + if (strpos($InfoFieldList[4], 'extra') !== false) { + $sql .= " as main, " . $this->db->prefix() . $InfoFieldList[0] . "_extrafields as extra"; + $sqlwhere .= " WHERE extra.fk_object=main." . $InfoFieldList[2] . " AND " . $InfoFieldList[4]; + } else { + $sqlwhere .= " WHERE " . $InfoFieldList[4]; + } + } else { + $sqlwhere .= ' WHERE 1=1'; + } + // Some tables may have field, some other not. For the moment we disable it. + if (in_array($InfoFieldList[0], array('tablewithentity'))) { + $sqlwhere .= " AND entity = " . ((int) $conf->entity); + } + $sql .= $sqlwhere; + //print $sql; + + $sql .= ' ORDER BY ' . implode(', ', $fields_label); + + dol_syslog(get_class($this) . '::showInputField type=sellist', LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $out .= ''; + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < $num) { + $labeltoshow = ''; + $obj = $this->db->fetch_object($resql); + + // Several field into label (eq table:code|libelle:rowid) + $notrans = false; + $fields_label = explode('|', $InfoFieldList[1]); + if (count($fields_label) > 1) { + $notrans = true; + foreach ($fields_label as $field_toshow) { + $labeltoshow .= $obj->$field_toshow . ' '; } + } else { + $labeltoshow = $obj->{$InfoFieldList[1]}; } - if (empty($labeltoshow)) { - $labeltoshow = '(not defined)'; - } + $labeltoshow = dol_trunc($labeltoshow, 45); + if ($value == $obj->rowid) { - $out .= ''; + foreach ($fields_label as $field_toshow) { + $translabel = $langs->trans($obj->$field_toshow); + if ($translabel != $obj->$field_toshow) { + $labeltoshow = dol_trunc($translabel) . ' '; + } else { + $labeltoshow = dol_trunc($obj->$field_toshow) . ' '; + } + } + $out .= ''; + } else { + if (!$notrans) { + $translabel = $langs->trans($obj->{$InfoFieldList[1]}); + if ($translabel != $obj->{$InfoFieldList[1]}) { + $labeltoshow = dol_trunc($translabel, 18); + } else { + $labeltoshow = dol_trunc($obj->{$InfoFieldList[1]}); + } + } + if (empty($labeltoshow)) { + $labeltoshow = '(not defined)'; + } + if ($value == $obj->rowid) { + $out .= ''; + } + + if (!empty($InfoFieldList[3]) && $parentField) { + $parent = $parentName . ':' . $obj->{$parentField}; + $isDependList = 1; + } + + $out .= ''; } - if (!empty($InfoFieldList[3]) && $parentField) { - $parent = $parentName.':'.$obj->{$parentField}; - $isDependList = 1; - } - - $out .= ''; + $i++; } - - $i++; + $this->db->free($resql); + } else { + print 'Error in request ' . $sql . ' ' . $this->db->lasterror() . '. Check setup of extra parameters.
'; } - $this->db->free($resql); } else { - print 'Error in request '.$sql.' '.$this->db->lasterror().'. Check setup of extra parameters.
'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $data = $form->select_all_categories(Categorie::$MAP_ID_TO_CODE[$InfoFieldList[5]], '', 'parent', 64, $InfoFieldList[6], 1, 1); + $out .= ''; + foreach ($data as $data_key => $data_value) { + $out .= '\n"; // Add new entry // "key" value of json key array is used by jQuery automatically as selected value. Example: 'type' = product or service, 'price_ht' = unit price without tax // "label" value of json key array is used by jQuery automatically as text for combo box - $out .= $opt; - array_push( - $outarray, - array('key'=>$outkey, - 'value'=>$outref, - 'label'=>$outval, - 'qty'=>$outqty, - 'price_qty_ht'=>price2num($objp->fprice, 'MU'), // Keep higher resolution for price for the min qty - 'price_unit_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price - 'price_ht'=>price2num($objp->unitprice, 'MU'), // This is used to fill the Unit Price (for compatibility) - 'tva_tx'=>$objp->tva_tx, - 'default_vat_code'=>$objp->default_vat_code, - 'discount'=>$outdiscount, - 'type'=>$outtype, - 'duration_value'=>$outdurationvalue, - 'duration_unit'=>$outdurationunit, - 'disabled'=>(empty($objp->idprodfournprice) ? true : false), - 'description'=>$objp->description - ) - ); + $out .= $optstart . ' data-html="'.dol_escape_htmltag($optlabel).'">' . $optlabel . "\n";; + array_push($outarray, $outarrayentry); + // Exemple of var_dump $outarray // array(1) {[0]=>array(6) {[key"]=>string(1) "2" ["value"]=>string(3) "ppp" // ["label"]=>string(76) "ppp (fff2) - ppp - 20,00 Euros/1unité (20,00 Euros/unité)" @@ -4910,9 +4913,10 @@ class Form * @param string $title Title * @param string $question Question * @param string $action Action - * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>)) - * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'select', 'multiselect', 'morecss', 'other' or 'onecolumn'... - * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' + * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , 'size'=>, 'morecss'=>, 'moreattr'=>'autofocus' or 'style=...')) + * 'type' can be 'text', 'password', 'checkbox', 'radio', 'date', 'select', 'multiselect', 'morecss', + * 'other', 'onecolumn' or 'hidden'... + * @param int|string $selectedchoice '' or 'no', or 'yes' or '1', 1, '0' or 0 * @param int|string $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx * @param int|string $height Force height of box (0 = auto) * @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones. @@ -9384,7 +9388,8 @@ class Form $ret .= ''; // gravatar need md5 hash } else { if ($nophoto == 'company') { - $ret .= '
'.img_picto('', 'company').'
'; + $ret .= '
'.img_picto('', 'company').'
'; + $ret .= '
'; } else { $ret .= ''; } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 242c1476736..99003f00276 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -327,11 +327,11 @@ class FormActions $cursorevent++; } } else { - print ''; + print ''; } if ($max && $num > $max) { - print ''; + print ''; } print '
'; - print $langs->trans("AddProjectIntoCategory").'  '; + print $langs->trans("AddObjectIntoCategory").'  '; print $form->select_dolusers('', 'elemid'); print '
'.$langs->trans("Date").'fulldayevent ? ' checked' : '').'>'; print ''; - // Recurring event - $userepeatevent = ($conf->global->MAIN_FEATURES_LEVEL == 2 ? 1 : 0); - if ($userepeatevent) { - // Repeat - //print '
'; - print '        
'; - print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); - print ''; - $selectedrecurrulefreq = 'no'; - $selectedrecurrulebymonthday = ''; - $selectedrecurrulebyday = ''; - if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { - $selectedrecurrulefreq = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebymonthday = $reg[1]; - } - if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { - $selectedrecurrulebyday = $reg[1]; - } - print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); - // If recurrulefreq is MONTHLY - print ''; - // If recurrulefreq is WEEKLY - print ''; - print ''; - print '
'; - //print '
'; + // print '        
'; + // print img_picto($langs->trans("Recurrence"), 'recurring', 'class="paddingright2"'); + // print ''; + // $selectedrecurrulefreq = 'no'; + // $selectedrecurrulebymonthday = ''; + // $selectedrecurrulebyday = ''; + // if ($object->recurrule && preg_match('/FREQ=([A-Z]+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulefreq = $reg[1]; + // } + // if ($object->recurrule && preg_match('/FREQ=MONTHLY.*BYMONTHDAY=(\d+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulebymonthday = $reg[1]; + // } + // if ($object->recurrule && preg_match('/FREQ=WEEKLY.*BYDAY(\d+)/i', $object->recurrule, $reg)) { + // $selectedrecurrulebyday = $reg[1]; + // } + // print $form->selectarray('recurrulefreq', $arrayrecurrulefreq, $selectedrecurrulefreq, 0, 0, 0, '', 0, 0, 0, '', 'marginrightonly'); + // // If recurrulefreq is MONTHLY + // print ''; + // // If recurrulefreq is WEEKLY + // print ''; + // print ''; + // print '
'; + // //print '
'.$obj->title.''.dol_escape_htmltag($obj->title).''; @@ -286,7 +286,7 @@ if ($resql) { // Nb of email if (!$filteremail) { - print ''; + print ''; $nbemail = $obj->nbemail; /*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 668787349be..aa26e7be794 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -108,16 +108,18 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once -$usercanread = $user->rights->commande->lire; -$usercancreate = $user->rights->commande->creer; -$usercandelete = $user->rights->commande->supprimer; +$usercanread = $user->hasRight('commande', 'lire'); +$usercancreate = $user->hasRight('commande', 'creer'); +$usercandelete = $user->hasRight('commande', 'supprimer'); // Advanced permissions -$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->creer)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->close))); -$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->validate))); -$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->commande->order_advance->annuler))); -$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send); -$usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); +$usercanclose = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($usercancreate)) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'close')))); +$usercanvalidate = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'validate')))); +$usercancancel = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $usercancreate) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->hasRight('commande', 'order_advance', 'annuler')))); +$usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'send')); +$usercangeneretedoc = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->hasRight('commande', 'order_advance', 'generetedoc')); + +$usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -2747,7 +2749,7 @@ if ($action == 'create' && $usercancreate) { $langs->load("interventions"); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { - if ($user->rights->ficheinter->creer) { + if ($user->hasRight('ficheinter', 'creer')) { print dolGetButtonAction('', $langs->trans('AddIntervention'), 'default', DOL_URL_ROOT.'/fichinter/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } else { print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('AddIntervention'), 'default', $_SERVER['PHP_SELF']. '#', '', false); @@ -2759,7 +2761,7 @@ if ($action == 'create' && $usercancreate) { if (!empty($conf->contrat->enabled) && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_SHIPMENTONPROCESS || $object->statut == Commande::STATUS_CLOSED)) { $langs->load("contracts"); - if ($user->rights->contrat->creer) { + if ($user->hasRight('contrat', 'creer')) { print dolGetButtonAction('', $langs->trans('AddContract'), 'default', DOL_URL_ROOT.'/contrat/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } } @@ -2771,7 +2773,7 @@ if ($action == 'create' && $usercancreate) { if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { - if ($user->rights->expedition->creer) { + if ($user->hasRight('expedition', 'creer')) { print dolGetButtonAction('', $langs->trans('CreateShipment'), 'default', DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('NotAllowed'), $langs->trans('CreateShipment'), 'default', $_SERVER['PHP_SELF']. '#', '', false); @@ -2790,7 +2792,7 @@ if ($action == 'create' && $usercancreate) { // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { - if (isModEnabled('facture') && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { + if (isModEnabled('facture') && $user->hasRight('facture', 'creer') && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { print dolGetButtonAction('', $langs->trans('CreateBill'), 'default', DOL_URL_ROOT.'/compta/facture/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, ''); } if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index ee25ea86eff..dbb99d0f993 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -1217,7 +1217,7 @@ if ($resql) { if ($permissiontocancel) { $arrayofmassactions['cancelorders'] = img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"); } - if ($user->rights->facture->creer) { + if (!empty($conf->invoice->enabled) && $user->rights->facture->creer) { $arrayofmassactions['createbills'] = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("CreateInvoiceForThisCustomer"); } if ($permissiontoclose) { diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 7a7097ecb71..21a082e9491 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2390,7 +2390,7 @@ class AccountLine extends CommonObject $result = ''; - $label = img_picto('', $this->picto).' '.$langs->trans("Transaction").':
'; + $label = img_picto('', $this->picto).' '.$langs->trans("BankTransactionLine").':
'; $label .= ''.$langs->trans("Ref").': '.$this->ref; $linkstart = ''; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 8bad5dbebd0..48ea553abf0 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -606,45 +606,20 @@ class PaymentVarious extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; - - if ($mode == 0) { - return $langs->trans($this->statuts[$status]); - } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$status]); - } elseif ($mode == 2) { - if ($status == 0) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - } elseif ($status == 1) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); - } elseif ($status == 2) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - } - } elseif ($mode == 3) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } - } elseif ($mode == 4) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - } - } elseif ($mode == 5) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + /*$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled');*/ } + + $statusType = 'status'.$status; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 601ef04de45..cbcb2fd5417 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -588,6 +588,8 @@ if ($id) { $morehtmlref .= ''; $linkback = ''.$langs->trans("BackToList").''; + $morehtmlright = ''; + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; @@ -617,7 +619,7 @@ if ($id) { } print '
'.$langs->trans("Sens").''.$sens.'
'.$langs->trans("Amount").''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans("Amount").''.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'
'; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index f56e21a2fe2..fdebf7f795c 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -537,6 +537,8 @@ if ($resql) { $totalarray = array(); $totalarray['nbfield'] = 0; $totalarray['val']['total_cred'] = 0; + $totalarray['val']['total_deb'] = 0; + while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index fb4f9eb17d4..fa812a14c3d 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -1,6 +1,4 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin @@ -102,6 +100,8 @@ class Deplacement extends CommonObject public $statuts = array(); public $statuts_short = array(); + public $statuts_logo = array(); + /** * Draft status @@ -129,6 +129,7 @@ class Deplacement extends CommonObject $this->statuts_short = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); $this->statuts = array(0 => 'Draft', 1 => 'Validated', 2 => 'Refunded'); + $this->statuts_logo = array(0 => 'status0', 1=>'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5'); } /** @@ -360,43 +361,12 @@ class Deplacement extends CommonObject // phpcs:enable global $langs; - if ($mode == 0) { - return $langs->trans($this->statuts[$status]); - } elseif ($mode == 1) { - return $langs->trans($this->statuts_short[$status]); - } elseif ($mode == 2) { - if ($status == 0) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts_short[$status]); - } elseif ($status == 1) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts_short[$status]); - } elseif ($status == 2) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts_short[$status]); - } - } elseif ($mode == 3) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } - } elseif ($mode == 4) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut0').' '.$langs->trans($this->statuts[$status]); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut4').' '.$langs->trans($this->statuts[$status]); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return img_picto($langs->trans($this->statuts_short[$status]), 'statut6').' '.$langs->trans($this->statuts[$status]); - } - } elseif ($mode == 5) { - if ($status == 0 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut0'); - } elseif ($status == 1 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut4'); - } elseif ($status == 2 && !empty($this->statuts_short[$status])) { - return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]), 'statut6'); - } - } + $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); + $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + + $statusType = $this->statuts_logo[$status]; + + return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode); } /** diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index a864168d161..285d9d366f7 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -668,6 +668,8 @@ class Invoices extends DolibarrApi $result = $this->invoice->delete(DolibarrApiAccess::$user); if ($result < 0) { throw new RestException(500, 'Error when deleting invoice'); + } elseif ($result == 0) { + throw new RestException(403, 'Invoice not erasable'); } return array( diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e9d1a449b0c..91b5df73a00 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5603,6 +5603,9 @@ class Facture extends CommonInvoice //$actioncomm->email_subject = $subject; $actioncomm->errors_to = $errors_to; + $actioncomm->elementtype = 'invoice'; + $actioncomm->fk_element = $tmpinvoice->id; + //$actioncomm->extraparams = $extraparams; $actioncomm->create($user); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f63d58db933..25543ed9d82 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -57,6 +57,7 @@ class Paiement extends CommonObject public $facid; public $datepaye; + public $date; // same than $datepaye /** * @deprecated @@ -153,6 +154,7 @@ class Paiement extends CommonObject */ public $ref_ext; + /** * Constructor * diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index ae92286dfec..d9cb6f6fb7d 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -1,8 +1,9 @@ - * Copyright (C) 2005-2016 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2010-2018 Juanjo Menent +/* Copyright (C) 2005 Rodolphe Quiedeville + * Copyright (C) 2005-2016 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2010-2018 Juanjo Menent + * Copyright (C) 2022 Alexandre Spangaro * * 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 @@ -108,7 +109,7 @@ llxHeader('', $langs->trans("WithdrawalsLines")); $sql = "SELECT p.rowid, p.ref, p.statut as status, p.datec"; $sql .= " , f.rowid as facid, f.ref as invoiceref, f.total_ttc"; -$sql .= " , s.rowid as socid, s.nom as name, s.code_client, s.email"; +$sql .= " , s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.email"; $sql .= " , pl.amount, pl.statut as statut_ligne, pl.rowid as rowid_ligne"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= " , ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -139,7 +140,7 @@ if ($search_bon) { } if ($type == 'bank-transfer') { if ($search_code) { - $sql .= natural_search("s.code_fourn", $search_code); + $sql .= natural_search("s.code_fournisseur", $search_code); } } else { if ($search_code) { @@ -172,6 +173,9 @@ if ($result) { $param = "&statut=".urlencode($statut); $param .= "&search_bon=".urlencode($search_bon); + if ($type == 'bank-transfer') { + $param .= '&type=bank-transfer'; + } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } @@ -204,7 +208,7 @@ if ($result) { print '   '; @@ -214,8 +218,12 @@ if ($result) { print '
'; - print ''; - print img_object($langs->trans("ShowBill"), "bill"); - print ' '.$obj->invoiceref."'.$obj->code_client."'; + $link_to_tab = '/comm/card.php?socid='; + $link_code = $obj->code_client; + if ($type == 'bank-transfer') { + $link_to_tab = '/fourn/card.php?socid='; + $link_code = $obj->code_fournisseur; + } + print ''.$link_code."'.dol_print_date($db->jdate($obj->datec), 'day')."
'.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; $cate_arbo = $form->select_all_categories(Categorie::TYPE_CONTACT, null, null, null, null, 1); @@ -1301,11 +1300,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $action = 'presend'; } + // View mode if (!empty($id) && $action != 'edit' && $action != 'create') { $objsoc = new Societe($db); - // View mode - // Show errors dol_htmloutput_errors(is_numeric($error) ? '' : $error, $errors); @@ -1530,9 +1528,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if ($object->user_id) { $dolibarr_user = new User($db); $result = $dolibarr_user->fetch($object->user_id); - print $dolibarr_user->getLoginUrl(1); + print $dolibarr_user->getLoginUrl(-1); } else { - print $langs->trans("NoDolibarrAccess"); + //print ''.$langs->trans("NoDolibarrAccess").''; + if (!$object->user_id && $user->rights->user->user->creer) { + print ''.img_picto($langs->trans("CreateDolibarrLogin"), 'add', 'class="pictofixedwidth"').$langs->trans("CreateDolibarrLogin").''; + } } print '
'; - print $obj->import_key; + print dol_escape_htmltag($obj->import_key); print "
'.$langs->trans("None").'
'.$langs->trans("None").'
'.$langs->trans("More").'...
'.$langs->trans("More").'...
'; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 32f2a9b1007..2a900ea53a4 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -825,13 +825,14 @@ class FormCompany extends Form /** * showContactRoles on view and edit mode * - * @param string $htmlname Html component name and id - * @param Contact $contact Contact Obejct - * @param string $rendermode view, edit - * @param array $selected $key=>$val $val is selected Roles for input mode - * @return string String with contacts roles + * @param string $htmlname Html component name and id + * @param Contact $contact Contact Obejct + * @param string $rendermode view, edit + * @param array $selected $key=>$val $val is selected Roles for input mode + * @param string $morecss More css + * @return string String with contacts roles */ - public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array()) + public function showRoles($htmlname, Contact $contact, $rendermode = 'view', $selected = array(), $morecss = 'minwidth500') { if ($rendermode === 'view') { $toprint = array(); @@ -856,7 +857,7 @@ class FormCompany extends Form $selected = $newselected; } } - return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, 'minwidth500'); + return $this->multiselectarray($htmlname, $contactType, $selected, 0, 0, $morecss); } return 'ErrorBadValueForParameterRenderMode'; // Should not happened diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index df7408200a9..4c77566eeed 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -954,7 +954,7 @@ class FormMail extends Form $out .= ''; } else { if (!isset($this->ckeditortoolbar)) { - $this->ckeditortoolbar = 'dolibarr_notes'; + $this->ckeditortoolbar = 'dolibarr_mailings'; } // Editor wysiwyg diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5bee2f31dd4..103b370dcb0 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -1513,9 +1513,10 @@ class FormOther * @param array $search_xaxis Array of preselected fields * @param array $arrayofxaxis Array of groupby to fill * @param string $showempty '1' or 'text' + * @param string $morecss More css * @return string HTML string component */ - public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1') + public function selectXAxisField($object, $search_xaxis, &$arrayofxaxis, $showempty = '1', $morecss = 'minwidth250 maxwidth500') { global $form; @@ -1523,7 +1524,7 @@ class FormOther foreach ($arrayofxaxis as $key => $val) { $arrayofxaxislabel[$key] = $val['label']; } - $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', 'minwidth250 maxwidth500', 1); + $result = $form->selectarray('search_xaxis', $arrayofxaxislabel, $search_xaxis, $showempty, 0, 0, '', 0, 0, 0, '', $morecss, 1); return $result; } diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 1cfddb588fd..2dd729df91d 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -952,21 +952,11 @@ class FormSetupItem if (!empty($conf->use_javascript_ajax)) { $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); } - if (!empty($conf->use_javascript_ajax)) { - $out .= "\n" . ''; - } + + // Add button to autosuggest a key + include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $out .= dolJSToSetRandomPassword($this->confKey, 'generate_token'.$this->confKey); + return $out; } diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 083e571cf35..c6a6826251f 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -165,9 +165,10 @@ class FormWebsite * @param int $useempty 1=Add an empty value in list * @param string $moreattrib More attributes on HTML select tag * @param int $addjscombo Add js combo + * @param string $morecss More css * @return string HTML select component with list of type of containers */ - public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '', $addjscombo = 0) + public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '', $addjscombo = 0, $morecss = 'minwidth200') { global $langs, $conf, $user; @@ -190,7 +191,7 @@ class FormWebsite } $out = ''; - $out .= ''; if ($useempty == 1 || $useempty == 2) { $out .= ''; diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 6b45cd08f98..caeece975f2 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -181,21 +181,21 @@ class Menubase if (!isset($this->enabled)) { $this->enabled = '1'; } - $this->menu_handler = trim($this->menu_handler); - $this->module = trim($this->module); - $this->type = trim($this->type); - $this->mainmenu = trim($this->mainmenu); - $this->leftmenu = trim($this->leftmenu); + $this->menu_handler = trim((string) $this->menu_handler); + $this->module = trim((string) $this->module); + $this->type = trim((string) $this->type); + $this->mainmenu = trim((string) $this->mainmenu); + $this->leftmenu = trim((string) $this->leftmenu); $this->fk_menu = (int) $this->fk_menu; // If -1, fk_mainmenu and fk_leftmenu must be defined - $this->fk_mainmenu = trim($this->fk_mainmenu); - $this->fk_leftmenu = trim($this->fk_leftmenu); + $this->fk_mainmenu = trim((string) $this->fk_mainmenu); + $this->fk_leftmenu = trim((string) $this->fk_leftmenu); $this->position = (int) $this->position; - $this->url = trim($this->url); - $this->target = trim($this->target); - $this->title = trim($this->title); - $this->langs = trim($this->langs); - $this->perms = trim($this->perms); - $this->enabled = trim($this->enabled); + $this->url = trim((string) $this->url); + $this->target = trim((string) $this->target); + $this->title = trim((string) $this->title); + $this->langs = trim((string) $this->langs); + $this->perms = trim((string) $this->perms); + $this->enabled = trim((string) $this->enabled); $this->user = (int) $this->user; if (empty($this->position)) { $this->position = 0; diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 4d62f9139b3..66e9241d9f5 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -51,6 +51,12 @@ class RssParser private $current_namespace; + private $initem; + private $intextinput; + private $incontent; + private $inimage; + private $inchannel; + // For parsing with xmlparser public $stack = array(); // parser stack private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); @@ -254,21 +260,26 @@ class RssParser return -1; } - $xmlparser = xml_parser_create(''); + try { + $xmlparser = xml_parser_create(null); - if (!is_resource($xmlparser) && !is_object($xmlparser)) { - $this->error = "ErrorFailedToCreateParser"; - return -1; + if (!is_resource($xmlparser) && !is_object($xmlparser)) { + $this->error = "ErrorFailedToCreateParser"; + return -1; + } + + xml_set_object($xmlparser, $this); + xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); + xml_set_character_data_handler($xmlparser, 'feed_cdata'); + + $status = xml_parse($xmlparser, $str, false); + + xml_parser_free($xmlparser); + $rss = $this; + //var_dump($status.' '.$rss->_format);exit; + } catch (Exception $e) { + $rss = null; } - - xml_set_object($xmlparser, $this); - xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); - xml_set_character_data_handler($xmlparser, 'feed_cdata'); - - $status = xml_parse($xmlparser, $str); - xml_parser_free($xmlparser); - $rss = $this; - //var_dump($status.' '.$rss->_format);exit; } } @@ -443,7 +454,7 @@ class RssParser // Loop on each category $itemCategory = array(); - if (is_array($item->category)) { + if (!empty($item->category) && is_array($item->category)) { foreach ($item->category as $cat) { $itemCategory[] = (string) $cat; } @@ -514,7 +525,7 @@ class RssParser * @param array $attrs Attributes of tags * @return void */ - public function feed_start_element($p, $element, &$attrs) + public function feed_start_element($p, $element, $attrs) { // phpcs:enable $el = $element = strtolower($element); @@ -681,9 +692,9 @@ class RssParser public function append_content($text) { // phpcs:enable - if ($this->initem) { + if (!empty($this->initem)) { $this->concat($this->current_item[$this->incontent], $text); - } elseif ($this->inchannel) { + } elseif (!empty($this->inchannel)) { $this->concat($this->channel[$this->incontent], $text); } } @@ -700,24 +711,24 @@ class RssParser if (!$el) { return; } - if ($this->current_namespace) { - if ($this->initem) { + if (!empty($this->current_namespace)) { + if (!empty($this->initem)) { $this->concat($this->current_item[$this->current_namespace][$el], $text); - } elseif ($this->inchannel) { + } elseif (!empty($this->inchannel)) { $this->concat($this->channel[$this->current_namespace][$el], $text); - } elseif ($this->intextinput) { + } elseif (!empty($this->intextinput)) { $this->concat($this->textinput[$this->current_namespace][$el], $text); - } elseif ($this->inimage) { + } elseif (!empty($this->inimage)) { $this->concat($this->image[$this->current_namespace][$el], $text); } } else { - if ($this->initem) { + if (!empty($this->initem)) { $this->concat($this->current_item[$el], $text); - } elseif ($this->intextinput) { + } elseif (!empty($this->intextinput)) { $this->concat($this->textinput[$el], $text); - } elseif ($this->inimage) { + } elseif (!empty($this->inimage)) { $this->concat($this->image[$el], $text); - } elseif ($this->inchannel) { + } elseif (!empty($this->inchannel)) { $this->concat($this->channel[$el], $text); } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 94bd36799fc..c11f94fa047 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -904,11 +904,11 @@ class Translate * This function need module "numberwords" to be installed. If not it will return * same number (this module is not provided by default as it use non GPL source code). * - * @param int $number Number to encode in full text - * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) - * @return string Label translated in UTF8 (but without entities) - * 10 if setDefaultLang was en_US => ten - * 123 if setDefaultLang was fr_FR => cent vingt trois + * @param int|string $number Number to encode in full text + * @param string $isamount ''=it's just a number, '1'=It's an amount (default currency), 'currencycode'=It's an amount (foreign currency) + * @return string Label translated in UTF8 (but without entities) + * 10 if setDefaultLang was en_US => ten + * 123 if setDefaultLang was fr_FR => cent vingt trois */ public function getLabelFromNumber($number, $isamount = '') { diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index c55d78b0caf..9a330c7aba5 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -952,7 +952,7 @@ class Utils dol_include_once('/core/lib/files.lib.php'); - $nbSaves = empty($conf->global->SYSLOG_FILE_SAVES) ? 10 : intval($conf->global->SYSLOG_FILE_SAVES); + $nbSaves = intval(getDolGlobalString('SYSLOG_FILE_SAVES', 10)); if (empty($conf->global->SYSLOG_FILE)) { $mainlogdir = DOL_DATA_ROOT; diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index d513262b871..dbe505a894b 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -195,14 +195,14 @@ class vCard // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; if ($type != "") { - $key .= ";$type"; + $key .= ";".$type; } $key .= ";CHARSET=".$this->encoding; $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); - if ($this->properties["LABEL;$type;CHARSET=".$this->encoding] == "") { + //if ($this->properties["LABEL;".$type.";CHARSET=".$this->encoding] == '') { //$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type); - } + //} } /** diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 46b885bd60a..c1222a6b762 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -217,7 +217,7 @@ foreach ($arrayoftype as $key => $val) { if (dol_eval($val['enabled'], 1, 1, '1')) { $newarrayoftype[$key] = $arrayoftype[$key]; } - if ($val['langs']) { + if (!empty($val['langs'])) { $langs->load($val['langs']); } } @@ -450,7 +450,7 @@ $simplearrayofmesures = array(); foreach ($arrayofmesures as $key => $val) { $simplearrayofmesures[$key] = $arrayofmesures[$key]['label']; } -print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth400', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields +print $form->multiselectarray('search_measures', $simplearrayofmesures, $search_measures, 0, 0, 'minwidth300', 1, 0, '', '', $langs->trans("Measures")); // Fill the array $arrayofmeasures with possible fields print '
'; // XAxis @@ -458,7 +458,7 @@ $count = 0; print '
'; print '
'; //var_dump($arrayofxaxis); -print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis")); // Fill the array $arrayofxaxis with possible fields +print $formother->selectXAxisField($object, $search_xaxis, $arrayofxaxis, $langs->trans("XAxis"), 'minwidth300 maxwidth400'); // Fill the array $arrayofxaxis with possible fields print '
'; // Group by @@ -970,31 +970,31 @@ function fillArrayOfMeasures($object, $tablealias, $labelofobject, &$arrayofmesu // Add main fields of object foreach ($object->fields as $key => $val) { if (!empty($val['isameasure']) && (!isset($val['enabled']) || dol_eval($val['enabled'], 1, 1, '1'))) { - $position = (!empty($val['position']) ? $val['position'] : 0); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofmesures[$tablealias.'.'.$key.'-sum'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Sum").')', - 'position' => ($position+($count * 100000)).'.1', + 'position' => ($position + ($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-average'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Average").')', - 'position' => ($position+($count * 100000)).'.2', + 'position' => ($position + ($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-min'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Minimum").')', - 'position' => ($position+($count * 100000)).'.3', + 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element ); $arrayofmesures[$tablealias.'.'.$key.'-max'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$langs->trans("Maximum").')', - 'position' => ($position+($count * 100000)).'.4', + 'position' => ($position + ($count * 100000)).'.4', 'table' => $object->table_element ); } } // Add extrafields to Measures - if ($object->isextrafieldmanaged) { + if (!empty($object->isextrafieldmanaged)) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['totalizable'][$key]) && (!isset($extrafields->attributes[$object->table_element]['enabled'][$key]) || dol_eval($extrafields->attributes[$object->table_element]['enabled'][$key], 1, 1, '1'))) { $position = (!empty($val['position']) ? $val['position'] : 0); @@ -1098,26 +1098,27 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $position = (!empty($val['position']) ? $val['position'] : 0); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofxaxis[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', - 'position' => ($position+($count * 100000)).'.1', + 'position' => ($position + ($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofxaxis[$tablealias.'.'.$key.'-month'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', - 'position' => ($position+($count * 100000)).'.2', + 'position' => ($position + ($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofxaxis[$tablealias.'.'.$key.'-day'] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', - 'position' => ($position+($count * 100000)).'.3', + 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element ); } else { + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofxaxis[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), - 'position' => ($position+($count * 100000)), + 'position' => ($position + ($count * 100000)), 'table' => $object->table_element ); } @@ -1125,7 +1126,7 @@ function fillArrayOfXAxis($object, $tablealias, $labelofobject, &$arrayofxaxis, } // Add extrafields to X-Axis - if ($object->isextrafieldmanaged) { + if (!empty($object->isextrafieldmanaged)) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { continue; @@ -1196,7 +1197,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup // Add main fields of object foreach ($object->fields as $key => $val) { - if (!$val['isameasure']) { + if (empty($val['isameasure'])) { if (in_array($key, array( 'id', 'ref_int', 'ref_ext', 'rowid', 'entity', 'last_main_doc', 'logo', 'logo_squarred', 'extraparams', 'parent', 'photo', 'socialnetworks', 'webservices_url', 'webservices_key'))) { @@ -1218,26 +1219,27 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup continue; } if (in_array($val['type'], array('timestamp', 'date', 'datetime'))) { - $position = (!empty($val['position']) ? $val['position'] : 0); + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofgroupby[$tablealias.'.'.$key.'-year'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($position+($count * 100000)).'.1', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.')', 'position' => ($position + ($count * 100000)).'.1', 'table' => $object->table_element ); $arrayofgroupby[$tablealias.'.'.$key.'-month'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($position+($count * 100000)).'.2', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.')', 'position' => ($position + ($count * 100000)).'.2', 'table' => $object->table_element ); $arrayofgroupby[$tablealias.'.'.$key.'-day'] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($position+($count * 100000)).'.3', + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']).' ('.$YYYY.'-'.$MM.'-'.$DD.')', 'position' => ($position + ($count * 100000)).'.3', 'table' => $object->table_element ); } else { + $position = (empty($val['position']) ? 0 : intVal($val['position'])); $arrayofgroupby[$tablealias.'.'.$key] = array( 'label' => img_picto('', $object->picto, - 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position+($count * 100000)), + 'class="pictofixedwidth"').' '.$labelofobject.': '.$langs->trans($val['label']), 'position' => ($position + ($count * 100000)), 'table' => $object->table_element ); } @@ -1245,7 +1247,7 @@ function fillArrayOfGroupBy($object, $tablealias, $labelofobject, &$arrayofgroup } // Add extrafields to Group by - if ($object->isextrafieldmanaged) { + if (! empty($object->isextrafieldmanaged)) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { continue; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 5847d88f026..9b1d78f1694 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -471,7 +471,7 @@ class DoliDBMysqli extends DoliDB */ public function escape($stringtoencode) { - return $this->db->real_escape_string($stringtoencode); + return $this->db->real_escape_string((string) $stringtoencode); } /** @@ -482,7 +482,7 @@ class DoliDBMysqli extends DoliDB */ public function escapeunderscore($stringtoencode) { - return str_replace('_', '\_', $stringtoencode); + return str_replace('_', '\_', (string) $stringtoencode); } /** diff --git a/htdocs/core/get_menudiv.php b/htdocs/core/get_menudiv.php index 597031945f1..c4be69675bb 100644 --- a/htdocs/core/get_menudiv.php +++ b/htdocs/core/get_menudiv.php @@ -121,10 +121,19 @@ print ' display: none; } + ul li.lilevel2 { + padding-left: 42px; + } + a.alilevel0, span.spanlilevel0 { background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/next.png\') !important; - background-repeat: no-repeat !important; - background-position-x: 10px; + background-repeat: no-repeat !important;'; +if ($langs->trans("DIRECTION") == 'rtl') { + print 'background-position: right;'; +} else { + print 'background-position-x: 10px;'; +} + print ' background-position-y: 16px; padding: 1em 15px 1em 40px; display: block; @@ -152,6 +161,18 @@ print ' li.lilevel1 a { padding-bottom: 5px; } + li.lilevel1 > a, li.lilevel1 > i { + /* background-image: url(\''.DOL_URL_ROOT.'/theme/'.urlencode($conf->theme).'/img/puce.png\') !important; */ + background-repeat: no-repeat !important;'; +if ($langs->trans("DIRECTION") == 'rtl') { + print 'background-position: right;'; +} else { + print 'background-position-x: 10px;'; +} + print 'background-position-y: 1px;'; + print 'padding-left: 20px;'; + print ' + } li.lilevel1 a, li.lilevel1 { color: #000; cursor: pointer; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 9167e08e599..3310554e530 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -231,33 +231,41 @@ print ' ); jQuery(\'.clipboardCPValue, .clipboardCPButton, .clipboardCPValueToPrint\').click(function() { - /* console.log(this.parentNode); */ console.log("We click on a clipboardCPButton or clipboardCPValueToPrint class and we want to copy content of clipboardCPValue class"); if (window.getSelection) { - range = document.createRange(); - - /* We select value to print using the parent. */ - /* We should use the class clipboardCPValue but it may have several element with copy/paste so class to select is not enough */ - range.selectNodeContents(this.parentNode.firstChild); + jqobj=$(this).parent().children(".clipboardCPValue"); + console.log(jqobj.html()); selection = window.getSelection(); /* get the object used for selection */ selection.removeAllRanges(); /* clear current selection */ + + /* We select the value to print using the parentNode.firstChild */ + /* We should use the class clipboardCPValue but it may have several element with copy/paste so class to select is not enough */ + range = document.createRange(); + range.selectNodeContents(this.parentNode.firstChild); selection.addRange(range); /* make the new selection with the value to copy */ + + /* copy selection into clipboard */ + var succeed; + try { + console.log("We set the style display to unset for the span so the copy will work"); + jqobj.css("display", "unset"); /* Because copy does not work on "block" object */ + + succeed = document.execCommand(\'copy\'); + + console.log("We set the style display back to inline-block"); + jqobj.css("display", "inline-block"); + } catch(e) { + succeed = false; + } + + /* Remove the selection to avoid to see the hidden field to copy selected */ + window.getSelection().removeAllRanges(); } - /* copy selection into clipboard */ - var succeed; - try { - succeed = document.execCommand(\'copy\'); - } catch(e) { - succeed = false; - } - - /* Remove the selection to avoid to see the hidden field to copy selected */ - window.getSelection().removeAllRanges(); - /* Show message */ + /* TODO Show message into a top left corner or center of screen */ var lastchild = this.parentNode.lastChild; /* .parentNode is clipboardCP and last child is clipboardCPText */ var tmp = lastchild.innerHTML if (succeed) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index cc99471a69f..908dacb870c 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -777,7 +777,7 @@ function isInEEC($object) */ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatelink = 0, $morehtmlright = '') { - global $user; + global $user, $action, $hookmanager; $i = -1; @@ -791,8 +791,9 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print "\n"; print load_fiche_titre($langs->trans("ProjectsDedicatedToThisThirdParty"), $newcardbutton.$morehtmlright, ''); - print '
'; - print "\n".''; + + print '
'."\n"; + print '
'; $sql = "SELECT p.rowid as id, p.entity, p.title, p.ref, p.public, p.dateo as do, p.datee as de, p.fk_statut as status, p.fk_opp_status, p.opp_amount, p.opp_percent, p.tms as date_update, p.budget_amount"; $sql .= ", cls.code as opp_status_code"; @@ -835,12 +836,12 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel print ''; // Ref - print ''; // Label - print ''; + print ''; // Date start print ''; // Date end @@ -877,6 +878,11 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel } else { dol_print_error($db); } + + $parameters = array('sql'=>$sql, 'function'=>'show_projects'); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print "
'; + print ''; print $projecttmp->getNomUrl(1); print ''.$obj->title.''.dol_escape_htmltag($obj->title).''.dol_print_date($db->jdate($obj->do), "day").'
"; print '
'; @@ -890,14 +896,15 @@ function show_projects($conf, $langs, $db, $object, $backtopage = '', $nocreatel /** * Show html area for list of contacts * - * @param Conf $conf Object conf - * @param Translate $langs Object langs - * @param DoliDB $db Database handler - * @param Societe $object Third party object - * @param string $backtopage Url to go once contact is created + * @param Conf $conf Object conf + * @param Translate $langs Object langs + * @param DoliDB $db Database handler + * @param Societe $object Third party object + * @param string $backtopage Url to go once contact is created + * @param int $showuserlogin 1=Show also user login if it exists * @return int */ -function show_contacts($conf, $langs, $db, $object, $backtopage = '') +function show_contacts($conf, $langs, $db, $object, $backtopage = '', $showuserlogin = 0) { global $user, $conf, $extrafields, $hookmanager; global $contextpage; @@ -1131,13 +1138,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') if (in_array($key, array('statut'))) { print $form->selectarray('search_status', array('-1'=>'', '0'=>$contactstatic->LibStatut(0, 1), '1'=>$contactstatic->LibStatut(1, 1)), $search_status); } elseif (in_array($key, array('role'))) { - print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles); + print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles, 'minwidth200 maxwidth300'); } else { print ''; } print ''; } } + if ($showuserlogin) { + print ''; + } // Extra fields $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -1177,6 +1187,9 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print getTitleFieldOfList($arrayfields['sc.'.$key]['label'], 0, $_SERVER['PHP_SELF'], '', '', $param, ($align ? 'class="'.$align.'"' : ''), $sortfield, $sortorder, $align.' ')."\n"; } } + if ($showuserlogin) { + print ''.$langs->trans("DolibarrLogin").''; + } // Extra fields $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -1275,6 +1288,16 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '') print ''.$contactstatic->getLibStatut(5).''; } + if ($showuserlogin) { + print ''; + $tmpuser= new User($db); + $resfetch = $tmpuser->fetch(0, '', '', 0, -1, '', $contactstatic->id); + if ($resfetch > 0) { + print $tmpuser->getNomUrl(1, '', 0, 0, 24, 1); + } + print ''; + } + // Extra fields $extrafieldsobjectkey = $contactstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index b4c728fd611..7078d7488ad 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -100,13 +100,22 @@ function dol_print_cron_urls() print '
'; print $langs->trans("URLToLaunchCronJobs").':
'; $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login; - print img_picto('', 'globe').' '.$url."
\n"; - print ' '.$langs->trans("OrToLaunchASpecificJob").'
'; + print ''; + print '
'.$langs->trans("OrToLaunchASpecificJob").'
'; $url = $urlwithroot.'/public/cron/cron_run_jobs_by_url.php?'.(empty($conf->global->CRON_KEY) ? '' : 'securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; - print img_picto('', 'globe').' '.$url."
\n"; + print ''; print '
'; print '
'; + print ajax_autoselect("publicurlmember"); + print ajax_autoselect("publicurlmemberall"); + $logintouse = 'firstadmin'; if ($user->admin) { $logintouse = $user->login; diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 2fd4ce3799a..59a16164f97 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -222,7 +222,7 @@ function ordersupplier_prepare_head(CommandeFournisseur $object) $h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; - $head[$h][1] .= $langs->trans("Events"); + $head[$h][1] = $langs->trans("Events"); if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { $head[$h][1] .= '/'; $head[$h][1] .= $langs->trans("Agenda"); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 8f08d77c6fb..a8c812993eb 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1718,7 +1718,7 @@ function dolButtonToOpenUrlInDialogPopup($name, $label, $buttonstring, $url, $di //print ''; $out .= ''."\n"; - $out .= ''.$buttonstring.''; + $out .= ''.$buttonstring.''; $out .= ''; $out .= ''; $out .= ''; @@ -2196,7 +2196,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } if ($showbarcode) { - $morehtmlleft .= '
'.$form->showbarcode($object, 100, 'photoref').'
'; + $morehtmlleft .= '
'.$form->showbarcode($object, 100, 'photoref valignmiddle').'
'; } if ($object->element == 'societe') { @@ -3887,15 +3887,18 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ if (strpos($pictowithouttext, 'fontawesome_') !== false || preg_match('/^fa-/', $pictowithouttext)) { // This is a font awesome image 'fonwtawesome_xxx' or 'fa-xxx' + $pictowithouttext = str_replace('fontawesome_', '', $pictowithouttext); $pictowithouttext = str_replace('fa-', '', $pictowithouttext); + $pictowithouttextarray = explode('_', $pictowithouttext); $marginleftonlyshort = 0; if (!empty($pictowithouttextarray[1])) { - $fakey = 'fa-'.$pictowithouttextarray[1]; - $fa = empty($pictowithouttextarray[2]) ? 'fa' : $pictowithouttextarray[2]; - $facolor = empty($pictowithouttextarray[3]) ? '' : $pictowithouttextarray[3]; - $fasize = empty($pictowithouttextarray[4]) ? '' : $pictowithouttextarray[4]; + // Syntax is 'fontawesome_fakey_faprefix_facolor_fasize' or 'fa-fakey_faprefix_facolor_fasize' + $fakey = 'fa-'.$pictowithouttextarray[0]; + $fa = empty($pictowithouttextarray[1]) ? 'fa' : $pictowithouttextarray[1]; + $facolor = empty($pictowithouttextarray[2]) ? '' : $pictowithouttextarray[2]; + $fasize = empty($pictowithouttextarray[3]) ? '' : $pictowithouttextarray[3]; } else { $fakey = 'fa-'.$pictowithouttext; $fa = 'fa'; @@ -3945,7 +3948,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'off', 'on', 'order', 'paiment', 'paragraph', 'play', 'pdf', 'phone', 'phoning', 'phoning_mobile', 'phoning_fax', 'playdisabled', 'previous', 'poll', 'pos', 'printer', 'product', 'propal', 'puce', 'stock', 'resize', 'service', 'stats', 'trip', - 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench', + 'security', 'setup', 'share-alt', 'sign-out', 'split', 'stripe', 'stripe-s', 'switch_off', 'switch_on', 'switch_on_red', 'tools', 'unlink', 'uparrow', 'user', 'user-tie', 'vcard', 'wrench', 'github', 'google', 'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp', 'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top', 'commercial', 'companies', 'generic', 'home', 'hrm', 'members', 'products', 'invoicing', @@ -4998,7 +5001,7 @@ function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = * @param string $field Field to use for new sorting * @param string $begin ("" by defaut) * @param string $moreparam Add more parameters on sort url links ("" by default) - * @param string $moreattrib Options of attribute td ("" by defaut, example: 'align="center"') + * @param string $moreattrib Options of attribute td ("" by defaut) * @param string $sortfield Current field used to sort * @param string $sortorder Current sort order * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag. @@ -5020,7 +5023,7 @@ function print_liste_field_titre($name, $file = "", $field = "", $begin = "", $m * @param string $field Field to use for new sorting. Empty if this field is not sortable. Example "t.abc" or "t.abc,t.def" * @param string $begin ("" by defaut) * @param string $moreparam Add more parameters on sort url links ("" by default) - * @param string $moreattrib Add more attributes on th ("" by defaut, example: 'align="center"'). To add more css class, use param $prefix. + * @param string $moreattrib Add more attributes on th ("" by defaut). To add more css class, use param $prefix. * @param string $sortfield Current field used to sort (Ex: 'd.datep,d.id') * @param string $sortorder Current sort order (Ex: 'asc,desc') * @param string $prefix Prefix for css. Use space after prefix to add your own CSS tag, for example 'mycss '. @@ -6580,10 +6583,10 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart = ' * * @param string $dir Directory to create (Separator must be '/'. Example: '/mydir/mysubdir') * @param string $dataroot Data root directory (To avoid having the data root in the loop. Using this will also lost the warning on first dir PHP has no permission when open_basedir is used) - * @param string|null $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' + * @param string $newmask Mask for new file (Defaults to $conf->global->MAIN_UMASK or 0755 if unavailable). Example: '0444' * @return int < 0 if KO, 0 = already exists, > 0 if OK */ -function dol_mkdir($dir, $dataroot = '', $newmask = null) +function dol_mkdir($dir, $dataroot = '', $newmask = '') { global $conf; @@ -6624,7 +6627,7 @@ function dol_mkdir($dir, $dataroot = '', $newmask = null) dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG); umask(0); - $dirmaskdec = octdec($newmask); + $dirmaskdec = octdec((string) $newmask); if (empty($newmask)) { $dirmaskdec = empty($conf->global->MAIN_UMASK) ? octdec('0755') : octdec($conf->global->MAIN_UMASK); } @@ -7316,6 +7319,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__ID__'] = '__ID__'; $substitutionarray['__REF__'] = '__REF__'; $substitutionarray['__NEWREF__'] = '__NEWREF__'; + $substitutionarray['__LABEL__'] = '__LABEL__'; $substitutionarray['__REF_CLIENT__'] = '__REF_CLIENT__'; $substitutionarray['__REF_SUPPLIER__'] = '__REF_SUPPLIER__'; $substitutionarray['__NOTE_PUBLIC__'] = '__NOTE_PUBLIC__'; @@ -7410,6 +7414,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__ID__'] = $object->id; $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__NEWREF__'] = $object->newref; + $substitutionarray['__LABEL__'] = (isset($object->label) ? $object->label : (isset($object->title) ? $object->title : null)); $substitutionarray['__REF_CLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null)); $substitutionarray['__REF_SUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null); $substitutionarray['__NOTE_PUBLIC__'] = (isset($object->note_public) ? $object->note_public : null); @@ -7458,8 +7463,8 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__MEMBER_PHONEMOBILE__'] = (isset($object->phone_mobile) ? dol_print_phone($object->phone_mobile) : ''); $substitutionarray['__MEMBER_TYPE__'] = (isset($object->type) ? $object->type : ''); $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc'); - $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc'); - $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc'); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = (isset($object->first_subscription_date_start) ? dol_print_date($object->first_subscription_date_start, 'dayrfc') : ''); + $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = (isset($object->first_subscription_date_end) ? dol_print_date($object->first_subscription_date_end, 'dayrfc') : ''); $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc'); $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc'); $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc'); @@ -8212,7 +8217,6 @@ function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $ } } if ($mesgstring) { - $langs->load("errors"); $ret++; $out .= $langs->trans($mesgstring); } @@ -8600,7 +8604,8 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' if ($onlysimplestring == '1') { // We must accept: '1 && getDolGlobalInt("doesnotexist1") && $conf->global->MAIN_FEATURES_LEVEL' // We must accept: '$conf->barcode->enabled && preg_match(\'/^(AAA|BBB)/\',$leftmenu)' - if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/', '/').']/i', $s)) { + // We must accept: '$user->rights->cabinetmed->read && $object->canvas=="patient@cabinetmed"' + if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/@', '/').']/i', $s)) { if ($returnvalue) { return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s; } else { @@ -8612,7 +8617,7 @@ function dol_eval($s, $returnvalue = 0, $hideerrors = 1, $onlysimplestring = '1' } } elseif ($onlysimplestring == '2') { // We must accept: (($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found" - if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/;[]', '/').']/i', $s)) { + if (preg_match('/[^a-z0-9\s'.preg_quote('^$_+-.*>&|=!?():"\',/@;[]', '/').']/i', $s)) { if ($returnvalue) { return 'Bad string syntax to evaluate (found chars that are not chars for simplestring): '.$s; } else { @@ -10410,6 +10415,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st * 'cancel-btn-label' => '', // Overide label of cancel button, if empty default label use "CloseDialog" lang key * 'content' => '', // Overide text of content, if empty default content use "ConfirmBtnCommonContent" lang key * 'modal' => true, // true|false to display dialog as a modal (with dark background) + * 'isDropDrown' => false, // true|false to display dialog as a dropdown (with dark background) * ], * ] * // phpcs:enable @@ -10419,12 +10425,16 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = { global $hookmanager, $action, $object, $langs; - $class = 'butAction'; - if ($actionType == 'danger' || $actionType == 'delete') { - $class = 'butActionDelete'; - if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); + //var_dump($params); + if ($params['isDropdown']) + $class = "dropdown-item"; + else { + $class = 'butAction'; + if ($actionType == 'danger' || $actionType == 'delete') { + $class = 'butActionDelete'; + if (!empty($url) && strpos($url, 'token=') === false) $url .= '&token='.newToken(); + } } - $attr = array( 'class' => $class, 'href' => empty($url) ? '' : $url, @@ -11044,12 +11054,12 @@ function readfileLowMemory($fullpath_original_file_osencoded, $method = -1) } /** - * Create a button to copy $valuetocopy in the clipboard. - * Code that handle the click is inside lib_foot.jsp.php. + * Create a button to copy $valuetocopy in the clipboard (for copy and paste feature). + * Code that handle the click is inside core/js/lib_foot.js.php. * * @param string $valuetocopy The value to print * @param int $showonlyonhover Show the copy-paste button only on hover - * @param string $texttoshow Replace the value to show with this text + * @param string $texttoshow Replace the value to show with this text. Use 'none' to show no text (only the copy-paste picto) * @return string The string to print for the button */ function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $texttoshow = '') @@ -11061,8 +11071,10 @@ function showValueWithClipboardCPButton($valuetocopy, $showonlyonhover = 1, $tex $showonlyonhover = 0; }*/ - $tag = 'span'; // Using div does not work when using the js copy code. - if ($texttoshow) { + $tag = 'span'; // Using div (like any style of type 'block') does not work when using the js copy code. + if ($texttoshow === 'none') { + $result = '<'.$tag.' class="clipboardCPValue hidewithsize">'.dol_escape_htmltag($valuetocopy, 1, 1).''; + } elseif ($texttoshow) { $result = '<'.$tag.' class="clipboardCPValue hidewithsize">'.dol_escape_htmltag($valuetocopy, 1, 1).''.dol_escape_htmltag($texttoshow, 1, 1).''; } else { $result = '<'.$tag.' class="clipboardCPValue">'.dol_escape_htmltag($valuetocopy, 1, 1).''; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index a775569407a..9e17d925dbe 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -30,7 +30,7 @@ * @param string $objectname Name of object * @param string $newmask New mask * @param string $readdir Directory source (use $destdir when not defined) - * @param string $addfieldentry Array of the field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') + * @param string $addfieldentry Array of 1 field entry to add array('key'=>,'type'=>,''label'=>,'visible'=>,'enabled'=>,'position'=>,'notnull'=>','index'=>,'searchall'=>,'comment'=>,'help'=>,'isameasure') * @param string $delfieldentry Id of field to remove * @return int|object <=0 if KO, Object if OK * @see rebuildObjectSql() @@ -40,7 +40,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = global $db, $langs; if (empty($objectname)) { - return -1; + return -6; } if (empty($readdir)) { $readdir = $destdir; @@ -48,9 +48,11 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.'); - return -1; + return -7; } + $error = 0; + // Check parameters if (is_array($addfieldentry) && count($addfieldentry) > 0) { if (empty($addfieldentry['name'])) { @@ -62,8 +64,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = return -2; } if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type']) - && !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type'])) { - setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors'); + && !preg_match('/^(boolean|smallint|real|date|datetime|timestamp|phone|mail|url|ip|password)$/', $addfieldentry['type'])) { + setEventMessages($langs->trans('BadValueForType', $addfieldentry['type']), null, 'errors'); return -2; } } @@ -217,10 +219,14 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = dol_mkdir(dirname($pathoffiletoedittarget)); //file_put_contents($pathoffiletoedittmp, $contentclass); - file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); - @chmod($pathoffiletoedittarget, octdec($newmask)); + $result = file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass); + if ($result) { + @chmod($pathoffiletoedittarget, octdec($newmask)); + } else { + $error++; + } - return $object; + return $error ? -1 : $object; } catch (Exception $e) { print $e->getMessage(); return -5; @@ -257,13 +263,33 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' // Edit .sql file if ($moduletype == 'internal') { - $pathoffiletoeditsrc = $readdir.'/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'; - $pathoffiletoedittarget = $destdir.'/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : ''); + $pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'-'.strtolower($module).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'-'.strtolower($module).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/../install/mysql/tables/llx_'.strtolower($module).'.sql'; + } + } + } } else { - $pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'; - $pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : ''); + $pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'-'.strtolower($module).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'-'.strtolower($module).'.sql'; + if (! dol_is_file($readdir.$pathoffiletoeditsrc)) { + $pathoffiletoeditsrc = '/sql/llx_'.strtolower($module).'.sql'; + } + } + } } + // Complete path to be full path + $pathoffiletoedittarget = $destdir.$pathoffiletoeditsrc.($readdir != $destdir ? '.new' : ''); + $pathoffiletoeditsrc = $readdir.$pathoffiletoeditsrc; + if (!dol_is_file($pathoffiletoeditsrc)) { $langs->load("errors"); setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors'); @@ -340,16 +366,13 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' @chmod($pathoffiletoedittarget, octdec($newmask)); } else { $error++; + setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); } // Edit .key.sql file - if ($moduletype == 'internal') { - $pathoffiletoeditsrc = $readdir.'/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'; - $pathoffiletoedittarget = $destdir.'/../install/mysql/tables/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : ''); - } else { - $pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'; - $pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : ''); - } + $pathoffiletoeditsrc = preg_replace('/\.sql$/', '.key.sql', $pathoffiletoeditsrc); + $pathoffiletoedittarget = preg_replace('/\.sql$/', '.key.sql', $pathoffiletoedittarget); + $pathoffiletoedittarget = preg_replace('/\.sql.new$/', '.key.sql.new', $pathoffiletoedittarget); $contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r'); @@ -378,10 +401,11 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = ' dol_mkdir(dirname($pathoffiletoedittarget)); $result2 = file_put_contents($pathoffiletoedittarget, $contentsql); - if ($result) { + if ($result2) { @chmod($pathoffiletoedittarget, octdec($newmask)); } else { $error++; + setEventMessages($langs->trans("ErrorFailToCreateFile", $pathoffiletoedittarget), null, 'errors'); } return $error ? -1 : 1; diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php index 8860f4126c4..bde894940de 100644 --- a/htdocs/core/lib/order.lib.php +++ b/htdocs/core/lib/order.lib.php @@ -60,8 +60,8 @@ function commande_prepare_head(Commande $object) $h++; } - if ((isModEnabled('expedition_bon') && $user->rights->expedition->lire) - || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) { + if ((isModEnabled('expedition_bon') && $user->hasRight('expedition', 'lire')) + || ($conf->delivery_note->enabled && $user->hasRight('expedition', 'delivery', 'lire'))) { $nbShipments = $object->getNbOfShipments(); $nbReceiption = 0; $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 273922ff615..776d0f0776f 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -824,10 +824,13 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } + // Budget task if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) { print ''; - print price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency); - $total_budget_amount += $lines[$i]->budget_amount; + if ($lines[$i]->budget_amount) { + print ''.price($lines[$i]->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; + $total_budget_amount += $lines[$i]->budget_amount; + } print ''; } @@ -982,7 +985,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } - // resume + // Progress if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_summary']['checked'])) { print ''; if ($total_projectlinesa_planned) { @@ -1008,9 +1011,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t } } + // Budget task if (count($arrayfields) > 0 && !empty($arrayfields['t.budget_amount']['checked'])) { print ''; - print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + if (strcmp($total_budget_amount, '')) { + print price($total_budget_amount, 0, $langs, 1, 0, 0, $conf->currency); + } print ''; } diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 4b70419630f..8f4abca6167 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -449,7 +449,7 @@ function encodedecode_dbpassconf($level = 0) * @param array $replaceambiguouschars Discard ambigous characters. For example array('I'). * @param int $length Length of random string (Used only if $generic is true) * @return string New value for password - * @see dol_hash() + * @see dol_hash(), dolJSToSetRandomPassword() */ function getRandomPassword($generic = false, $replaceambiguouschars = null, $length = 32) { @@ -527,3 +527,34 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len return $generated_password; } + +/** + * Ouput javacript to autoset a generated password using default module into a HTML element. + * + * @param string $htmlname HTML name of element to insert key into + * @param string $htmlnameofbutton HTML name of button + * @return string HTML javascript code to set a password + * @see getRandomPassword() + */ +function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token') +{ + global $conf; + + if (!empty($conf->use_javascript_ajax)) { + print "\n".''; + } +} diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index adc4f8d487c..71f399497c7 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2022 Laurent Destailleur * Copyright (C) 2010-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -72,6 +72,7 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout $num = count($newTabMenu); for ($i = 0; $i < $num; $i++) { + //var_dump($type_user.' '.$newTabMenu[$i]['url'].' '.$showmode.' '.$newTabMenu[$i]['perms']); $idsel = (empty($newTabMenu[$i]['mainmenu']) ? 'none' : $newTabMenu[$i]['mainmenu']); $shorturl = ''; @@ -80,9 +81,9 @@ function print_auguria_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout if ($showmode == 1) { $newTabMenu[$i]['url'] = make_substitutions($newTabMenu[$i]['url'], $substitarray); + // url = url from host, shorturl = relative path into dolibarr sources $url = $shorturl = $newTabMenu[$i]['url']; - - if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { + if (!preg_match("/^(http:\/\/|https:\/\/)/i", $newTabMenu[$i]['url'])) { // Do not change url content for external links $tmp = explode('?', $newTabMenu[$i]['url'], 2); $url = $shorturl = $tmp[0]; $param = (isset($tmp[1]) ? $tmp[1] : ''); @@ -235,11 +236,11 @@ function print_text_menu_entry_auguria($text, $showmode, $url, $id, $idsel, $cla $classnametxt = str_replace('class="', 'class="tmenulabel ', $classname); if ($showmode == 1) { - print ''; - print '
'; + print '
'; + print '
'; print '
'; if (empty($conf->global->THEME_TOPMENU_DISABLE_TEXT)) { - print ''; + print ''; print ''; print $text; print ''; @@ -300,11 +301,13 @@ function print_end_menu_array_auguria() * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all). If value come being '', we change it to value in session and 'none' if not defined in session. * @param array $moredata An array with more data to output + * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @return int Nb of menu entries */ -function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null) +function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null, $type_user = 0) { - global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc; + global $user, $conf, $langs, $hookmanager; + global $dolibarr_main_db_name, $mysoc; $newmenu = $menu; @@ -472,6 +475,29 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t return 0; } + // Allow the $menu_array of the menu to be manipulated by modules + $parameters = array( + 'mainmenu' => $mainmenu, + ); + $hook_items = $menu_array; + $reshook = $hookmanager->executeHooks('menuLeftMenuItems', $parameters, $hook_items); // Note that $action and $object may have been modified by some hooks + + if (is_numeric($reshook)) { + if ($reshook == 0 && !empty($hookmanager->results)) { + $menu_array[] = $hookmanager->results; // add + } elseif ($reshook == 1) { + $menu_array = $hookmanager->results; // replace + } + + // @todo Sort menu items by 'position' value + // $position = array(); + // foreach ($menu_array as $key => $row) { + // $position[$key] = $row['position']; + // } + // $array1_sort_order = SORT_ASC; + // array_multisort($position, $array1_sort_order, $menu_array); + } + // Show menu $invert = empty($conf->global->MAIN_MENU_INVERT) ? "" : "invert"; if (empty($noout)) { @@ -542,7 +568,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t if ($menu_array[$i]['enabled']) { // Enabled so visible print ''."\n"; $lastlevel0 = 'enabled'; } elseif ($showmenu) { // Not enabled but visible (so greyed) - print ''."\n"; + print ''."\n"; $lastlevel0 = 'greyed'; } else { $lastlevel0 = 'hidden'; @@ -572,10 +602,12 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $cssmenu = ' menu_contenu'.dol_string_nospecial(preg_replace('/\.php.*$/', '', $menu_array[$i]['url'])); } - if ($menu_array[$i]['enabled'] && $lastlevel0 == 'enabled') { // Enabled so visible, except if parent was not enabled. - print '