diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 19c076242f8..5e56ac2a1fc 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -101,28 +101,30 @@ Long description (Can span accross multiple lines). ### Pull Requests -When submitting a pull request, use same rule as [Commits](#commits) for the message. +Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and +a process to follow to optimize the chance to have PRs merged efficiently... -If your pull request only contains one commit, GitHub will be smart enough to fill it for you. +When submitting a pull request, use same rule as [Commits](#commits) for the message. +If your pull request only contains 1 commit, GitHub will be smart enough to fill it for you. Otherwise, please be a bit verbose about what you're providing. -Your Pull Request (PR) must pass the Continuous Integration checks. +Your Pull Request (PR) must pass the Continuous Integration checks and code quality checks. Also, some code changes need a prior approbation: * if you want to include a new external library (into htdocs/includes directory), please ask before to the project manager (@eldy) to see if such a library can be accepted. -* if you add a new table, you must first create a page on http://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Than ask the project manager (@eldy) if the new data model you plan to add can be accepted as you suggest. +* if you add a new table, you must first create a page on https://wiki.dolibarr.org/index.php/Category:Table_SQL (copy an existing page changing its name to see it into this index page). Then ask the project manager (@eldy) if the new data model you plan to add is compatible with curent and future works in progress and can be accepted as you suggest. -Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR. +Once a PR has been submitted, you may need to wait for its integration. It is common that the project leader let the PR open for a long delay to allow every developer discuss about the PR (A label is added in such a case). If the label of PR start with "WIP" (Work In Progress), it will not be analyzed (until you change the label of PR). If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration. If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet. -In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the flag ask you. The majority of PR are waiting an action of the developer/author. +In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR. -Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. This is one of the most important ratio of answered PR in Open Source world. Don't expect the core team to reach the 100%. With the increasing popularity of Dolibarr, this ratio will probably decrease in future. +Statistics on Dolibarr project shows that around 95% of submitted PR are reviewed and tagged. Average answer delay is also one of the best among Open source project (just few days before having the Answer Tag set). This is one of the most important ratio of answered PR in Open Source world for a major project. Don't expect the core team to reach the 100%. A so high ratio is very rare on a so popular project and with the increasing popularity of Dolibarr, this ratio will probably decrease in future to a more common level. ### Resources diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml new file mode 100644 index 00000000000..ed37c9aadc2 --- /dev/null +++ b/.github/workflows/stale-issues-safe.yml @@ -0,0 +1,24 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: "Close stale issues (bugs and feature requests)" + +on: + schedule: + - cron: "0 21 * * *" + issue_comment: + types: [created] + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: Dolibarr/stale@staleunstale + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + stale-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 15 days (you should still be able to re-open it if required).' + stale-label: 'Issue Stale (automatic label)' + exempt-labels: 'Priority High / Blocking,Priority Top Strategic,Priority Medium,Hacktoberfest,good first issue,Bug Security (CVE),Analysis of PR in progres' + days-before-stale: 365 + days-before-close: 15 + operations-per-run: 100 + dry-run: false + \ No newline at end of file diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml.disabled similarity index 74% rename from .github/workflows/stale-issues.yml rename to .github/workflows/stale-issues.yml.disabled index b50af3ec717..6e7dad5dc9b 100644 --- a/.github/workflows/stale-issues.yml +++ b/.github/workflows/stale-issues.yml.disabled @@ -3,21 +3,23 @@ name: "Close stale issues (bugs and feature requests)" on: schedule: - - cron: "0 0 * * *" + - cron: "0 20 * * *" jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v1 + - uses: Dolibarr/stale@master with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.' + stale-issue-message: 'This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. This issue may be closed automatically by stale bot in 15 days (you should still be able to re-open it if required).' stale-issue-label: 'Issue Stale (automatic label)' exempt-issue-label: 'Priority High / Blocking' days-before-stale: 365 - days-before-close: 15 + days-before-close: -1 + operations-per-run: 100 #stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.' - #stale-pr-label: 'PR Stale (automatic label)' - #exempt-pr-label: 'Priority Top Strategic' + stale-pr-label: 'PR Stale (automatic label)' + stale-pr-message: + exempt-pr-label: 'Priority Top Strategic' \ No newline at end of file diff --git a/.gitignore b/.gitignore index ffacba65feb..30151359365 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ htdocs/includes/sebastian/ htdocs/includes/squizlabs/ htdocs/includes/symfony/ htdocs/includes/webmozart/ +htdocs/.well-known/apple-developer-merchantid-domain-association diff --git a/.travis.yml b/.travis.yml index dd3322e5cf7..688d706331d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ # We use dist: xenial to have php 5.6+ available +os: linux dist: xenial sudo: required @@ -43,7 +44,7 @@ env: global: # Set to true for very verbose output - DEBUG=false - matrix: + jobs: # MariaDB overrides MySQL installation so it's not possible to test both yet #- DB=mariadb - DB=mysql @@ -53,7 +54,7 @@ env: # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test #- WS=nginx -matrix: +jobs: fast_finish: true allow_failures: - php: nightly @@ -281,7 +282,7 @@ script: # Ensure we catch errors set -e #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . + parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/myclabs --exclude htdocs/includes/webmozart --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel/Classes/PHPExcel/Shared --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/composer/autoload_static.php --blame . set +e echo diff --git a/COPYRIGHT b/COPYRIGHT index fe707c1d63d..c1f400aff4e 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -17,7 +17,7 @@ CKEditor 4.12.1 LGPL-2.1+ Yes EvalMath 1.0 BSD Yes Safe math expressions evaluation Escpos-php 2.2 MIT License Yes Thermal receipt printer library, for use with ESC/POS compatible printers GeoIP 1.4 LGPL-2.1+ Yes Sample code to make geoip convert (not into deb package) -Mobiledetect 2.8.33 MIT License Yes Detect mobile devices browsers +Mobiledetect 2.8.34 MIT License Yes Detect mobile devices browsers NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency ParseDown 1.6 MIT License Yes Markdown parser @@ -32,15 +32,16 @@ PSR/simple-cache ? Library for cache (used by PHPSp Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer) Sabre 3.2.2 BSD Yes DAV support Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP -Stripe 6.41 MIT licence Yes Library for Stripe module +Stripe 6.43.1 MIT licence Yes Library for Stripe module TCPDF 6.3.2 LGPL-3+ Yes PDF generation TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement JS libraries: -Ace 1.4.6 BSD Yes JS library to get code syntaxique coloration in a textarea. +Ace 1.4.8 BSD Yes JS library to get code syntaxique coloration in a textarea. +Chart 2.9.3 MIT License Yes JS library for graph jQuery 3.4.1 MIT License Yes JS library jQuery UI 1.12.1 GPL and MIT License Yes JS library plugin UI -jQuery select2 4.0.5 GPL and Apache License Yes JS library plugin for sexier multiselect +jQuery select2 4.0.13 GPL and Apache License Yes JS library plugin for sexier multiselect jQuery blockUI 2.70.0 GPL and MIT License Yes JS library plugin blockUI (to use ajax popups) jQuery Colorpicker 1.1 MIT License Yes JS library for color picker for a defined list of colors jQuery Flot 0.8.3 MIT License Yes JS library to build graph diff --git a/ChangeLog b/ChangeLog index f7631b8dc5f..7089658872e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,7 +8,10 @@ For Users: NEW: Module MO (Manufacturing Order) is available as stable module. For Developers or integrators: - +* A new way to navigate between pages in list is available. To use it, you must + - replace $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); + - remove input field in form '';' + - add parameter $pagenavastextinput to value 1 when calling print_barre_liste WARNING: @@ -19,8 +22,105 @@ Following changes may create regressions for some external modules, but were nec with HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing the HTML into content (in such a case, sanitize data later) * Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless. +* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced + by a "_" automatically when a reference (with a custom numbering mask that use it) is generated. + +***** ChangeLog for 11.0.3 compared to 11.0.2 ***** +FIX: unit price for selected supplier products not set. NaN was used. +FIX: use bad var to check if total is positive for each VAT rate when validating an invoice +FIX: status missing from last customer invoices box when using MAIN_STATUS_USES_CSS +FIX: translations for "orders" not loaded in the homepage box +FIX: #13194 +FIX: #13274 cannot add or update 0 value for an int or double extrafield +FIX: #13285 SQL error during migration with pgsql +FIX: #13294 +FIX: #13313 +FIX: Clone Fourn Command, add line's extrafields +FIX: cols parameter not propagated to tpl +FIX: CSRF error when creating an intervention +FIX: date order was -1D and desc with label repetition +FIX: empty of series in graph of product distribution +FIX: fk_type subscription list via api REST +FIX: link when using anchor on "/" in website module +FIX: menu export document was not visible when using "simple accounting" +FIX: missing class declaration +FIX: missing global $conf +FIX: Missing token in some forms (avoid unset POST errors) +FIX: params of setEventMessage($langs->trans('ErrorProductClone')... +FIX: Remove unexisting link +FIX: mass action on stock movements +FIX: substitute lines dates values on doc generator (ODT, ...) +FIX: Ticket - Load Cache Messages Ticket, wrong message's status +FIX: Ticket Public - Private messages are displayed +FIX: wrong include - replace extrafields_create.tpl.php to extrafields_add.tpl.php + +***** ChangeLog for 11.0.2 compared to 11.0.1 ***** +FIX: #10309 +FIX: #13110 +FIX: #13118 +FIX: #13124 +FIX: #13131 +FIX: #13135 +FIX: #13146 +FIX: #13198 +FIX: #13175 +FIX: #13182 +FIX: #13183 +FIX: #13184 +FIX: #13263 +FIX: #13267 +FIX: an external user can not approve +FIX: API Get list of documents for supplier_invoice +FIX: API to push an expense report +FIX: API upload/download doc for expensereport +FIX: Avoid to download the export if we just press enter to refresh form +FIX: Bad link to template invoices +FIX: Bad sort link in accounting report +FIX: Bad translation for productlot EatBy and SellBy +FIX: better method to check user rights AND usergroup rights ! +FIX: CA by product list filter +FIX: CSS +FIX: Disable js if no javascript +FIX: duplicate class name into some log lines +FIX: etrafield with visibilty=5 were not in read only. +FIX: excess paid from situation invoices not counted when calculating remain to pay. +FIX: Force FEC export to txt format. +FIX: Free input for email no more visible. +FIX: Keep assigned users in session when loading projects and tasks +FIX: List of viewed projects too large in task widget. +FIX: Menu truncated. Add tooltip to have all content. +FIX: Missing field "billed" in export. +FIX: missing "statut" for getNomUrl() function +FIX: modFournisseur is required by modSupplierProposal +FIX: Multicompany compatibility +FIX: must be == and not = +FIX: option for topbar search and bookmarks +FIX: option MAIN_OPTIMIZEFORTEXTBROWSER +FIX: some responsive troubles +FIX: round MT in accountancy books +FIX: search with '0' +FIX: sort link +FIX: SQL Overload in default contact trigger. +FIX: SQl syntax error. +FIX: Submit of documents for supplier invoices. +FIX: timezone must be tzserver and not tzuser as on contract card +FIX: token in barcode tools page missing +FIX: Bad name of trigger PROPAL_SUPPLIER_TRIGGER, should be PROPOSAL_SUPPLIER_TRIGGER +FIX: Type of contact for event does not exists and not supported +FIX: Type of contact not saved when creating a contact +FIX: typo on ckeck method +FIX: undefined function measuringUnitString in product list +FIX: Usage of project not available in export. +FIX: wrong test +FIX: z-index for moretabsList with constant MAIN_MAXTABS_IN_CARD +FIX: Use GETPOST instead of POST +FIX: HTML Injection +FIX: Visualization rights correction on last modified contacts box. +FIX: Vulnerability in module from modulebuilder. +FIX: Vulnerability reported by code16 + ***** ChangeLog for 11.0.1 compared to 11.0.0 ***** FIX: advanced target emailing sql and ergonomy. FIX: After import of a website template, home page was not set. diff --git a/README.md b/README.md index b8d067ffb7a..fbf59a27a74 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ Releases can be downloaded from [official website](https://www.dolibarr.org/). You can use a Web server and a supported database (MariaDB, MySQL or PostgreSQL) to install the standard version. +- Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Versions). + - Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommanded if you known git): `git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is main version like 3.6, 9.0, ...) @@ -68,6 +70,7 @@ If you don't have time to install it yourself, you can try some commercial 'read ## UPGRADING - At first make a backup of your Dolibarr files & than see https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr +- Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md). - Overwrite all old files from 'dolibarr' directory with files provided into the new version's package. - At first next access, Dolibarr will redirect your to the "install/" page to follow the upgrade process.  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file into the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*"). diff --git a/build/README b/build/README index 07f0ebe3b55..67ceb05c8d2 100644 --- a/build/README +++ b/build/README @@ -45,9 +45,12 @@ Dolibarr working. It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory. -We can find in "build", following sub-directories: +You can find in "build", following sub-directories: -* debian: +* composer +To test an upgrade of a lib. + +* debian To build Debian package. * dmg: diff --git a/build/exe/doliwamp/Languages/MyEnglish.isl b/build/exe/doliwamp/Languages/MyEnglish.isl index b066a5f87f6..371e724d6d0 100644 --- a/build/exe/doliwamp/Languages/MyEnglish.isl +++ b/build/exe/doliwamp/Languages/MyEnglish.isl @@ -11,11 +11,11 @@ LaunchProgram=Launch %1 AssocFileExtension=&Associate %1 with the %2 file extension AssocingFileExtension=Associating %1 with the %2 file extension... -YouWillInstallDoliWamp=You will install or upgrade DoliWamp (so Dolibarr + all required third party software like Apache, Mysql and PHP) on your computer. +YouWillInstallDoliWamp=You will install DoliWamp (so Dolibarr + all required third party software like Apache, Mysql and PHP) on your computer. ThisAssistantInstallOrUpgrade=WARNING: Using an ERP CRM installed on a local computer can be dangerous: if your computer break down, you can lose all your data. Do this if you are ready to manage backup yourself seriously. If not, use an installation in Saas instead (see https://saas.dolibarr.org). IfYouHaveTechnicalKnowledge=Moreover, if you have technical knowledges and want to manage your Apache, Mysql and PHP yourself, you should not use this assistant and make a manual installation of Dolibarr on your existing server with Apache, Mysql and PHP. ButIfYouLook=But if you look for an automatic setup on your local computer, you''re on the good way... -DoYouWantToStart=Do you want to start installation/upgrade process ? +DoYouWantToStart=Do you want to start installation process ? TechnicalParameters=Technical parameters IfFirstInstall=If first install, please specify some technical parameters. If you don't understand, are not sure, or are doing an upgrade, just leave the default values. diff --git a/build/exe/doliwamp/Languages/MyFrench.isl b/build/exe/doliwamp/Languages/MyFrench.isl index 2e93a44081e..c3fd15cbac8 100644 --- a/build/exe/doliwamp/Languages/MyFrench.isl +++ b/build/exe/doliwamp/Languages/MyFrench.isl @@ -11,11 +11,11 @@ LaunchProgram=Ex AssocFileExtension=&Associer %1 avec l'extension de fichier %2 AssocingFileExtension=Associe %1 avec l'extension de fichier %2... -YouWillInstallDoliWamp=Vous allez installer ou mettre à jour DoliWamp sur votre ordinateur (donc Dolibarr + tous ses composants prérequis comme Apache, Mysql et PHP). +YouWillInstallDoliWamp=Vous allez installer DoliWamp sur votre ordinateur (donc Dolibarr + tous ses composants prérequis comme Apache, Mysql et PHP). ThisAssistantInstallOrUpgrade=AVERTISSEMENT: L'utilisation d'un ERP CRM installé sur un ordinateur local peut être dangereuse: si votre ordinateur tombe en panne, vous pouvez perdre toutes vos données. Faites-le si vous êtes prêt à gérer les sauvegardes vous-même sérieusement. Sinon, utilisez plutôt une installation en Saas (voir https://saas.dolibarr.org). IfYouHaveTechnicalKnowledge=De plus, si vous avez des compétences techniques et envisagez de partager votre Apache, Mysql et PHP avec d''autres applications que Dolibarr, vous ne devriez pas utiliser cet assistant mais faire plutôt une installation manuelle de Dolibarr sur un serveur existant équipé de Apache, Mysql et PHP. ButIfYouLook=Mais si vous recherchez une installation clé en main automatisée sur une poste local, vous êtes sur la bonne voie... -DoYouWantToStart=Voulez-vous démarrer le processus d'installation/mise à jour ? +DoYouWantToStart=Voulez-vous démarrer le processus d'installation ? TechnicalParameters=Paramètres techniques IfFirstInstall=S'il s'agit de la première installation, merci de spécifier ces quelques paramètres techniques. Si vous ne les comprennez pas, êtes non sûr, ou procédez à une mise à jour, laissez les champs avec les valeurs proposées par défaut. diff --git a/build/exe/doliwamp/doliwamp.iss b/build/exe/doliwamp/doliwamp.iss index 994beb95eff..9705cc198da 100644 --- a/build/exe/doliwamp/doliwamp.iss +++ b/build/exe/doliwamp/doliwamp.iss @@ -32,7 +32,7 @@ AppPublisherURL=https://www.nltechno.com AppSupportURL=https://www.dolibarr.org AppUpdatesURL=https://www.dolibarr.org AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql software. -AppCopyright=Copyright (C) 2008-2019 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) +AppCopyright=Copyright (C) 2008-2020 Laurent Destailleur (NLTechno), Fabian Rodriguez (Le Goût du Libre) DefaultDirName=c:\dolibarr DefaultGroupName=Dolibarr ;LicenseFile=COPYING @@ -81,7 +81,7 @@ Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm: Name: "{app}\logs" Name: "{app}\tmp" Name: "{app}\dolibarr_documents" -Name: "{app}\bin\apache\apache2.4.9\logs" +Name: "{app}\bin\apache\apache2.4.41\logs" [Files] ; Stop/start @@ -98,35 +98,48 @@ Source: "build\exe\doliwamp\mysqltestinstall.bat.install"; DestDir: "{app}\"; Fl Source: "build\exe\doliwamp\startdoliwamp_manual_donotuse.bat.install"; DestDir: "{app}\"; Flags: ignoreversion; Source: "build\exe\doliwamp\builddemosslfiles.bat.install"; DestDir: "{app}\"; Flags: ignoreversion; Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversion; + ; PhpMyAdmin, 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.19, 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.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 To test: apache 2.4.41, php 7.3.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) Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange" -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:\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:\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:\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" + ; Mysql data files (does not overwrite if exists) -Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db" +; 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 +;Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mariadb\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db" + ; Dolibarr Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,sabre\sabre\*\tests,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php" Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,initdemo\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,vagrant\*,xdebug\*" Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png" Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php" Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,default.properties,install.lock" + ; Config files Source: "build\exe\doliwamp\phpmyadmin.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion; Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin4.1.14"; 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.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\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.0.45"; Flags: ignoreversion; -Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php5.5.12"; 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\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; Source: "build\exe\doliwamp\ca_demo_dolibarr.crt"; DestDir: "{app}"; Flags: ignoreversion; Source: "build\exe\doliwamp\ca_demo_dolibarr.key"; DestDir: "{app}"; Flags: ignoreversion; + ; Licence Source: "COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion; @@ -227,9 +240,12 @@ procedure InitializeWizard(); begin //version des applis, a modifier pour chaque version de WampServer 2 - apacheVersion := '2.4.9'; - phpVersion := '5.5.12' ; - mysqlVersion := '5.0.45'; + //apacheVersion := '2.4.9'; + //phpVersion := '5.5.12' ; + apacheVersion := '2.4.41'; + phpVersion := '7.3.12' ; + //mysqlVersion := '5.0.45'; + mysqlVersion := '10.4.10'; phpmyadminVersion := '4.1.14'; smtpServer := 'localhost'; @@ -361,18 +377,19 @@ begin winPath := ExpandConstant('{win}'); pathWithSlashes := path; StringChange (pathWithSlashes, '\','/'); - datadir := pathWithSlashes+'/bin/mysql/data'; - exedirold := pathWithSlashes+'/bin/mysql/mysql5.0.45'; - exedirnew := pathWithSlashes+'/bin/mysql/mysql5.0.45'; - + // 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/'; + // 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. // Install of service and stop/start scripts are already rebuild by installer. // FileCopy(exedirold+'/my.ini',exedirnew+'/my.ini', true); -// We should not need this, also databases may not be called dolibarr + // We should not need this, also databases may not be called dolibarr // res := RenameFile(ibdata1dirold+'/dolibarr',ibdata1dirnew+'/dolibarr'); // if res then // begin @@ -392,39 +409,21 @@ begin //---------------------------------------------- // TODO Update this list when changing PHP/Apache versions - phpDllCopy := 'fdftk.dll'; + phpDllCopy := 'libssh2.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'fribidi.dll'; + phpDllCopy := 'icuuc64.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'gds32.dll'; + phpDllCopy := 'icuin64.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libeay32.dll'; + phpDllCopy := 'icuio64.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libmhash.dll'; + phpDllCopy := 'icudt64.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libmysql.dll'; + phpDllCopy := 'libsasl.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libpq.dll'; + phpDllCopy := 'php7apache2_4.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'msql.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libmcrypt.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'libmysqli.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'ntwdblib.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - - phpDllCopy := 'php5activescript.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'php5nsapi.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'php5ts.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - - phpDllCopy := 'ssleay32.dll'; - filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); - phpDllCopy := 'yaz.dll'; + phpDllCopy := 'php7ts.dll'; filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False); @@ -516,6 +515,17 @@ begin then begin + //---------------------------------------------- + // check that we don't try an upgrade (mysql upgrade no supported) + //---------------------------------------------- + + if FileExists (pathWithSlashes+'/bin/mysql/mysql5.0.45'+phpVersion+'/bin/mysqld-nt.exe') then + begin + MsgBox('An existing installation using an old version of Mysql exists. Sorry, upgrade with this installer is not possible.', mbInformation, MB_OK); + Abort(); + end; + + //---------------------------------------------- // Rename file c:/windows/php.ini (we don't want it) //---------------------------------------------- @@ -727,8 +737,8 @@ begin // Create file my.ini (if not exists) //---------------------------------------------- - destFile := pathWithSlashes+'/bin/mysql/mysql'+mysqlVersion+'/my.ini'; - srcFile := pathWithSlashes+'/bin/mysql/mysql'+mysqlVersion+'/my.ini.install'; + destFile := pathWithSlashes+'/bin/mariadb/mariadb'+mysqlVersion+'/my.ini'; + srcFile := pathWithSlashes+'/bin/mariadb/mariadb'+mysqlVersion+'/my.ini.install'; if not FileExists (destFile) then begin @@ -814,6 +824,8 @@ begin StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True); StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True); StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True); + StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True); + StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True); SaveStringToFile(destFile,srcContents, False); end; @@ -956,9 +968,11 @@ begin - // Uninstall and Install services + // Uninstall services batFile := path+'\uninstall_services.bat'; Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult); + + // Install services batFile := path+'\install_services.bat'; Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult); @@ -1057,7 +1071,7 @@ Filename: "{app}\rundoliwamp.bat"; Description: {cm:LaunchNow}; Flags: shellexec [UninstallDelete] Type: files; Name: "{app}\*.*" -Type: files; Name: "{app}\bin\mysql\mysql5.0.45\*.*" +Type: files; Name: "{app}\bin\mariadb\mariadb10.4.10\*.*" Type: filesandordirs; Name: "{app}\alias" Type: filesandordirs; Name: "{app}\apps" Type: filesandordirs; Name: "{app}\bin\apache" diff --git a/build/exe/doliwamp/httpd.conf.install b/build/exe/doliwamp/httpd.conf.install index 40cc9a2f5c6..6a65e0833f9 100644 --- a/build/exe/doliwamp/httpd.conf.install +++ b/build/exe/doliwamp/httpd.conf.install @@ -1,55 +1,74 @@ # # This is the main Apache HTTP server configuration file. It contains the # configuration directives that give the server its instructions. -# See for detailed information. -# In particular, see -# +# See for detailed information. +# In particular, see +# # for a discussion of each configuration directive. # # Do NOT simply read the instructions in here without understanding # what they do. They're here only as hints or reminders. If you are unsure -# consult the online docs. You have been warned. +# consult the online docs. You have been warned. # # Configuration and logfile names: If the filenames you specify for many # of the server's control files begin with "/" (or "drive:/" for Win32), the # server will use that explicit path. If the filenames do *not* begin -# with "/", the value of ServerRoot is prepended -- so "logs/foo.log" -# with ServerRoot set to "C:/Program Files/Apache Software Foundation/Apache2.2" will be interpreted by the -# server as "C:/Program Files/Apache Software Foundation/Apache2.2/logs/foo.log". +# with "/", the value of ServerRoot is prepended -- so "logs/access_log" +# with ServerRoot set to "/usr/local/apache2" will be interpreted by the +# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" +# will be interpreted as '/logs/access_log'. # # NOTE: Where filenames are specified, you must use forward slashes # instead of backslashes (e.g., "c:/apache" instead of "c:\apache"). -# If a drive letter is omitted, the drive on which Apache.exe is located +# If a drive letter is omitted, the drive on which httpd.exe is located # will be used by default. It is recommended that you always supply -# an explicit drive letter in absolute paths, however, to avoid -# confusion. -# - -# ThreadsPerChild: constant number of worker threads in the server process -# MaxRequestsPerChild: maximum number of requests a server process serves -ThreadsPerChild 250 -MaxRequestsPerChild 0 +# an explicit drive letter in absolute paths to avoid confusion. +ServerSignature On +ServerTokens Full # # ServerRoot: The top of the directory tree under which the server's # configuration, error, and log files are kept. # # Do not add a slash at the end of the directory path. If you point -# ServerRoot at a non-local disk, be sure to point the LockFile directive -# at a local disk. If you wish to share the same ServerRoot for multiple -# httpd daemons, you will need to change at least LockFile and PidFile. +# ServerRoot at a non-local disk, be sure to specify a local disk on the +# Mutex directive, if file-based mutexes are used. If you wish to share the +# same ServerRoot for multiple httpd daemons, you will need to change at +# least PidFile. # +# Apache variable names used by Apache conf files: +# The names and contents of variables: +# APACHE24, VERSION_APACHE, INSTALL_DIR, APACHE_DIR, SRVROOT +# should never be changed. +Define APACHE24 Apache2.4 +Define VERSION_APACHE WAMPAPACHEVERSION +Define INSTALL_DIR WAMPROOT +Define APACHE_DIR ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE} +Define SRVROOT ${INSTALL_DIR}/bin/apache/apache${VERSION_APACHE} + ServerRoot "WAMPROOT/bin/apache/apacheWAMPAPACHEVERSION" +# +# Mutex: Allows you to set the mutex mechanism and mutex file directory +# for individual mutexes, or change the global defaults +# +# Uncomment and change the directory if mutexes are file-based and the default +# mutex file directory is not on a local disk or is not appropriate for some +# other reason. +# +# Mutex default:logs + # # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the # directive. # -# Change this to Listen on specific IP addresses as shown below to -# prevent Apache from glomming onto all bound IP addresses (0.0.0.0) +# Change this to Listen on specific IP addresses as shown below to +# prevent Apache from glomming onto all bound IP addresses. # #Listen 12.34.56.78:80 +#Listen 0.0.0.0:80 +#Listen [::0]:80 Listen WAMPAPACHEPORT # @@ -64,40 +83,72 @@ Listen WAMPAPACHEPORT # Example: # LoadModule foo_module modules/mod_foo.so # +LoadModule access_compat_module modules/mod_access_compat.so LoadModule actions_module modules/mod_actions.so LoadModule alias_module modules/mod_alias.so LoadModule allowmethods_module modules/mod_allowmethods.so LoadModule asis_module modules/mod_asis.so LoadModule auth_basic_module modules/mod_auth_basic.so -#LoadModule auth_digest_module modules/mod_auth_digest.so +LoadModule auth_digest_module modules/mod_auth_digest.so +#LoadModule auth_form_module modules/mod_auth_form.so #LoadModule authn_anon_module modules/mod_authn_anon.so +LoadModule authn_core_module modules/mod_authn_core.so +#LoadModule authn_dbd_module modules/mod_authn_dbd.so #LoadModule authn_dbm_module modules/mod_authn_dbm.so LoadModule authn_file_module modules/mod_authn_file.so +#LoadModule authn_socache_module modules/mod_authn_socache.so +#LoadModule authnz_fcgi_module modules/mod_authnz_fcgi.so +#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so LoadModule authz_core_module modules/mod_authz_core.so +#LoadModule authz_dbd_module modules/mod_authz_dbd.so #LoadModule authz_dbm_module modules/mod_authz_dbm.so -#LoadModule authz_default_module modules/mod_authz_default.so LoadModule authz_groupfile_module modules/mod_authz_groupfile.so LoadModule authz_host_module modules/mod_authz_host.so +#LoadModule authz_owner_module modules/mod_authz_owner.so LoadModule authz_user_module modules/mod_authz_user.so LoadModule autoindex_module modules/mod_autoindex.so -LoadModule buffer_module modules/mod_buffer.so +#LoadModule brotli_module modules/mod_brotli.so +#LoadModule buffer_module modules/mod_buffer.so LoadModule cache_module modules/mod_cache.so LoadModule cache_disk_module modules/mod_cache_disk.so +#LoadModule cache_socache_module modules/mod_cache_socache.so #LoadModule cern_meta_module modules/mod_cern_meta.so LoadModule cgi_module modules/mod_cgi.so +#LoadModule charset_lite_module modules/mod_charset_lite.so +#LoadModule data_module modules/mod_data.so #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so +#LoadModule dav_lock_module modules/mod_dav_lock.so +#LoadModule dbd_module modules/mod_dbd.so #LoadModule deflate_module modules/mod_deflate.so LoadModule dir_module modules/mod_dir.so +#LoadModule dumpio_module modules/mod_dumpio.so LoadModule env_module modules/mod_env.so -LoadModule expires_module modules/mod_expires.so -#LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule expires_module modules/mod_expires.so +#LoadModule ext_filter_module modules/mod_ext_filter.so +LoadModule file_cache_module modules/mod_file_cache.so +#LoadModule filter_module modules/mod_filter.so +#LoadModule http2_module modules/mod_http2.so #LoadModule headers_module modules/mod_headers.so -LoadModule imagemap_module modules/mod_imagemap.so +#LoadModule heartbeat_module modules/mod_heartbeat.so +#LoadModule heartmonitor_module modules/mod_heartmonitor.so +#LoadModule ident_module modules/mod_ident.so +#LoadModule imagemap_module modules/mod_imagemap.so LoadModule include_module modules/mod_include.so #LoadModule info_module modules/mod_info.so LoadModule isapi_module modules/mod_isapi.so +#LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so +#LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so +#LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so +#LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so +#LoadModule ldap_module modules/mod_ldap.so +#LoadModule logio_module modules/mod_logio.so LoadModule log_config_module modules/mod_log_config.so +#LoadModule log_debug_module modules/mod_log_debug.so +#LoadModule log_forensic_module modules/mod_log_forensic.so +#LoadModule lua_module modules/mod_lua.so +#LoadModule macro_module modules/mod_macro.so +#LoadModule md_module modules/mod_md.so LoadModule mime_module modules/mod_mime.so #LoadModule mime_magic_module modules/mod_mime_magic.so LoadModule negotiation_module modules/mod_negotiation.so @@ -105,33 +156,63 @@ LoadModule negotiation_module modules/mod_negotiation.so #LoadModule proxy_ajp_module modules/mod_proxy_ajp.so #LoadModule proxy_balancer_module modules/mod_proxy_balancer.so #LoadModule proxy_connect_module modules/mod_proxy_connect.so -#LoadModule proxy_http_module modules/mod_proxy_http.so +#LoadModule proxy_express_module modules/mod_proxy_express.so +#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so +#LoadModule proxy_hcheck_module modules/mod_proxy_hcheck.so +#LoadModule proxy_html_module modules/mod_proxy_html.so +#LoadModule proxy_http_module modules/mod_proxy_http.so +#LoadModule proxy_http2_module modules/mod_proxy_http2.so +#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so +#LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so +#LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so +#LoadModule ratelimit_module modules/mod_ratelimit.so +#LoadModule reflector_module modules/mod_reflector.so +#LoadModule remoteip_module modules/mod_remoteip.so +#LoadModule request_module modules/mod_request.so +#LoadModule reqtimeout_module modules/mod_reqtimeout.so LoadModule rewrite_module modules/mod_rewrite.so +#LoadModule sed_module modules/mod_sed.so +#LoadModule session_module modules/mod_session.so +#LoadModule session_cookie_module modules/mod_session_cookie.so +#LoadModule session_crypto_module modules/mod_session_crypto.so +#LoadModule session_dbd_module modules/mod_session_dbd.so LoadModule setenvif_module modules/mod_setenvif.so +#LoadModule slotmem_plain_module modules/mod_slotmem_plain.so +#LoadModule slotmem_shm_module modules/mod_slotmem_shm.so +#LoadModule socache_dbm_module modules/mod_socache_dbm.so +#LoadModule socache_memcache_module modules/mod_socache_memcache.so +#LoadModule socache_redis_module modules/mod_socache_redis.so +#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so #LoadModule speling_module modules/mod_speling.so #LoadModule ssl_module modules/mod_ssl.so -LoadModule status_module modules/mod_status.so +#LoadModule status_module modules/mod_status.so +#LoadModule substitute_module modules/mod_substitute.so #LoadModule unique_id_module modules/mod_unique_id.so LoadModule userdir_module modules/mod_userdir.so #LoadModule usertrack_module modules/mod_usertrack.so +#LoadModule version_module modules/mod_version.so LoadModule vhost_alias_module modules/mod_vhost_alias.so -LoadModule php5_module "WAMPROOT/bin/php/phpWAMPPHPVERSION/php5apache2_4.dll" +#LoadModule watchdog_module modules/mod_watchdog.so +#LoadModule xml2enc_module modules/mod_xml2enc.so +PHPIniDir "${APACHE_DIR}/bin" +#LoadModule WAMPAPACHELOADMODULE "${INSTALL_DIR}/bin/php/phpWAMPPHPVERSIONWEB/WAMPPHPAPACHEDLL" +LoadModule php7_module "WAMPROOT/bin/php/phpWAMPPHPVERSION/php7apache2_4.dll" + + # -# ExtendedStatus controls whether Apache will generate "full" status -# information (ExtendedStatus On) or just basic information (ExtendedStatus -# Off) when the "server-status" handler is called. The default is Off. +# If you wish httpd to run as a different user or group, you must run +# httpd as root initially and it will switch. # -ExtendedStatus On - - -SetHandler server-status -Require local -#Require ip 1.2.3.4 -#Require host 1.2.3.4 - +# User/Group: The name (or #number) of the user/group to run httpd as. +# It is usually good practice to create a dedicated user and group for +# running httpd, as with most system services. +# +User daemon +Group daemon + # 'Main' server configuration # @@ -162,59 +243,12 @@ ServerAdmin doliwamp@localhost ServerName localhost # -# ServerTokens -# This directive configures what you return as the Server HTTP response -# Header. The default is 'Full' which sends information about the OS-Type -# and compiled in modules. -# Set to one of: Full | OS | Minor | Minimal | Major | Prod -# where Full conveys the most information, and Prod the least. -# -#ServerTokens Prod - -# -# DocumentRoot: The directory out of which you will serve your -# documents. By default, all requests are taken from this directory, but -# symbolic links and aliases may be used to point to other locations. -# -DocumentRoot "WAMPROOT/www/" - - -# -# Timeout: The number of seconds before receives and sends time out. -# -Timeout 300 - -# -# KeepAlive: Whether or not to allow persistent connections (more than -# one request per connection). Set to "Off" to deactivate. -# -KeepAlive On - -# -# MaxKeepAliveRequests: The maximum number of requests to allow -# during a persistent connection. Set to 0 to allow an unlimited amount. -# We recommend you leave this number high, for maximum performance. -# -MaxKeepAliveRequests 500 - -# -# KeepAliveTimeout: Number of seconds to wait for the next request from the -# same client on the same connection. -# -KeepAliveTimeout 30 - - -# -# Each directory to which Apache has access can be configured with respect -# to which services and features are allowed and/or disabled in that -# directory (and its subdirectories). -# -# First, we configure the "default" to be a very restrictive set of -# features. +# Deny access to the entirety of your server's filesystem. You must +# explicitly permit access to web content directories in other +# blocks below. # - Options FollowSymLinks - AllowOverride None + AllowOverride none Require all denied @@ -224,12 +258,15 @@ KeepAliveTimeout 30 # you might expect, make sure that you have specifically enabled it # below. # +HostnameLookups Off # -# This should be changed to whatever you set DocumentRoot to. +# DocumentRoot: The directory out of which you will serve your +# documents. By default, all requests are taken from this directory, but +# symbolic links and aliases may be used to point to other locations. # - - +DocumentRoot "${INSTALL_DIR}/www" + # # Possible values for the Options directive are "None", "All", # or any combination of: @@ -239,30 +276,23 @@ KeepAliveTimeout 30 # doesn't give it to you. # # The Options directive is both complicated and important. Please see - # http://httpd.apache.org/docs/2.2/mod/core.html#options + # http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information. # - Options Indexes FollowSymLinks + Options +Indexes +FollowSymLinks +Multiviews # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: - # Options FileInfo AuthConfig Limit + # AllowOverride FileInfo AuthConfig Limit # AllowOverride all # # Controls who can get stuff from this server. # -# onlineoffline tag - don't remove - - Require all granted - - - Require ip 127.0.0.1 - Require host localhost - - +# Don't modify this line - Instead modify Require of VirtualHost in httpd-vhost.conf + Require local # @@ -274,12 +304,12 @@ KeepAliveTimeout 30 # -# The following lines prevent .htaccess and .htpasswd files from being -# viewed by Web clients. +# The following lines prevent .htaccess and .htpasswd files from being +# viewed by Web clients. # - + Require all denied - + # # ErrorLog: The location of the error log file. @@ -288,7 +318,8 @@ KeepAliveTimeout 30 # logged here. If you *do* define an error logfile for a # container, that host's errors will be logged there and not here. # -ErrorLog "WAMPROOT/logs/apache_error.log" + +ErrorLog "${INSTALL_DIR}/logs/apache_error.log" # # LogLevel: Control the number of messages logged to the error_log. @@ -317,22 +348,22 @@ LogLevel warn # define per- access logfiles, transactions will be # logged therein and *not* in this file. # - CustomLog "WAMPROOT/logs/access.log" common + CustomLog "${INSTALL_DIR}/logs/access.log" common # # If you prefer a logfile with access, agent, and referer information # (Combined Logfile Format) you can use the following directive. # - #CustomLog logs/access.log combined + #CustomLog "logs/access.log" combined # - # Redirect: Allows you to tell clients about documents that used to - # exist in your server's namespace, but do not anymore. The client + # Redirect: Allows you to tell clients about documents that used to + # exist in your server's namespace, but do not anymore. The client # will make a new request for the document at its new location. # Example: - # Redirect permanent /foo http://localhost/bar + # Redirect permanent /foo http://www.example.com/bar # # Alias: Maps web paths into filesystem paths and is used to @@ -346,75 +377,43 @@ LogLevel warn # the filesystem path. # - # ScriptAlias: This controls which directories contain server scripts. + # ScriptAlias: This controls which directories contain server scripts. # ScriptAliases are essentially the same as Aliases, except that # documents in the target directory are treated as applications and # run by the server when requested rather than as documents sent to the # client. The same rules about trailing "/" apply to ScriptAlias # directives as to Alias. # - ScriptAlias /cgi-bin/ "cgi-bin/" + ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/" + + # + # ScriptSock: On threaded servers, designate the path to the UNIX + # socket used to communicate with the CGI daemon of mod_cgid. + # + #Scriptsock cgisock + + # -# "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased +# "${SRVROOT}/cgi-bin" should be changed to whatever your ScriptAliased # CGI directory exists, if you have that configured. # - + AllowOverride None Options None Require all granted -# -# Apache parses all CGI scripts for the shebang line by default. -# This comment line, the first line of the script, consists of the symbols -# pound (#) and exclamation (!) followed by the path of the program that -# can execute this specific script. For a perl script, with perl.exe in -# the C:\Program Files\Perl directory, the shebang line should be: - - #!c:/program files/perl/perl - -# Note you _must_not_ indent the actual shebang line, and it must be the -# first line of the file. Of course, CGI processing must be enabled by -# the appropriate ScriptAlias or Options ExecCGI directives for the files -# or directory in question. -# -# However, Apache on Windows allows either the Unix behavior above, or can -# use the Registry to match files by extention. The command to execute -# a file of this type is retrieved from the registry by the same method as -# the Windows Explorer would use to handle double-clicking on a file. -# These script actions can be configured from the Windows Explorer View menu, -# 'Folder Options', and reviewing the 'File Types' tab. Clicking the Edit -# button allows you to modify the Actions, of which Apache 1.3 attempts to -# perform the 'Open' Action, and failing that it will try the shebang line. -# This behavior is subject to change in Apache release 2.0. -# -# Each mechanism has it's own specific security weaknesses, from the means -# to run a program you didn't intend the website owner to invoke, and the -# best method is a matter of great debate. -# -# To enable the this Windows specific behavior (and therefore -disable- the -# equivilant Unix behavior), uncomment the following directive: -# -#ScriptInterpreterSource registry -# -# The directive above can be placed in individual blocks or the -# .htaccess file, with either the 'registry' (Windows behavior) or 'script' -# (Unix behavior) option, and will override this server default option. -# - -# -# DefaultType: the default MIME type the server will use for a document -# if it cannot otherwise determine one, such as from filename extensions. -# If your server contains mostly text or HTML documents, "text/plain" is -# a good value. If most of your content is binary, such as applications -# or images, you may want to use "application/octet-stream" instead to -# keep browsers from trying to display binary files as though they are -# text. -# -#DefaultType text/plain + + # + # Avoid passing HTTP_PROXY environment to CGI's on this or any proxied + # backend servers which have lingering "httpoxy" defects. + # 'Proxy' request header is undefined by the IETF, not listed by IANA + # + RequestHeader unset Proxy early + # @@ -432,8 +431,8 @@ LogLevel warn # AddEncoding allows you to have certain browsers uncompress # information on the fly. Note: Not all browsers support this. # - #AddEncoding x-compress .Z - #AddEncoding x-gzip .gz .tgz + AddEncoding x-compress .Z + AddEncoding x-gzip .gz .tgz # # If the AddEncoding directives above are commented-out, then you # probably should define those extensions to indicate media types: @@ -481,25 +480,40 @@ LogLevel warn #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" -#ErrorDocument 402 http://localhost/subscription_info.html +#ErrorDocument 402 http://www.example.com/subscription_info.html # # -# EnableMMAP and EnableSendfile: On systems that support it, -# memory-mapping or the sendfile syscall is used to deliver +# MaxRanges: Maximum number of Ranges in a request before +# returning the entire resource, or one of the special +# values 'default', 'none' or 'unlimited'. +# Default setting is to accept 200 Ranges. +#MaxRanges unlimited + +# +# EnableMMAP and EnableSendfile: On systems that support it, +# memory-mapping or the sendfile syscall may be used to deliver # files. This usually improves server performance, but must -# be turned off when serving from networked-mounted +# be turned off when serving from networked-mounted # filesystems or if support for these functions is otherwise # broken on your system. +# Defaults: EnableMMAP On, EnableSendfile Off # -#EnableMMAP off -#EnableSendfile off +EnableMMAP off +EnableSendfile off + +# AcceptFilter: On Windows, none uses accept() rather than AcceptEx() and +# will not recycle sockets between connections. This is useful for network +# adapters with broken driver support, as well as some virtual network +# providers such as vpn drivers, or spam, virus or spyware filters. +AcceptFilter http none +AcceptFilter https none # Supplemental configuration # -# The configuration files in the conf/extra/ directory can be -# included to add extra features or to modify the default configuration of -# the server, or you may simply copy their contents here and change as +# The configuration files in the conf/extra/ directory can be +# included to add extra features or to modify the default configuration of +# the server, or you may simply copy their contents here and change as # necessary. # Server-pool management (MPM specific) @@ -532,17 +546,19 @@ Include conf/extra/httpd-autoindex.conf # Various default settings #Include conf/extra/httpd-default.conf - +# Configure mod_proxy_html to understand HTML4/XHTML1 + +Include conf/extra/proxy-html.conf + # Secure (SSL/TLS) connections +#Include conf/extra/httpd-ssl.conf # # Note: The following must must be present to support # starting without SSL on platforms with no /dev/random equivalent # but a statically compiled-in mod_ssl. # - - SSLRandomSeed startup builtin SSLRandomSeed connect builtin @@ -733,44 +749,8 @@ SSLCertificateKeyFile "WAMPROOT/myserver.key" # nokeepalive ssl-unclean-shutdown \ # downgrade-1.0 force-response-1.0 - + - - -# OPTIMIZE: To use gzip compression (for already compressed files). -# Note that constant MAIN_OPTIMIZE_SPEED must have a value with bit 0 set. -#AddType text/javascript .jgz -#AddEncoding gzip .jgz - -# OPTIMIZE: To use gzip compression (on the fly). -# Note that you must also enable the module mod_deflate. -# You can also set this with constant MAIN_OPTIMIZE_SPEED and bit 2 set. -#TODO - -# OPTIMIZE: To use cache on static pages (A259200 = 1 month, A7200 = 2 hours, A691600 = 8 days = recommanded for static resources). -# Note that you must also enable the module mod_expires. -#ExpiresActive On -#ExpiresByType image/x-icon A2592000 -#ExpiresByType image/gif A2592000 -#ExpiresByType image/png A2592000 -#ExpiresByType image/jpeg A2592000 -#ExpiresByType text/css A2592000 -#ExpiresByType text/javascript A2592000 -#ExpiresByType application/x-javascript A2592000 -#ExpiresByType application/javascript A2592000 - - -# To protect Dolibarr with HTTP Auth -# -# Options +Indexes -# AuthUserFile /var/www/.htpasswd -# AuthName "Zone authent basic Dolibarr" -# AuthType Basic -# require user test -# - - -# Declare alias for Dolibarr, PHPMyAdmin and other software -Include "WAMPROOT/alias/*.conf" +Include "${INSTALL_DIR}/alias/*.conf" \ No newline at end of file diff --git a/build/exe/doliwamp/install_services.bat.install b/build/exe/doliwamp/install_services.bat.install index 5ad43827f86..5d0fe69350f 100644 --- a/build/exe/doliwamp/install_services.bat.install +++ b/build/exe/doliwamp/install_services.bat.install @@ -11,14 +11,19 @@ REM NET STOP doliwampmysqld cd "WAMPROOT" REM Apache x.x -.\bin\apache\apacheWAMPAPACHEVERSION\bin\httpd.exe -k install -n doliwampapache +.\bin\apache\apacheWAMPAPACHEVERSION\bin\httpd.exe -k install -n doliwampapache >> doliwamp.log 2>>&1 REM reg add HKLM\SYSTEM\CurrentControlSet\Services\doliwampapache /V Start /t REG_DWORD /d 3 /f REM Mysql 5.0- -REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --install-manual doliwampmysqld -.\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --install doliwampmysqld +REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --install-manual doliwampmysqld +REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld REM Mysql 5.1+ REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld +REM Mariadb +REM The mysql_install_db allows to not provide files into mysql dir but does not return to prompt so install hangs +REM .\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT --password=WAMPMYSQLNEWPASSWORD >> doliwamp.log 2>>&1 +.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql_install_db.exe --datadir=WAMPROOT/bin/mariadb/data --port=WAMPMYSQLPORT >> doliwamp.log 2>>&1 +.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqld.exe --install doliwampmysqld >> doliwamp.log 2>>&1 echo ---- End script >> doliwamp.log 2>>&1 diff --git a/build/exe/doliwamp/my.ini.install b/build/exe/doliwamp/my.ini.install index e1a9495e20b..4d2037d8e97 100644 --- a/build/exe/doliwamp/my.ini.install +++ b/build/exe/doliwamp/my.ini.install @@ -69,13 +69,13 @@ port=WAMPMYSQLPORT #Path to installation directory. All paths are usually resolved relative to this. -basedir=WAMPROOT/bin/mysql/mysqlWAMPMYSQLVERSION +basedir=WAMPROOT/bin/mariadb/mariadbWAMPMYSQLVERSION #log file log-error=WAMPROOT/logs/mysql.log #Path to the database root -datadir=WAMPROOT/bin/mysql/data +datadir=WAMPROOT/bin/mariadb/data # The default storage engine that will be used when create new tables when default-storage-engine=INNODB @@ -196,13 +196,13 @@ port=WAMPMYSQLPORT #Path to installation directory. All paths are usually resolved relative to this. -basedir=WAMPROOT/bin/mysql/mysqlWAMPMYSQLVERSION +basedir=WAMPROOT/bin/mariadb/mariadbWAMPMYSQLVERSION #log file log-error=WAMPROOT/logs/mysql.log #Path to the database root -datadir=WAMPROOT/bin/mysql/data +datadir=WAMPROOT/bin/mariadb/data # The default storage engine that will be used when create new tables when default-storage-engine=INNODB diff --git a/build/exe/doliwamp/mysql/columns_priv.MYD b/build/exe/doliwamp/mysql/columns_priv.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/columns_priv.MYI b/build/exe/doliwamp/mysql/columns_priv.MYI deleted file mode 100644 index f1a20aacb4b..00000000000 Binary files a/build/exe/doliwamp/mysql/columns_priv.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/columns_priv.frm b/build/exe/doliwamp/mysql/columns_priv.frm deleted file mode 100644 index 6b12fc174c2..00000000000 Binary files a/build/exe/doliwamp/mysql/columns_priv.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/db.MYD b/build/exe/doliwamp/mysql/db.MYD deleted file mode 100644 index 8d671b07393..00000000000 Binary files a/build/exe/doliwamp/mysql/db.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/db.MYI b/build/exe/doliwamp/mysql/db.MYI deleted file mode 100644 index d4a1de9c34d..00000000000 Binary files a/build/exe/doliwamp/mysql/db.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/db.frm b/build/exe/doliwamp/mysql/db.frm deleted file mode 100644 index a8cab8f1fcd..00000000000 Binary files a/build/exe/doliwamp/mysql/db.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/func.MYD b/build/exe/doliwamp/mysql/func.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/func.MYI b/build/exe/doliwamp/mysql/func.MYI deleted file mode 100644 index cbfe35c310e..00000000000 Binary files a/build/exe/doliwamp/mysql/func.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/func.frm b/build/exe/doliwamp/mysql/func.frm deleted file mode 100644 index d572065cbd8..00000000000 Binary files a/build/exe/doliwamp/mysql/func.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_category.MYD b/build/exe/doliwamp/mysql/help_category.MYD deleted file mode 100644 index d3ffdd47d9a..00000000000 Binary files a/build/exe/doliwamp/mysql/help_category.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_category.MYI b/build/exe/doliwamp/mysql/help_category.MYI deleted file mode 100644 index 1827cfaa604..00000000000 Binary files a/build/exe/doliwamp/mysql/help_category.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_category.frm b/build/exe/doliwamp/mysql/help_category.frm deleted file mode 100644 index f97bae288e6..00000000000 Binary files a/build/exe/doliwamp/mysql/help_category.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_keyword.MYD b/build/exe/doliwamp/mysql/help_keyword.MYD deleted file mode 100644 index ec02aeb4876..00000000000 Binary files a/build/exe/doliwamp/mysql/help_keyword.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_keyword.MYI b/build/exe/doliwamp/mysql/help_keyword.MYI deleted file mode 100644 index 8c5a7a6359b..00000000000 Binary files a/build/exe/doliwamp/mysql/help_keyword.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_keyword.frm b/build/exe/doliwamp/mysql/help_keyword.frm deleted file mode 100644 index 2fb3b009667..00000000000 Binary files a/build/exe/doliwamp/mysql/help_keyword.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_relation.MYD b/build/exe/doliwamp/mysql/help_relation.MYD deleted file mode 100644 index 493c37c9c19..00000000000 Binary files a/build/exe/doliwamp/mysql/help_relation.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_relation.MYI b/build/exe/doliwamp/mysql/help_relation.MYI deleted file mode 100644 index ecb69cc0360..00000000000 Binary files a/build/exe/doliwamp/mysql/help_relation.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_relation.frm b/build/exe/doliwamp/mysql/help_relation.frm deleted file mode 100644 index 8ddfdddc71e..00000000000 Binary files a/build/exe/doliwamp/mysql/help_relation.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_topic.MYD b/build/exe/doliwamp/mysql/help_topic.MYD deleted file mode 100644 index 3b660b25496..00000000000 Binary files a/build/exe/doliwamp/mysql/help_topic.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_topic.MYI b/build/exe/doliwamp/mysql/help_topic.MYI deleted file mode 100644 index 7a727366752..00000000000 Binary files a/build/exe/doliwamp/mysql/help_topic.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/help_topic.frm b/build/exe/doliwamp/mysql/help_topic.frm deleted file mode 100644 index a09a2c3b590..00000000000 Binary files a/build/exe/doliwamp/mysql/help_topic.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/host.MYD b/build/exe/doliwamp/mysql/host.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/host.MYI b/build/exe/doliwamp/mysql/host.MYI deleted file mode 100644 index f0cbeb6258c..00000000000 Binary files a/build/exe/doliwamp/mysql/host.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/host.frm b/build/exe/doliwamp/mysql/host.frm deleted file mode 100644 index dbafa8d2b90..00000000000 Binary files a/build/exe/doliwamp/mysql/host.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/proc.MYD b/build/exe/doliwamp/mysql/proc.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/proc.MYI b/build/exe/doliwamp/mysql/proc.MYI deleted file mode 100644 index a843a2efda1..00000000000 Binary files a/build/exe/doliwamp/mysql/proc.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/proc.frm b/build/exe/doliwamp/mysql/proc.frm deleted file mode 100644 index 32b9b0e2eda..00000000000 Binary files a/build/exe/doliwamp/mysql/proc.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/procs_priv.MYD b/build/exe/doliwamp/mysql/procs_priv.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/procs_priv.MYI b/build/exe/doliwamp/mysql/procs_priv.MYI deleted file mode 100644 index a7f955241e1..00000000000 Binary files a/build/exe/doliwamp/mysql/procs_priv.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/procs_priv.frm b/build/exe/doliwamp/mysql/procs_priv.frm deleted file mode 100644 index b2cd3f50ef2..00000000000 Binary files a/build/exe/doliwamp/mysql/procs_priv.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/tables_priv.MYD b/build/exe/doliwamp/mysql/tables_priv.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/tables_priv.MYI b/build/exe/doliwamp/mysql/tables_priv.MYI deleted file mode 100644 index 6a2409ff79a..00000000000 Binary files a/build/exe/doliwamp/mysql/tables_priv.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/tables_priv.frm b/build/exe/doliwamp/mysql/tables_priv.frm deleted file mode 100644 index 4afbd02da2d..00000000000 Binary files a/build/exe/doliwamp/mysql/tables_priv.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone.MYD b/build/exe/doliwamp/mysql/time_zone.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/time_zone.MYI b/build/exe/doliwamp/mysql/time_zone.MYI deleted file mode 100644 index 68053049224..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone.frm b/build/exe/doliwamp/mysql/time_zone.frm deleted file mode 100644 index 8391df0107e..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_leap_second.MYD b/build/exe/doliwamp/mysql/time_zone_leap_second.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/time_zone_leap_second.MYI b/build/exe/doliwamp/mysql/time_zone_leap_second.MYI deleted file mode 100644 index e41863b0448..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_leap_second.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_leap_second.frm b/build/exe/doliwamp/mysql/time_zone_leap_second.frm deleted file mode 100644 index 90bb6cda6df..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_leap_second.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_name.MYD b/build/exe/doliwamp/mysql/time_zone_name.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/time_zone_name.MYI b/build/exe/doliwamp/mysql/time_zone_name.MYI deleted file mode 100644 index e13615ccdef..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_name.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_name.frm b/build/exe/doliwamp/mysql/time_zone_name.frm deleted file mode 100644 index a1515da6890..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_name.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_transition.MYD b/build/exe/doliwamp/mysql/time_zone_transition.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/time_zone_transition.MYI b/build/exe/doliwamp/mysql/time_zone_transition.MYI deleted file mode 100644 index f28e4cec8d2..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_transition.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_transition.frm b/build/exe/doliwamp/mysql/time_zone_transition.frm deleted file mode 100644 index 52e2d1da633..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_transition.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_transition_type.MYD b/build/exe/doliwamp/mysql/time_zone_transition_type.MYD deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/build/exe/doliwamp/mysql/time_zone_transition_type.MYI b/build/exe/doliwamp/mysql/time_zone_transition_type.MYI deleted file mode 100644 index 2f7e0c7127d..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_transition_type.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/time_zone_transition_type.frm b/build/exe/doliwamp/mysql/time_zone_transition_type.frm deleted file mode 100644 index cee25730d40..00000000000 Binary files a/build/exe/doliwamp/mysql/time_zone_transition_type.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysql/user.MYD b/build/exe/doliwamp/mysql/user.MYD deleted file mode 100644 index 80ef951da55..00000000000 Binary files a/build/exe/doliwamp/mysql/user.MYD and /dev/null differ diff --git a/build/exe/doliwamp/mysql/user.MYI b/build/exe/doliwamp/mysql/user.MYI deleted file mode 100644 index 63b81f1efbf..00000000000 Binary files a/build/exe/doliwamp/mysql/user.MYI and /dev/null differ diff --git a/build/exe/doliwamp/mysql/user.frm b/build/exe/doliwamp/mysql/user.frm deleted file mode 100644 index ef5c451c7f3..00000000000 Binary files a/build/exe/doliwamp/mysql/user.frm and /dev/null differ diff --git a/build/exe/doliwamp/mysqlinitpassword.bat.install b/build/exe/doliwamp/mysqlinitpassword.bat.install index d90cee71b33..4b9e9ac4173 100644 --- a/build/exe/doliwamp/mysqlinitpassword.bat.install +++ b/build/exe/doliwamp/mysqlinitpassword.bat.install @@ -17,7 +17,7 @@ ping 1.1.1.1 -n 1 -w 5000 > nul echo ---- Execute mysqlinitpassword.bat to init mysql password >> doliwamp.log 2>>&1 echo For a first installation, if an error is shown here, rerun the script manually. >> doliwamp.log 2>>&1 echo For an update, you will get an "Access denied" error, ignore this error. >> doliwamp.log 2>>&1 -.\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqladmin -v -w6 -P WAMPMYSQLPORT -u root password WAMPMYSQLNEWPASSWORD >> doliwamp.log 2>>&1 +.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqladmin -v -w6 -P WAMPMYSQLPORT -u root password WAMPMYSQLNEWPASSWORD >> doliwamp.log 2>>&1 echo ---- End script >> doliwamp.log 2>>&1 diff --git a/build/exe/doliwamp/mysqltestinstall.bat.install b/build/exe/doliwamp/mysqltestinstall.bat.install index 56baaeacb4d..b718cf94ac8 100644 --- a/build/exe/doliwamp/mysqltestinstall.bat.install +++ b/build/exe/doliwamp/mysqltestinstall.bat.install @@ -6,7 +6,7 @@ REM To change password, run following SQL command: REM GRANT ALL ON *.* TO login@localhost IDENTIFIED BY "newpassword" echo ----------------------------------------------------------- -echo This programm wil test a login on Mysql installed +echo This programm will test a login on Mysql installed echo by DoliWamp. echo Version: WAMPMYSQLVERSION echo Port: WAMPMYSQLPORT @@ -19,6 +19,6 @@ SET SAVES= SET /P SAVES=Enter password to test: echo Try to connect to mysql with this password -.\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysql -P WAMPMYSQLPORT -u root -p%SAVES% +.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysql -P WAMPMYSQLPORT -u root -p%SAVES% pause diff --git a/build/exe/doliwamp/php.ini.install b/build/exe/doliwamp/php.ini.install index af8ef607112..a2576c7652d 100644 --- a/build/exe/doliwamp/php.ini.install +++ b/build/exe/doliwamp/php.ini.install @@ -644,53 +644,36 @@ default_socket_timeout = 60 ; If an extension does not load, run "deplister.exe php_xxx.dll" to get list of dependency dll missing. -extension=php_bz2.dll -extension=php_curl.dll -;extension=php_dba.dll -;extension=php_dbase.dll -;extension=php_exif.dll -;extension=php_fdf.dll -extension=php_gd2.dll -;extension=php_gettext.dll -;extension=php_gmp.dll -;extension=php_ifx.dll -;extension=php_imap.dll -;extension=php_interbase.dll -extension=php_intl.dll -extension=php_ldap.dll -extension=php_mbstring.dll -;extension=php_mcrypt.dll -;extension=php_mhash.dll -;extension=php_mime_magic.dll -;extension=php_ming.dll -;extension=php_msql.dll -;extension=php_mssql.dll -extension=php_mysql.dll -extension=php_mysqli.dll -;extension=php_oci8.dll -extension=php_openssl.dll -;extension=php_pdo.dll ; for php 5.2.11 -;extension=php_pdo_firebird.dll -;extension=php_pdo_mssql.dll -extension=php_pdo_mysql.dll -;extension=php_pdo_oci.dll -;extension=php_pdo_oci8.dll -;extension=php_pdo_odbc.dll -;extension=php_pdo_pgsql.dll -extension=php_pdo_sqlite.dll -;extension=php_pgsql.dll -;extension=php_pspell.dll -;extension=php_shmop.dll -;extension=php_snmp.dll -extension=php_soap.dll -extension=php_sockets.dll -;extension=php_sqlite.dll -;extension=php_sybase_ct.dll -;extension=php_tidy.dll -;extension=php_xmlrpc.dll -;extension=php_xsl.dll -;extension=php_zip.dll -;extension=php_xdebug-2.0.5-5.2.dll +extension=bz2 +extension=curl +;extension=dba +;extension=com_dotnet +;extension=enchant +;extension=fileinfo +;extension=ftp +extension=gd2 +;extension=gettext +;extension=gmp +extension=intl +extension=imap +;extension=interbase +extension=ldap +extension=mbstring +extension=exif ; Must be after mbstring as it depends on it +extension=mysqli +;extension=odbc +extension=openssl +;extension=pdo_firebird +extension=pdo_mysql +;extension=pdo_oci +;extension=pdo_odbc +;extension=pdo_pgsql +;extension=pdo_sqlite +;extension=pgsql +;extension=phpdbg_webhelper +;extension=shmop +extension=soap +extension=sockets ;;;;;;;;;;;;;;;;;;; diff --git a/build/exe/doliwamp/startdoliwamp_manual_donotuse.bat.install b/build/exe/doliwamp/startdoliwamp_manual_donotuse.bat.install index c8e33e4620b..675cfd4750e 100644 --- a/build/exe/doliwamp/startdoliwamp_manual_donotuse.bat.install +++ b/build/exe/doliwamp/startdoliwamp_manual_donotuse.bat.install @@ -12,7 +12,8 @@ start WAMPROOT\bin\apache\apacheWAMPAPACHEVERSION\bin\httpd.exe -f conf\httpd.co echo echo Running Mysql as user process (this process does not return so we use "start") -start WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --defaults-file=WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\my.ini --console +REM start WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --defaults-file=WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\my.ini --console REM start WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --defaults-file=WAMPROOT\bin\mysql\mysqlWAMPMYSQLVERSION\my.ini --console +start WAMPROOT\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqld.exe --defaults-file=WAMPROOT\bin\mariadb\mariadbWAMPMYSQLVERSION\my.ini --console pause \ No newline at end of file diff --git a/build/exe/doliwamp/uninstall_services.bat.install b/build/exe/doliwamp/uninstall_services.bat.install index 0f12a29b6e2..a7329ab1b8f 100644 --- a/build/exe/doliwamp/uninstall_services.bat.install +++ b/build/exe/doliwamp/uninstall_services.bat.install @@ -11,9 +11,11 @@ NET STOP doliwampapache NET STOP doliwampmysqld REM Mysql 5.0- -.\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --remove doliwampmysqld +REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld-nt.exe --remove doliwampmysqld REM Mysql 5.1+ REM .\bin\mysql\mysqlWAMPMYSQLVERSION\bin\mysqld.exe --remove doliwampmysqld +REM Maraiadb +.\bin\mariadb\mariadbWAMPMYSQLVERSION\bin\mysqld.exe --remove doliwampmysqld REM wampmanager.exe -quit -id={doliwampserver} echo ---- End script >> doliwamp.log 2>>&1 diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index f68ca6a77f5..c06dc51aec1 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -2,7 +2,7 @@ #---------------------------------------------------------------------------- # \file build/makepack-dolibarr.pl # \brief Dolibarr package builder (tgz, zip, rpm, deb, exe, aps) -# \author (c)2004-2015 Laurent Destailleur +# \author (c)2004-2020 Laurent Destailleur # # This is list of constant you can set to have generated packages moved into a specific dir: #DESTIBETARC='/media/HDDATA1_LD/Mes Sites/Web/Dolibarr/dolibarr.org/files/lastbuild' @@ -430,12 +430,14 @@ if ($nboftargetok) { $ret=`git tag -a -f -m "$MAJOR.$MINOR.$BUILD" "$MAJOR.$MINOR.$BUILD"`; print 'Run git push -f --tags'."\n"; $ret=`git push -f --tags`; + #$ret=`git push -f origin "$MAJOR.$MINOR.$BUILD"`; } } else { print 'Run git push --tags'."\n"; $ret=`git push --tags`; + #$ret=`git push origin "$MAJOR.$MINOR.$BUILD"`; } chdir("$olddir"); } @@ -1065,7 +1067,7 @@ if ($nboftargetok) { print "Remove target $NEWDESTI/$FILENAMEEXEDOLIWAMP.exe...\n"; unlink "$NEWDESTI/$FILENAMEEXEDOLIWAMP.exe"; - print "Check that in your Wine setup, you create a Z: drive that point to your / directory.\n"; + print "Check that in your Wine setup, you have created a Z: drive that point to your / directory.\n"; $SOURCEBACK=$SOURCE; $SOURCEBACK =~ s/\//\\/g; diff --git a/build/obs/README b/build/obs/README index c8a29e1dac4..44427c01d49 100644 --- a/build/obs/README +++ b/build/obs/README @@ -1,20 +1,24 @@ README (English) ################################################## OBS Package tools +OBE - openSUSE Build Service ################################################## -This directory contains files to explain how to publish -a package onto OBS +This directory contains an instruction to explain +how to publish a package onto OBS. -# Create a project onto OBS -#---------------------------------- -https://build.opensuse.org +# Create a project onto OBS +--------------------------- +https://build.opensuse.org -Packaging rules: http://en.opensuse.org/Portal:Packaging + +# Packaging rules: +------------------ +https://en.opensuse.org/Portal:Packaging Add attributes: -OBS:Screenshots URL of screenshot http://www.dolibarr.org/images/dolibarr_screenshot1.png +OBS:Screenshots URL of screenshot https://www.dolibarr.org/images/dolibarr_screenshot1.png OBS:QualityCategory Development|Testing|Stable|Private OBS:Maintained 1 @@ -28,22 +32,24 @@ To submit a snapshot for building, we should have a service file with content -How to have such a service file created automatically ? -Go into project you want to update. It mught be: +# How to have such a service file created automatically ? +--------------------------------------------------------- +Go into project you want to update. It might be: - openSUSE Build Service > Projects > Application:ERP:Dolibarr > dolibarr - or your private project Once logged, click on "Add file" in section "Source Files", then select mode "Upload From: Remote URL" Keep empty for "Filename", choose "Remote URL" and enter into last field, URL that should looks like this: -http://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.4.src.rpm +https://www.dolibarr.org/files/stable/package_rpm_generic/dolibarr-x.y.v-0.4.src.rpm Then add into Advanded - Attributes -OBS:Screenshots http://www.dolibarr.org/images/dolibarr_screenshot1.png -OBS:QualityCategory Stable|Testing|Development|Private +OBS:Screenshots https://www.dolibarr.org/images/dolibarr_screenshot1.png +OBS:QualityCategory Stable|Testing|Development|Private # Move project into official directory +-------------------------------------- - Enter a bug to ask to be a maintener of a category or to add a new one. For example: https://bugzilla.novell.com/show_bug.cgi?id=848083 to be a maintener of category https://build.opensuse.org/project/show/Application:ERP diff --git a/composer.json b/composer.json index 86acd2f8d60..d26bbb05ad9 100644 --- a/composer.json +++ b/composer.json @@ -28,11 +28,12 @@ "ext-curl" : "*", "ckeditor/ckeditor" : "4.12.1", "mike42/escpos-php" : "2.2", - "mobiledetect/mobiledetectlib" : "2.8.33", + "mobiledetect/mobiledetectlib" : "2.8.34", "phpoffice/phpexcel" : "1.8.1", "restler/framework" : "3.0.0-RC6", - "tecnickcom/tcpdf" : "^6.2", - "luracast/restler" : "^3.0" + "tecnickcom/tcpdf" : "6.3.2", + "nnnick/chartjs" : "^2.9", + "stripe/stripe-php" : "6.43.1" }, "require-dev" : { "jakub-onderka/php-parallel-lint" : "^0", @@ -56,4 +57,4 @@ "ext-zip" : "ODT, Excel and file compression support", "ext-xml" : "Excel support" } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index e9ea391bba2..09c71674512 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "16c94fd4f22ac17820d85ee57b0616e1", + "content-hash": "17e906996157e8a94564f686a6096dc5", "packages": [ { "name": "ckeditor/ckeditor", @@ -49,24 +49,31 @@ }, { "name": "mike42/escpos-php", - "version": "v1.2.1", + "version": "v2.2", "source": { "type": "git", "url": "https://github.com/mike42/escpos-php.git", - "reference": "cfea4c4fc95516ac953e1e5b623f854632afa2ee" + "reference": "e5496cf819b048b11877117bd14a9cea4fb17c03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mike42/escpos-php/zipball/cfea4c4fc95516ac953e1e5b623f854632afa2ee", - "reference": "cfea4c4fc95516ac953e1e5b623f854632afa2ee", + "url": "https://api.github.com/repos/mike42/escpos-php/zipball/e5496cf819b048b11877117bd14a9cea4fb17c03", + "reference": "e5496cf819b048b11877117bd14a9cea4fb17c03", "shasum": "" }, "require": { - "php": ">=5.3.0" + "ext-mbstring": "*", + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "4.5.*", - "squizlabs/php_codesniffer": "2.*" + "guzzlehttp/guzzle": "^5.3", + "phpunit/phpunit": "^4.8", + "squizlabs/php_codesniffer": "^3.2" + }, + "suggest": { + "ext-gd": "Used for image printing if present.", + "ext-imagick": "Will be used for image printing if present. Required for PDF printing or use of custom fonts.", + "guzzlehttp/guzzle": "Allows the use of the ApiConnector to send print jobs over HTTP." }, "type": "library", "autoload": { @@ -79,28 +86,12 @@ "MIT" ], "authors": [ - { - "name": "Roni Saha", - "email": "roni.cse@gmail.com" - }, { "name": "Michael Billington", "email": "michael.billington@gmail.com" - }, - { - "name": "Gergely Radics", - "email": "gerifield@ustream.tv" - }, - { - "name": "Warren Doyle", - "email": "w.doyle@fuelled.co" - }, - { - "name": "vharo", - "email": "vharo@geepok.com" } ], - "description": "Thermal receipt printer library, for use with ESC/POS compatible printers", + "description": "PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers", "homepage": "https://github.com/mike42/escpos-php", "keywords": [ "ESC-POS", @@ -109,20 +100,20 @@ "print", "receipt" ], - "time": "2016-04-25T01:14:07+00:00" + "time": "2019-10-05T05:59:00+00:00" }, { "name": "mobiledetect/mobiledetectlib", - "version": "2.8.33", + "version": "2.8.34", "source": { "type": "git", "url": "https://github.com/serbanghita/Mobile-Detect.git", - "reference": "cd385290f9a0d609d2eddd165a1e44ec1bf12102" + "reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/cd385290f9a0d609d2eddd165a1e44ec1bf12102", - "reference": "cd385290f9a0d609d2eddd165a1e44ec1bf12102", + "url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/6f8113f57a508494ca36acbcfa2dc2d923c7ed5b", + "reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b", "shasum": "" }, "require": { @@ -161,7 +152,48 @@ "mobile detector", "php mobile detect" ], - "time": "2018-09-01T15:05:15+00:00" + "time": "2019-09-18T18:44:20+00:00" + }, + { + "name": "nnnick/chartjs", + "version": "v2.9.3", + "source": { + "type": "git", + "url": "https://github.com/chartjs/Chart.js.git", + "reference": "06f73dc3590084b2c464bf08189c7aee2b6b92d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chartjs/Chart.js/zipball/06f73dc3590084b2c464bf08189c7aee2b6b92d2", + "reference": "06f73dc3590084b2c464bf08189c7aee2b6b92d2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "release/2.0": "v2.0-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "NICK DOWNIE", + "email": "hello@nickdownie.com" + } + ], + "description": "Simple HTML5 charts using the canvas element.", + "homepage": "https://www.chartjs.org/", + "keywords": [ + "JS", + "chart" + ], + "time": "2019-11-14T18:37:30+00:00" }, { "name": "phpoffice/phpexcel", @@ -282,6 +314,62 @@ ], "time": "2019-05-12T15:15:11+00:00" }, + { + "name": "stripe/stripe-php", + "version": "v6.43.1", + "source": { + "type": "git", + "url": "https://github.com/stripe/stripe-php.git", + "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stripe/stripe-php/zipball/42fcdaf99c44bb26937223f8eae1f263491d5ab8", + "reference": "42fcdaf99c44bb26937223f8eae1f263491d5ab8", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "1.*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0", + "symfony/process": "~2.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "psr-4": { + "Stripe\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stripe and contributors", + "homepage": "https://github.com/stripe/stripe-php/contributors" + } + ], + "description": "Stripe PHP Library", + "homepage": "https://stripe.com/", + "keywords": [ + "api", + "payment processing", + "stripe" + ], + "time": "2019-08-29T16:56:12+00:00" + }, { "name": "tecnickcom/tcpdf", "version": "6.3.2", @@ -1815,7 +1903,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.0", + "php": ">=5.5.0", "ext-curl": "*" }, "platform-dev": [] diff --git a/dev/examples/ldap/ldapadd_sample1.txt b/dev/examples/ldap/ldapadd_sample1.txt index 8a28529acb8..e998d6013a3 100644 --- a/dev/examples/ldap/ldapadd_sample1.txt +++ b/dev/examples/ldap/ldapadd_sample1.txt @@ -11,4 +11,4 @@ objectclass: dcObject objectClass: organization objectClass: top dc: my-domain -o: Mon organisation \ No newline at end of file +o: my organisation diff --git a/dev/examples/ldap/ldapmodify_sample1.txt b/dev/examples/ldap/ldapmodify_sample1.txt index e3a8361ca31..e95d1dc03a7 100644 --- a/dev/examples/ldap/ldapmodify_sample1.txt +++ b/dev/examples/ldap/ldapmodify_sample1.txt @@ -12,4 +12,4 @@ objectclass: dcObject objectClass: organization objectClass: top dc: my-domain -o: Mon organisation \ No newline at end of file +o: my organisation diff --git a/dev/initdemo/initdemo.sh b/dev/initdemo/initdemo.sh index 1b365ed83ba..c373a25090d 100755 --- a/dev/initdemo/initdemo.sh +++ b/dev/initdemo/initdemo.sh @@ -110,7 +110,7 @@ then fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Mysql root login (ex: root):" 16 55 root 2> $fichtemp + --inputbox "Mysql user login (ex: root):" 16 55 root 2> $fichtemp valret=$? @@ -128,7 +128,7 @@ then fichtemp=`tempfile 2>/dev/null` || fichtemp=/tmp/test$$ trap "rm -f $fichtemp" 0 1 2 5 15 $DIALOG --title "Init Dolibarr with demo values" --clear \ - --inputbox "Password for Mysql root login :" 16 55 2> $fichtemp + --inputbox "Password for Mysql user login :" 16 55 2> $fichtemp valret=$? @@ -172,6 +172,8 @@ echo "mysql -P$port -u$admin -p***** $base < $mydir/$dumpfile" mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile export res=$? +$mydir/updatedemo.php confirm +export res=$? # ---------------------------- copy demo files export documentdir=`cat $mydir/../../htdocs/conf/conf.php | grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g' ` diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index a1410d3d962..0cc43a18a9d 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -51,6 +51,8 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; * Main */ +print "***** ".$script_file." *****\n"; +print "Update dates to current year for database name = ".$db->database_name."\n"; if (empty($confirm)) { print "Usage: $script_file confirm\n"; @@ -65,11 +67,13 @@ $tmp=dol_getdate(dol_now()); $tables=array( 'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'), 'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'), - 'facture'=>array(0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'), + 'facture'=>array(0=>'datec', 0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'), 'paiement'=>array(0=>'datep'), 'bank'=>array(0=>'datev', 1=>'dateo'), 'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'), - 'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture') + 'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'), + 'expense_report'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 4=>'date_approve', 5=>'date_refuse', 6=>'date_cancel'), + 'leave'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel') ); $year=2010; @@ -77,14 +81,15 @@ $currentyear=$tmp['year']; while ($year <= $currentyear) { //$year=2021; - $delta=($currentyear - $year); + $delta1=($currentyear - $year); + $delta2=($currentyear - $year - 1); //$delta=-1; - if ($delta) + if ($delta1) { foreach($tables as $tablekey => $tableval) { - print "\nCorrect ".$tablekey." for year ".$year." and move them to current year ".$currentyear." "; + print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." "; $sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)"; //$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()"; $resql = $db->query($sql); @@ -103,7 +108,7 @@ while ($year <= $currentyear) foreach($tableval as $field) { if ($j) $sql2.=", "; - $sql2.= $field." = DATE_ADD(".$field.", INTERVAL ".$delta." YEAR)"; + $sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)"); $j++; } $sql2.=" WHERE rowid = ".$obj->rowid; @@ -115,6 +120,7 @@ while ($year <= $currentyear) } } else dol_print_error($db); + print "\n"; } } diff --git a/dev/resources/licence/Links on GPL.txt b/dev/resources/licence/Links on GPL.txt index bb9c1597f68..0fb3b63c851 100644 --- a/dev/resources/licence/Links on GPL.txt +++ b/dev/resources/licence/Links on GPL.txt @@ -1,7 +1,7 @@ -* Page with licence compatibility +* Page with license compatibility https://www.gnu.org/licenses/quick-guide-gplv3.fr.html -* FAQ on GPL licence +* FAQ on GPL license https://www.fsf.org/licensing/licenses/gpl-faq.html * Questions/Answers on Fork for using Dolibarr as a SaaS diff --git a/dev/resources/sepa/text.txt b/dev/resources/sepa/text.txt index 0a5336a128e..e6c05276be2 100644 --- a/dev/resources/sepa/text.txt +++ b/dev/resources/sepa/text.txt @@ -1,2 +1,2 @@ -To test a SEPA file: -http://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa \ No newline at end of file +To test a SEPA file: +https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa diff --git a/dev/setup/eclipse/PSR-12 [built-in].xml b/dev/setup/eclipse/PSR-12 [built-in].xml new file mode 100644 index 00000000000..47925209682 --- /dev/null +++ b/dev/setup/eclipse/PSR-12 [built-in].xml @@ -0,0 +1,215 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/translation/README b/dev/translation/README index b470e4228d8..9727f91e2e6 100644 --- a/dev/translation/README +++ b/dev/translation/README @@ -3,11 +3,12 @@ README (English) This directory contains tools to generate translation files for a new languages or to update translation files for existing languages. See Dolibarr Wiki page: -http://wiki.dolibarr.org/index.php/Translator_documentation +https://wiki.dolibarr.org/index.php/Translator_documentation For more information on how to use them. +for Linux OS: To install transifex client: sudo pip install --upgrade transifex-client To update transifex client: -sudo pip install --upgrade transifex-client \ No newline at end of file +sudo pip install --upgrade transifex-client diff --git a/dev/translation/erp_comparison_translation.txt b/dev/translation/erp_comparison_translation.txt index c99a5f4cc1c..6cf7c4f7c60 100644 --- a/dev/translation/erp_comparison_translation.txt +++ b/dev/translation/erp_comparison_translation.txt @@ -1,17 +1,25 @@ +comparison of terms -Term Dolibarr SAP Odoo ... ----------------------------------------------------------------------------- -Thirdparty Contact partner Partner/Contact (company) -Contact/address Contact person Partner/Contact (individual) +Dolibarr SAP ERP Odoo +------------------------------------------------------------------------- +Thirdparty Contact partner Partner/Contact (company) +Contact/address Contact person Partner/Contact (individual) -Financial ?? Invoicing - -Income / Expense ?? Profit / Loss -Balance ?? Net profit -Subledger account Subledger account ?? +Financial Finance (FI) Accounting +Accounting -Proposal ?? Quotation Proposal is ok but proposition looks better (proposal is for a detailed proposition). We can say also "business proposition or business proposal". - Indian are using "Quotation". +Income / Expense ?? Profit / Loss +Balance ?? Net profit +Subledger account Subledger account ?? + +CRM Sales & Distribution Sales +Proposal ?? Quotation + + + +Proposal is ok but proposition looks better (proposal is for a detailed proposition). +We can say also "business proposition or business proposal". +In India they are using "Quotation". diff --git a/dev/translation/txpull.sh b/dev/translation/txpull.sh index 3f24bd0912d..fcccae98221 100755 --- a/dev/translation/txpull.sh +++ b/dev/translation/txpull.sh @@ -54,5 +54,5 @@ fi echo Think to launch also: echo "> dev/tools/fixaltlanguages.sh fix all" -echo "For v11: Replace also regex \(.*(sponge|cornas|eratosthene|cyan).*\) with ''" +echo "For v11: Replace also regex \(.*(sponge|cornas|eratosthene|cyan).*\) with '' on *.lang files" diff --git a/doc/images/README.md b/doc/images/README.md index 798cf599b4c..7422d246d40 100644 --- a/doc/images/README.md +++ b/doc/images/README.md @@ -10,7 +10,11 @@ https://github.com/Dolibarr/foundation -* Few icons are from http://led24.de/iconset/. This is original README file for this source: +* Few icons are / were from website led24.de + +* Attention: This website is no longer available! + +This is original README file for this source: ------------------------------------------------------- You can do whatever you want with these icons (use on web or in desktop applications) as long as you don’t pass them off as your own and remove this readme file. A credit statement and a link back to http://led24.de/iconset/ or http://led24.de/ would be appreciated. diff --git a/doc/user/README-DE.md b/doc/user/README-DE.md new file mode 100644 index 00000000000..ea9458f4563 --- /dev/null +++ b/doc/user/README-DE.md @@ -0,0 +1,12 @@ +README (german) +LiesMich (deutsch) + +-------------------------------- +Benutzeranleitung +-------------------------------- + +Alle Dolibarr-Informationen sind online verfuegbar ueber die Webseiten: +https://www.dolibarr.de +oder +https://www.dolibarr.org +https://wiki.dolibarr.org diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 9de858da26b..1afe2ecca18 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -45,7 +45,8 @@ $search_label = GETPOST('search_label', 'alpha'); $search_labelshort = GETPOST('search_labelshort', 'alpha'); $search_accountparent = GETPOST('search_accountparent', 'alpha'); $search_pcgtype = GETPOST('search_pcgtype', 'alpha'); -$search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha'); + +$chartofaccounts = GETPOST('chartofaccounts', 'int'); // Security check if ($user->socid > 0) accessforbidden(); @@ -55,7 +56,7 @@ if (!$user->rights->accounting->chartofaccount) accessforbidden(); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -69,10 +70,12 @@ $arrayfields = array( 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), - 'aa.pcg_subtype'=>array('label'=>$langs->trans("Pcgsubtype"), 'checked'=>0, 'help'=>'PcgtypeDesc'), + 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) ); +if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']); + $accounting = new AccountingAccount($db); @@ -101,14 +104,11 @@ if (empty($reshook)) $search_labelshort = ""; $search_accountparent = ""; $search_pcgtype = ""; - $search_pcgsubtype = ""; $search_array_options = array(); } - - if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax))) + if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on + || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified { - $chartofaccounts = GETPOST('chartofaccounts', 'int'); - if ($chartofaccounts > 0) { // Get language code for this $chartofaccounts @@ -160,7 +160,8 @@ if (empty($reshook)) if ($action == 'disable') { if ($accounting->fetch($id)) { - $result = $accounting->account_desactivate($id); + $mode = GETPOST('mode', 'int'); + $result = $accounting->account_desactivate($id, $mode); } $action = 'update'; @@ -169,7 +170,8 @@ if (empty($reshook)) } } elseif ($action == 'enable') { if ($accounting->fetch($id)) { - $result = $accounting->account_activate($id); + $mode = GETPOST('mode', 'int'); + $result = $accounting->account_activate($id, $mode); } $action = 'update'; if ($result < 0) { @@ -195,7 +197,7 @@ if ($action == 'delete') { $pcgver = $conf->global->CHARTOFACCOUNTS; -$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.pcg_subtype, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.active, "; +$sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconcilable, aa.active, "; $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity; @@ -241,7 +243,6 @@ if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_la if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2); if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); -if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype); $sql .= $db->order($sortfield, $sortorder); // Count total nb of records @@ -274,23 +275,17 @@ if ($resql) if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort); if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); - if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); - if ($optioncss != '') $param .= '&optioncss='.$optioncss; + if ($optioncss != '') $param .= '&optioncss='.$optioncss; if (!empty($conf->use_javascript_ajax)) { - print ' + print ' '; @@ -337,8 +332,7 @@ if ($resql) else dol_print_error($db); print ""; print ajax_combobox("chartofaccounts"); - print ''; - print ''; + print ''; print '
'; print '
'; @@ -363,7 +357,7 @@ if ($resql) print ''; } if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; - if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print ' '; } if (!empty($arrayfields['aa.active']['checked'])) print ' '; print ''; $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); @@ -377,7 +371,7 @@ if ($resql) if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']); - if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_subtype']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_subtype', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_subtype']['help']); + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (! empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); } if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -454,25 +448,36 @@ if ($resql) if (!$i) $totalarray['nbfield']++; } - // Chart of accounts subtype - if (!empty($arrayfields['aa.pcg_subtype']['checked'])) - { - print ""; - print $obj->pcg_subtype; - print "\n"; - if (!$i) $totalarray['nbfield']++; + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { + // Activated or not reconciliation on accounting account + if (!empty($arrayfields['aa.reconcilable']['checked'])) { + print ''; + if (empty($obj->reconcilable)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } } // Activated or not if (!empty($arrayfields['aa.active']['checked'])) { - print ''; + print ''; if (empty($obj->active)) { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 2ed3ad44695..0ab42d582d1 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -61,7 +61,7 @@ $active = 1; $sortfield = GETPOST("sortfield", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page; $pageprev = $page - 1; diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index f2bc1907c7c..7449750f958 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -92,7 +92,6 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->fk_pcg_version = $obj->pcg_version; $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->pcg_subtype = GETPOST('pcg_subtype', 'alpha'); $object->account_number = $account_number; $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category', 'alpha'); @@ -158,7 +157,6 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount) $object->fk_pcg_version = $obj->pcg_version; $object->pcg_type = GETPOST('pcg_type', 'alpha'); - $object->pcg_subtype = GETPOST('pcg_subtype', 'alpha'); $object->account_number = $account_number; $object->account_parent = $account_parent; $object->account_category = GETPOST('account_category', 'alpha'); @@ -260,12 +258,6 @@ if ($action == 'create') { print ''; print ''; - // Chart of accounts subtype - print ''.$langs->trans("Pcgsubtype").''; - print ''; - print ''; - print ''; - print ''; dol_fiche_end(); @@ -329,12 +321,6 @@ elseif ($id > 0 || $ref) { print ''; print ''; - // Chart of accounts subtype - print ''.$langs->trans("Pcgsubtype").''; - print ''; - print ''; - print ''; - print ''; dol_fiche_end(); @@ -383,10 +369,6 @@ elseif ($id > 0 || $ref) { print ''.$langs->trans("Pcgtype").''; print ''.$object->pcg_type.''; - // Chart of accounts subtype - print ''.$langs->trans("Pcgsubtype").''; - print ''.$object->pcg_subtype.''; - print ''; print ''; diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index f04f17c6e8c..500a0d3cbba 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -56,7 +56,7 @@ $active = 1; $sortfield = GETPOST("sortfield", 'aZ09comma'); $sortorder = GETPOST("sortorder", 'aZ09comma'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $listlimit * $page; $pageprev = $page - 1; @@ -677,9 +677,6 @@ if ($id) } if ($fieldlist[$field] == 'pcg_type') { $valuetoshow = $langs->trans("Pcg_type"); - } - if ($fieldlist[$field] == 'pcg_subtype') { - $valuetoshow = $langs->trans("Pcg_subtype"); } if ($fieldlist[$field] == 'type_template') { $valuetoshow = $langs->trans("TypeOfTemplate"); diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 611aa8fc321..ad22a88f415 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2019 Alexandre Spangaro + * Copyright (C) 2013-2020 Alexandre Spangaro * Copyright (C) 2014-2015 Ari Elbaz (elarifr) * Copyright (C) 2014 Marcos García * Copyright (C) 2014 Juanjo Menent @@ -46,27 +46,35 @@ if (empty($user->rights->accounting->chartofaccount)) $action = GETPOST('action', 'aZ09'); -$list_account_main = array ( +$list_account_main = array( 'ACCOUNTING_ACCOUNT_CUSTOMER', 'ACCOUNTING_ACCOUNT_SUPPLIER', 'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', ); -$list_account = array (); +$list_account = array(); $list_account[] = '---Product---'; -$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Service---'; -$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_SERVICE_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Other---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; @@ -112,25 +120,25 @@ if ($action == 'update') { foreach ($list_account_main as $constname) { $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } foreach ($list_account as $constname) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $constname, $reg)) { // This is a separator continue; } $constvalue = GETPOST($constname, 'alpha'); - if (! dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error ++; + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; } } - if (! $error) { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -161,6 +169,7 @@ print ''; // Define main accounts for thirdparty print ''; +print ''; foreach ($list_account_main as $key) { print ''; @@ -180,17 +189,8 @@ foreach ($list_account_main as $key) { } -print "
'.$langs->trans("ThirdParties").' | '.$langs->trans("Users").'
\n"; - - -print '
'; - -// Define default accounts - -print ''; - foreach ($list_account as $key) { - $reg=array(); + $reg = array(); if (preg_match('/---(.*)---/', $key, $reg)) { print ''; } @@ -198,9 +198,9 @@ foreach ($list_account as $key) { print ''; // Param $label = $langs->trans($key); - print ''; + print ''; // Value - print ''; print ''; diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index edc73688389..b2262c603f9 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -134,13 +134,13 @@ if ($action == 'update') { $form = new Form($db); -$title = $langs->trans('ConfigAccountingExpert'); +$title = $langs->trans('ExportOptions'); llxHeader('', $title); $linkback = ''; // $linkback = '' . $langs->trans("BackToModuleList") . ''; -print load_fiche_titre($langs->trans('ConfigAccountingExpert'), $linkback, 'accountancy'); +print load_fiche_titre($langs->trans('ExportOptions'), $linkback, 'accountancy'); print "\n".''."\n"; + print ''."\n"; } diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 96c00f48312..78b82f42b82 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -1,7 +1,8 @@ - * Copyright (C) 2015 Frederic France - * Copyright (C) 2016 Juanjo Menent +/* Copyright (C) 2013-2016 Laurent Destailleur + * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juanjo Menent + * Copyright (C) 2020 Andreu Bisquerra Gaya * * 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 @@ -355,7 +356,7 @@ if ($mode == 'config' && $user->admin) { print ''; print ''; print ''; - //print ''; + print ''; print '
'.$langs->trans($reg[1]).'
' . $label . ''.$label.''; // Do not force class=right, or it align also the content of the select box + print ''; // Do not force class=right, or it align also the content of the select box print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print '
'.$langs->trans("CONNECTOR_NETWORK_PRINT").':'.$langs->trans("CONNECTOR_NETWORK_PRINT_HELP").'
'.$langs->trans("CONNECTOR_FILE_PRINT").':'.$langs->trans("CONNECTOR_FILE_PRINT_HELP").'
'.$langs->trans("CONNECTOR_WINDOWS_PRINT").':'.$langs->trans("CONNECTOR_WINDOWS_PRINT_HELP").'
'.$langs->trans("CONNECTOR_JAVA").':'.$langs->trans("CONNECTOR_JAVA_HELP").'
'.$langs->trans("CONNECTOR_CUPS_PRINT").':'.$langs->trans("CONNECTOR_CUPS_PRINT_HELP").'
'; dol_fiche_end(); diff --git a/htdocs/admin/reception_extrafields.php b/htdocs/admin/reception_extrafields.php index 454fe1c4a8f..95338903ade 100644 --- a/htdocs/admin/reception_extrafields.php +++ b/htdocs/admin/reception_extrafields.php @@ -89,9 +89,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -103,10 +103,10 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
"; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -116,10 +116,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } llxFooter(); diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index 462326316b2..b64c01c5f00 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -35,7 +35,7 @@ $langs->loadLangs(array("admin","resource")); // Security check if (!$user->admin) - accessforbidden(); + accessforbidden(); $action = GETPOST('action', 'alpha'); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index f1cbea504d3..0b6987b1a9f 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -213,7 +213,7 @@ $found=0; print ''; print ''.$langs->trans("ReStockOnBill").''; print ''; -if (! empty($conf->fournisseur->enabled)) +if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL'); @@ -234,7 +234,7 @@ $found++; print ''; print ''.$langs->trans("ReStockOnValidateOrder").''; print ''; -if (! empty($conf->fournisseur->enabled)) +if (! empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || ! empty($conf->supplier_order->enabled) || ! empty($conf->supplier_invoice->enabled)) { if ($conf->use_javascript_ajax) { print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'); diff --git a/htdocs/admin/supplierinvoicedet_extrafields.php b/htdocs/admin/supplierinvoicedet_extrafields.php index bcb3b5769ee..39a757bbf9c 100644 --- a/htdocs/admin/supplierinvoicedet_extrafields.php +++ b/htdocs/admin/supplierinvoicedet_extrafields.php @@ -86,9 +86,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -101,9 +101,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -113,10 +113,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/supplierorder_extrafields.php b/htdocs/admin/supplierorder_extrafields.php index 78c31291414..8924741df52 100644 --- a/htdocs/admin/supplierorder_extrafields.php +++ b/htdocs/admin/supplierorder_extrafields.php @@ -84,9 +84,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
'; - print "".$langs->trans("NewAttribute").""; - print "
"; + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; } @@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -111,10 +111,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index 64f8fba72ad..3cfc18accc9 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -86,31 +86,31 @@ print ''; if (preg_match('/^fr_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("France")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("France")).''; print '
  • '; } if (preg_match('/^el_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Greece")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Greece")).''; print '
  • '; } if (preg_match('/^es_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Spain")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Spain")).''; print '
  • '; } if (preg_match('/^it_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Italy")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Italy")).''; print '
  • '; } if (preg_match('/^de_/i', $langs->getDefaultLang())) { print '
  • '; - print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Germany")).''; + print ''.$langs->trans("OfficialWebSiteLocal", $langs->transnoentitiesnoconv("Germany")).''; print '
  • '; } print '
  • '; diff --git a/htdocs/admin/system/constall.php b/htdocs/admin/system/constall.php index 194c871958d..0835138227b 100644 --- a/htdocs/admin/system/constall.php +++ b/htdocs/admin/system/constall.php @@ -70,27 +70,27 @@ $configfileparameters=array( '?dolibarr_main_auth_ldap_admin_login', '?dolibarr_main_auth_ldap_admin_pass', '?dolibarr_main_auth_ldap_debug', - 'separator', - '?dolibarr_lib_ADODB_PATH', + 'separator', + '?dolibarr_lib_ADODB_PATH', '?dolibarr_lib_FPDF_PATH', - '?dolibarr_lib_TCPDF_PATH', + '?dolibarr_lib_TCPDF_PATH', '?dolibarr_lib_FPDI_PATH', - '?dolibarr_lib_TCPDI_PATH', + '?dolibarr_lib_TCPDI_PATH', '?dolibarr_lib_NUSOAP_PATH', - '?dolibarr_lib_PHPEXCEL_PATH', - '?dolibarr_lib_GEOIP_PATH', + '?dolibarr_lib_PHPEXCEL_PATH', + '?dolibarr_lib_GEOIP_PATH', '?dolibarr_lib_ODTPHP_PATH', - '?dolibarr_lib_ODTPHP_PATHTOPCLZIP', - '?dolibarr_js_CKEDITOR', - '?dolibarr_js_JQUERY', - '?dolibarr_js_JQUERY_UI', - '?dolibarr_js_JQUERY_FLOT', + '?dolibarr_lib_ODTPHP_PATHTOPCLZIP', + '?dolibarr_js_CKEDITOR', + '?dolibarr_js_JQUERY', + '?dolibarr_js_JQUERY_UI', + '?dolibarr_js_JQUERY_FLOT', '?dolibarr_font_DOL_DEFAULT_TTF', - '?dolibarr_font_DOL_DEFAULT_TTF_BOLD', + '?dolibarr_font_DOL_DEFAULT_TTF_BOLD', 'separator', '?dolibarr_mailing_limit_sendbyweb', '?dolibarr_mailing_limit_sendbycli', - '?dolibarr_strict_mode' + '?dolibarr_strict_mode' ); $configfilelib=array( // 'separator', @@ -121,20 +121,20 @@ $configfilelib=array( 'dolibarr_main_auth_ldap_admin_pass', 'dolibarr_main_auth_ldap_debug', 'separator', - 'dolibarr_lib_ADODB_PATH', - 'dolibarr_lib_TCPDF_PATH', - 'dolibarr_lib_FPDI_PATH', + 'dolibarr_lib_ADODB_PATH', + 'dolibarr_lib_TCPDF_PATH', + 'dolibarr_lib_FPDI_PATH', 'dolibarr_lib_NUSOAP_PATH', - 'dolibarr_lib_PHPEXCEL_PATH', - 'dolibarr_lib_GEOIP_PATH', + 'dolibarr_lib_PHPEXCEL_PATH', + 'dolibarr_lib_GEOIP_PATH', 'dolibarr_lib_ODTPHP_PATH', - 'dolibarr_lib_ODTPHP_PATHTOPCLZIP', - 'dolibarr_js_CKEDITOR', - 'dolibarr_js_JQUERY', - 'dolibarr_js_JQUERY_UI', - 'dolibarr_js_JQUERY_FLOT', + 'dolibarr_lib_ODTPHP_PATHTOPCLZIP', + 'dolibarr_js_CKEDITOR', + 'dolibarr_js_JQUERY', + 'dolibarr_js_JQUERY_UI', + 'dolibarr_js_JQUERY_FLOT', 'dolibarr_font_DOL_DEFAULT_TTF', - 'dolibarr_font_DOL_DEFAULT_TTF_BOLD', + 'dolibarr_font_DOL_DEFAULT_TTF_BOLD', 'separator', 'Limit nb of email sent by page', 'Strict mode is on/off' @@ -155,19 +155,19 @@ foreach($configfileparameters as $key) if (empty($ignore)) { - $newkey = preg_replace('/^\?/', '', $key); + $newkey = preg_replace('/^\?/', '', $key); - if (preg_match('/^\?/', $key) && empty(${$newkey})) - { - $i++; - continue; // We discard parametes starting with ? - } + if (preg_match('/^\?/', $key) && empty(${$newkey})) + { + $i++; + continue; // We discard parametes starting with ? + } - if ($newkey == 'separator' && $lastkeyshown == 'separator') - { - $i++; - continue; - } + if ($newkey == 'separator' && $lastkeyshown == 'separator') + { + $i++; + continue; + } print ''; if ($newkey == 'separator') @@ -233,17 +233,17 @@ if ($resql) $i = 0; while ($i < $num) - { - $obj = $db->fetch_object($resql); + { + $obj = $db->fetch_object($resql); - print ''; - print ''.$obj->name.''."\n"; - print ''.$obj->value.''."\n"; - if (empty($conf->multicompany->enabled) || !$user->entity) print ''.$obj->entity.''."\n"; // If superadmin or multicompany disabled - print "\n"; + print ''; + print ''.$obj->name.''."\n"; + print ''.$obj->value.''."\n"; + if (empty($conf->multicompany->enabled) || !$user->entity) print ''.$obj->entity.''."\n"; // If superadmin or multicompany disabled + print "\n"; - $i++; - } + $i++; + } } print ''; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 7a53b95fcf2..dce23de6270 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -54,17 +54,17 @@ $i=0; foreach($modulesdir as $dir) { $handle=@opendir(dol_osencode($dir)); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') - { - $modName = substr($file, 0, dol_strlen($file) - 10); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); - if ($modName) - { - //print 'xx'.$dir.$file.'
    '; + if ($modName) + { + //print 'xx'.$dir.$file.'
    '; if (in_array($file, $modules_files)) { // File duplicate @@ -77,13 +77,13 @@ foreach($modulesdir as $dir) if (class_exists($modName)) { try { - $objMod = new $modName($db); + $objMod = new $modName($db); - $modules[$objMod->numero]=$objMod; - $modules_names[$objMod->numero]=$objMod->name; - $modules_files[$objMod->numero]=$file; - $modules_fullpath[$file]=$dir.$file; - $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; + $modules[$objMod->numero]=$objMod; + $modules_names[$objMod->numero]=$objMod->name; + $modules_files[$objMod->numero]=$file; + $modules_fullpath[$file]=$dir.$file; + $picto[$objMod->numero]=(isset($objMod->picto) && $objMod->picto)?$objMod->picto:'generic'; } catch(Exception $e) { @@ -95,11 +95,11 @@ foreach($modulesdir as $dir) print "Warning bad descriptor file : ".$dir.$file." (Class ".$modName." not found into file)
    "; } } - } - } - } - closedir($handle); - } + } + } + } + closedir($handle); + } } print '
    '; @@ -120,15 +120,15 @@ foreach($sortorder as $numero=>$name) // Module print ''; $alt=$name.' - '.$modules_files[$numero]; - if (! empty($picto[$numero])) - { - if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1); - else print img_object($alt, $picto[$numero], 'width="14px"'); - } - else - { - print img_object($alt, $picto[$numero], 'width="14px"'); - } + if (! empty($picto[$numero])) + { + if (preg_match('/^\//', $picto[$numero])) print img_picto($alt, $picto[$numero], 'width="14px"', 1); + else print img_object($alt, $picto[$numero], 'width="14px"'); + } + else + { + print img_object($alt, $picto[$numero], 'width="14px"'); + } print ' '.$modules[$numero]->getName(); print ""; // Version diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 3dae3c91f9d..42c66281450 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -53,10 +53,10 @@ print $langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index // Recupere la version de PHP $phpversion=version_php(); -print "
    PHP - ".$langs->trans("Version").": ".$phpversion."
    \n"; +print "
    PHP - ".$langs->trans("Version").": ".$phpversion."
    \n"; // Recupere la version du serveur web -print "
    Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."
    \n"; +print "
    Web server - ".$langs->trans("Version").": ".$_SERVER["SERVER_SOFTWARE"]."
    \n"; // XDebug print '
    '; @@ -65,8 +65,8 @@ $test=!function_exists('xdebug_is_enabled'); if ($test) print img_picto('', 'tick.png').' '.$langs->trans("NotInstalled"); else { - print img_picto('', 'warning').' '.$langs->trans("XDebugInstalled"); - print ' '.$langs->trans("MoreInformation").' XDebug admin page'; + print img_picto('', 'warning').' '.$langs->trans("ModuleActivated", $langs->transnoentities("XDebug")); + print ' - '.$langs->trans("MoreInformation").' XDebug admin page'; } print '
    '; diff --git a/htdocs/admin/system/xdebug.php b/htdocs/admin/system/xdebug.php index 56b452706f5..9ea68431b1a 100644 --- a/htdocs/admin/system/xdebug.php +++ b/htdocs/admin/system/xdebug.php @@ -41,54 +41,54 @@ print "
    \n"; if (!function_exists('xdebug_is_enabled')) { - print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.'; - llxFooter(); - exit; + print 'XDebug seems to be not installed. Function xdebug_is_enabled not found.'; + llxFooter(); + exit; } if (function_exists('socket_create')) { - $address = ini_get('xdebug.remote_host')?ini_get('xdebug.remote_host'):'127.0.0.1'; - $port = ini_get('xdebug.remote_port')?ini_get('xdebug.remote_port'):9000; + $address = ini_get('xdebug.remote_host')?ini_get('xdebug.remote_host'):'127.0.0.1'; + $port = ini_get('xdebug.remote_port')?ini_get('xdebug.remote_port'):9000; - print "Current xdebug setup:
    \n"; - print "* Remote debug setup:
    \n"; - print 'xdebug.remote_enable = '.ini_get('xdebug.remote_enable')."
    \n"; - print 'xdebug.remote_host = '.$address."
    \n"; - print 'xdebug.remote_port = '.$port."
    \n"; - print "* Profiler setup "; - if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename()?"(currently on into file ".xdebug_get_profiler_filename().")":"(currently off)"; - else print "(currenlty not available)"; - print ":
    \n"; - print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."
    \n"; - print 'xdebug.profiler_enable_trigger = '.ini_get('xdebug.profiler_enable_trigger')."
    \n"; - print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."
    \n"; - print 'xdebug.profiler_output_name = '.ini_get('xdebug.profiler_output_name')."
    \n"; - print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."
    \n"; - print "
    \n"; + print "Current xdebug setup:
    \n"; + print "* Remote debug setup:
    \n"; + print 'xdebug.remote_enable = '.ini_get('xdebug.remote_enable')."
    \n"; + print 'xdebug.remote_host = '.$address."
    \n"; + print 'xdebug.remote_port = '.$port."
    \n"; + print "* Profiler setup "; + if (function_exists('xdebug_get_profiler_filename')) print xdebug_get_profiler_filename()?"(currently on into file ".xdebug_get_profiler_filename().")":"(currently off)"; + else print "(currenlty not available)"; + print ":
    \n"; + print 'xdebug.profiler_enable = '.ini_get('xdebug.profiler_enable')."
    \n"; + print 'xdebug.profiler_enable_trigger = '.ini_get('xdebug.profiler_enable_trigger')."
    \n"; + print 'xdebug.profiler_output_dir = '.ini_get('xdebug.profiler_output_dir')."
    \n"; + print 'xdebug.profiler_output_name = '.ini_get('xdebug.profiler_output_name')."
    \n"; + print 'xdebug.profiler_append = '.ini_get('xdebug.profiler_append')."
    \n"; + print "
    \n"; - echo "To run a debug session, add parameter
    "; - echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; - echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; - echo "* XDEBUG_PROFILE=aname on each URL.
    "; - print "
    "; + echo "To run a debug session, add parameter
    "; + echo "* XDEBUG_SESSION_START=aname on your URL. To stop, remove cookie XDEBUG_SESSION_START.
    \n"; + echo "To run a profiler session (when xdebug.profiler_enable_trigger=1), add parameter
    \n"; + echo "* XDEBUG_PROFILE=aname on each URL.
    "; + print "
    "; - print "Test debugger server (Eclipse for example):
    \n"; - $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); - if (empty($socket)) die('Unable to prepare a socket'); - //socket_bind($sock, $address, $port) or die('Unable to bind on address='.$address.' port='.$port); - //socket_listen($sock); - //$client = socket_accept($sock); - $client=socket_connect($socket, $address, $port); - if ($client) - { - echo "Connection established: ".$client." - address=".$address." port=".$port."
    \n"; - echo "There is a Remote debug server at this address.
    \n"; - echo "
    \n"; - echo "To be sure this debugger accepts input from your PHP server and xdebug, be sure to have\n"; - echo "your php.ini file with this :
    \n"; - echo '\n"; - print "

    \n"; - echo 'Then check in your debug server (Eclipse), you have setup:
    + print "

    \n"; + echo 'Then check in your debug server (Eclipse), you have setup:
    XDebug with same port than in php.ini
    Allow Remote debug=yes or prompt
    '."\n"; - print "
    \n"; - } - else - { - print socket_strerror(socket_last_error()); - echo "Failed to connect to address=".$address." port=".$port."
    \n"; - echo "There is no Remote debug server at this address.\n"; - } - socket_close($socket); + print "
    \n"; + } + else + { + print socket_strerror(socket_last_error()); + echo "Failed to connect to address=".$address." port=".$port."
    \n"; + echo "There is no Remote debug server at this address.\n"; + } + socket_close($socket); } else { - print "Can't test if PHPDebug is OK as PHP socket functions are not enabled."; + print "Can't test if PHPDebug is OK as PHP socket functions are not enabled."; } diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index dba1f827748..cd982ef0f5c 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -197,6 +197,7 @@ dol_fiche_end(); print load_fiche_titre($langs->trans("TicketNumberingModules")); +print '
    '; print ''; print ''; print ''; @@ -287,7 +288,9 @@ foreach ($dirmodels as $reldir) { } } -print '
    '.$langs->trans("Name").'

    '; +print ''; +print '
    '; +print '
    '; if (!$conf->use_javascript_ajax) { print '
    '; diff --git a/htdocs/admin/ticket_extrafields.php b/htdocs/admin/ticket_extrafields.php index 18d5eee40a6..d7be1d058e6 100644 --- a/htdocs/admin/ticket_extrafields.php +++ b/htdocs/admin/ticket_extrafields.php @@ -36,7 +36,7 @@ $form = new Form($db); $tmptype2label = ExtraFields::$type2label; $type2label = array(''); foreach ($tmptype2label as $key => $val) { - $type2label[$key] = $langs->trans($val); + $type2label[$key] = $langs->trans($val); } $action = GETPOST('action', 'alpha'); @@ -44,7 +44,7 @@ $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'ticket'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) { - accessforbidden(); + accessforbidden(); } @@ -79,9 +79,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '"; + print '"; } /* ************************************************************************** */ @@ -91,10 +91,10 @@ if ($action != 'create' && $action != 'edit') { /* ************************************************************************** */ if ($action == 'create') { - print "
    "; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); - include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php'; + include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -103,10 +103,10 @@ if ($action == 'create') { /* */ /* ************************************************************************** */ if ($action == 'edit' && !empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; + include DOL_DOCUMENT_ROOT . '/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index a4098e52247..6b8a23c94fc 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -167,7 +167,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); -print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; +print ''.$langs->trans("TicketPublicAccess").' : '.dol_buildpath('/public/ticket/index.php', 2).''; dol_fiche_end(); @@ -176,14 +176,14 @@ $enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Button off, click to enable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); $enabledisablehtml .= ''; } else { // Button on, click to disable - $enabledisablehtml .= ''; + $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on'); $enabledisablehtml .= ''; } @@ -200,6 +200,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print ''; } + print '
    '; print ''; print ''; print ''; } - print '
    '.$langs->trans("Parameters").''; @@ -279,7 +280,9 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print '

    '; + print ''; + print '
    '; + print '
    '; if (!$conf->use_javascript_ajax) { print '
    '; @@ -288,6 +291,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) // Admin var of module print load_fiche_titre($langs->trans("TicketParamMail")); + print '
    '; print ''; print ''; @@ -369,13 +373,14 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; print ''; + print ''; print ''; print ''; print '
    '.$langs->trans("TicketUrlPublicInterfaceLabelAdmin").''; print ''; - print ''; print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); print '
    '; + print '
    '; print '
    '; diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 854fd130bc5..05546fdee5a 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -33,7 +33,7 @@ $action = GETPOST('action', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "date"; if (empty($page) || $page == -1) { $page = 0; } diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index e05e4fc143d..f2e423d9174 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -39,7 +39,7 @@ $file=GETPOST('filename_template', 'alpha'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; if (! $sortorder) $sortorder="DESC"; diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index c1c641b82f2..dec8da6aa53 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -41,7 +41,7 @@ $file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="date"; if ($page < 0) { $page = 0; } diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 52717200bce..f57a16332df 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -48,7 +48,7 @@ $langs->loadLangs(array("companies", "admin", "users", "other")); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index d909dc8610b..de526b725da 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -43,7 +43,7 @@ if ($user->socid > 0) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; @@ -167,7 +167,7 @@ if ($savehandler == 'files') if (count($listofsessions) == 0) { - print ''.$langs->trans("NoSessionFound", $savepath, $openbasedir).''; + print ''.$langs->trans("NoSessionFound", $savepath, $openbasedir).''; } print ""; } diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index 664cda18916..6d1f40ec4a0 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -54,9 +54,9 @@ $version='0.0'; if ($action == 'getlastversion') { - $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); - //var_dump($result['content']); - $sfurl = simplexml_load_string($result['content']); + $result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); + //var_dump($result['content']); + $sfurl = simplexml_load_string($result['content']); } @@ -75,39 +75,39 @@ print $langs->trans("CurrentVersion").' : '.DOL_VERSION.'
    '; if (function_exists('curl_init')) { - $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; + $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - if ($action == 'getlastversion') - { - if ($sfurl) - { - $i=0; - while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { - $title=$sfurl->channel[0]->item[$i]->title; - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) - { - $newversion=$reg[1]; - $newversionarray=explode('.', $newversion); - $versionarray=explode('.', $version); - //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion; - } - $i++; - } + if ($action == 'getlastversion') + { + if ($sfurl) + { + $i=0; + while (! empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) + { + $title=$sfurl->channel[0]->item[$i]->title; + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) + { + $newversion=$reg[1]; + $newversionarray=explode('.', $newversion); + $versionarray=explode('.', $version); + //var_dump($newversionarray);var_dump($versionarray); + if (versioncompare($newversionarray, $versionarray) > 0) $version=$newversion; + } + $i++; + } - // Show version - print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .'
    '; - } - else - { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").'
    '; - } - } - else - { - print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").'
    '; - } + // Show version + print $langs->trans("LastStableVersion").' : '. (($version != '0.0')?$version:$langs->trans("Unknown")) .'
    '; + } + else + { + print $langs->trans("LastStableVersion").' : ' .$langs->trans("UpdateServerOffline").'
    '; + } + } + else + { + print $langs->trans("LastStableVersion").' : ' .$langs->trans("Check").'
    '; + } } print '
    '; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index c641be11a59..cad874d89b2 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -45,7 +45,7 @@ $mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite'; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index 56602502715..fb15a57a87e 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -147,13 +147,13 @@ dol_fiche_head($head, 'card', $langs->trans("MenuUsersAndGroups"), -1, 'user'); print ''; print ''; -print ''; +print ''; print ''; print ''."\n"; print ''; -// Mail required for members +// Mail required for users print ''; print ''; @@ -206,6 +206,8 @@ else dol_print_error($db); } +print load_fiche_titre($langs->trans("UsersDocModules"), '', ''); + print '
    '.$langs->trans("Description").''.$langs->trans("Parameter").' '.$langs->trans("Value").'
    '.$langs->trans("UserMailRequired").'
    '; print ''; print ''; diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 43910bedb56..4f556ff19b3 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -152,6 +152,8 @@ else dol_print_error($db); } +print load_fiche_titre($langs->trans("GroupsDocModules"), '', ''); + print '
    '.$langs->trans("Name").'
    '; print ''; print ''; diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 2d201421f20..dd7fd353ea2 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -55,7 +55,7 @@ $status = 1; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index 92c16a1123e..7d16aa3963b 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -48,7 +48,7 @@ $status = 1; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 45cf082763e..73041f6c386 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -130,7 +130,9 @@ print ''; print ''; print ''; -print ''; +print ''; print ''; print ''; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 891c3969f81..e58ebf7d280 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -80,7 +80,18 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity = $conf->entity; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* + $tmpreldir = ''; + if ($modulepart == 'supplier_invoice') { + $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); + } + + $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ + $relativefile = $original_file; + + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -146,7 +157,18 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity = $conf->entity; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* + $tmpreldir = ''; + if ($modulepart == 'supplier_invoice') { + $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); + } + + $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ + $relativefile = $original_file; + + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; @@ -228,7 +250,7 @@ class Documents extends DolibarrApi /** * Return the list of documents of a dedicated element (from its ID or Ref) * - * @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'shipment', 'project', ...) + * @param string $modulepart Name of module or area concerned ('thirdparty', 'member', 'proposal', 'order', 'invoice', 'supplier_invoice', 'shipment', 'project', ...) * @param int $id ID of element * @param string $ref Ref of element * @param string $sortfield Sort criteria ('','fullname','relativename','name','date','size') @@ -369,6 +391,24 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); } + elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') + { + $modulepart = 'supplier_invoice'; + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + + if (!DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { + throw new RestException(401); + } + + $object = new FactureFournisseur($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Invoice not found'); + } + + $upload_dir = $conf->fournisseur->dir_output."/facture/".get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').dol_sanitizeFileName($object->ref); + } elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -401,6 +441,22 @@ class Documents extends DolibarrApi $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($object->ref); } + elseif ($modulepart == 'expensereport') + { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + + if (!DolibarrApiAccess::$user->rights->expensereport->read && !DolibarrApiAccess::$user->rights->expensereport->read) { + throw new RestException(401); + } + + $object = new ExpenseReport($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Expense report not found'); + } + + $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); + } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); @@ -432,8 +488,9 @@ class Documents extends DolibarrApi /** * Upload a file. * - * Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. - * Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. + * Test sample for invoice: { "filename": "mynewfile.txt", "modulepart": "invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. + * Test sample for supplier invoice: { "filename": "mynewfile.txt", "modulepart": "supplier_invoice", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }. + * Test sample for medias file: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "image/mywebsite", "filecontent": "Y29udGVudCB0ZXh0Cg==", "fileencoding": "base64", "overwriteifexists": "0" }. * * @param string $filename Name of file to create ('FA1705-0123.txt') * @param string $modulepart Name of module or area concerned by file upload ('facture', 'project', 'project_task', ...) @@ -489,6 +546,13 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($this->db); } + elseif ($modulepart == 'facture_fournisseur' || $modulepart == 'supplier_invoice') + { + $modulepart = 'supplier_invoice'; + + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; + $object = new FactureFournisseur($this->db); + } elseif ($modulepart == 'project') { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -523,6 +587,11 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $object = new Product($this->db); } + elseif ($modulepart == 'expensereport') + { + require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; + $object = new ExpenseReport($this->db); + } // TODO Implement additional moduleparts else { @@ -548,6 +617,12 @@ class Documents extends DolibarrApi throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); } + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + if ($modulepart == 'supplier_invoice') { + $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); + } + $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write'); @@ -643,7 +718,18 @@ class Documents extends DolibarrApi //--- Finds and returns the document $entity = $conf->entity; - $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); + // Special cases that need to use get_exdir to get real dir of object + // If future, all object should use this to define path of documents. + /* + $tmpreldir = ''; + if ($modulepart == 'supplier_invoice') { + $tmpreldir = get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier'); + } + + $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); */ + $relativefile = $original_file; + + $check_access = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 7c471dfd0bd..2afca6aedb5 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -554,6 +554,70 @@ class Setup extends DolibarrApi return $list; } + + /** + * Get the list of Expense Report types. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number (starting from zero) + * @param string $module To filter on module + * @param int $active Event's type is active or not {@min 0} {@max 1} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" + * @return array List of expense report types + * + * @url GET dictionary/expensereport_types + * + * @throws RestException + */ + public function getListOfExpenseReportsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT id, code, label, accountancy_code, active, module, position"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; + $sql .= " WHERE t.active = ".$active; + if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + // Add sql filters + if ($sqlfilters) + { + if (!DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + + $sql .= $this->db->order($sortfield, $sortorder); + + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; + + $sql .= $this->db->plimit($limit, $offset); + } + + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(503, 'Error when retrieving list of expense report types : '.$this->db->lasterror()); + } + + return $list; + } + + /** * Get the list of contacts types. * @@ -1337,6 +1401,39 @@ class Setup extends DolibarrApi return $this->_cleanObjectDatas($mysoc); } + + /** + * Get value of a setup variables + * + * Note that conf variables that stores security key or password hashes can't be loaded with API. + * + * @url GET /conf + * + * @param string $confname Name of conf variable to get + * @return array|mixed Data without useless information + * + * @throws RestException 403 Forbidden + * @throws RestException 500 Error Bad or unknown value for constname + */ + public function getConf($confname) + { + global $conf; + + if (!DolibarrApiAccess::$user->admin + && (empty($conf->global->API_LOGIN_ALLOWED_FOR_ADMIN_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_ADMIN_CHECK)) { + throw new RestException(403, 'Error API open to admin users only or to the login user defined with constant API_LOGIN_ALLOWED_FOR_ADMIN_CHECK'); + } + + if (! preg_match('/[^a-zA-Z0-9_]/', $confname) || ! isset($conf->global->$confname)) { + throw new RestException(500, 'Error Bad or unknown value for constname'); + } + if (preg_match('/(_pass|password|secret|_key|key$)/i', $confname)) { + throw new RestException(403, 'Forbidden'); + } + + return $conf->global->$confname; + } + /** * Do a test of integrity for files and setup. * @@ -1345,7 +1442,9 @@ class Setup extends DolibarrApi * * @url GET checkintegrity * - * @throws RestException + * @throws RestException 404 Signature file not found + * @throws RestException 500 Technical error + * @throws RestException 503 Forbidden */ public function getCheckIntegrity($target) { @@ -1354,7 +1453,7 @@ class Setup extends DolibarrApi if (!DolibarrApiAccess::$user->admin && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) { - throw new RestException(503, 'Error API open to admin users only or to login user defined with constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK'); + throw new RestException(503, 'Error API open to admin users only or to the login user defined with constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK'); } require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 7a9ef9ad24d..6ccdab6c179 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -56,6 +56,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $url = $_SERVER['PHP_SELF']; +if (preg_match('/api\/index\.php$/', $url)) { // sometimes $_SERVER['PHP_SELF'] is 'api\/index\.php' instead of 'api\/index\.php/explorer.php' or 'api\/index\.php/method' + $url = $_SERVER['PHP_SELF'].$_SERVER['PATH_INFO']; +} // Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases) if (! empty($conf->global->MAIN_NGINX_FIX)) { diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index d4ae2bd2930..9d224fe079e 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -76,9 +76,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print ''; - print "
    "; + print '
    '; + print ''; + print "
    "; } @@ -90,10 +90,10 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { - print "
    "; - print load_fiche_titre($langs->trans('NewAttribute')); + print "
    "; + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -103,10 +103,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index b4ff4ebac68..b0ab945f543 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -203,7 +203,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id); + $res = $object->fetch_optionals(); $head = asset_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic'); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index c6488f9e0be..c6762c5c946 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -47,7 +47,7 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index 2a9657baf90..e414193fb83 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -49,7 +49,7 @@ $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 542dbc8e23d..8df5ffe8c40 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -43,7 +43,7 @@ $type = GETPOST('type', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 20f189dd99f..e298e0e6540 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -61,28 +61,28 @@ if (! empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) $dir = dol_buildpath($dirroot, 0); $handle = @opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) - { - $file = substr($file, 0, dol_strlen($file)-4); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) + { + $file = substr($file, 0, dol_strlen($file)-4); - try { - dol_include_once($dirroot.$file.'.php'); - } - catch(Exception $e) - { - dol_syslog($e->getMessage(), LOG_ERR); - } + try { + dol_include_once($dirroot.$file.'.php'); + } + catch(Exception $e) + { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCodeProduct = new $file(); - break; - } - } - closedir($handle); - } + $modBarCodeProduct = new $file(); + break; + } + } + closedir($handle); + } } } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 828d2ecff50..5cd988a5bed 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -278,6 +278,7 @@ dol_htmloutput_errors($mesg); print ''; print ''; print ''; +print ''; print '
    '; diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php index becbbc3f151..3bd7f0097b9 100644 --- a/htdocs/blockedlog/admin/blockedlog_list.php +++ b/htdocs/blockedlog/admin/blockedlog_list.php @@ -58,7 +58,7 @@ if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_star $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/blockedlog/ajax/block-add.php b/htdocs/blockedlog/ajax/block-add.php index f38efde42b2..92ccd8af369 100644 --- a/htdocs/blockedlog/ajax/block-add.php +++ b/htdocs/blockedlog/ajax/block-add.php @@ -37,8 +37,8 @@ $element = GETPOST('element', 'alpha'); $action = GETPOST('action', 'alpha'); if ($element === 'facture') { - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $facture = new Facture($db); if($facture->fetch($id)>0) { diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 3c6f7563590..4da28dfdeb9 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2017 Laurent Destailleur +/* Copyright (C) 2017 ATM Consulting + * Copyright (C) 2017-2020 Laurent Destailleur * * 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 @@ -115,6 +115,8 @@ class BlockedLog public $ref_object = ''; public $object_data = null; + public $object_version = ''; + public $user_fullname = ''; /** @@ -674,7 +676,7 @@ class BlockedLog $langs->load("blockedlog"); $sql = "SELECT b.rowid, b.date_creation, b.signature, b.signature_line, b.amounts, b.action, b.element, b.fk_object, b.entity,"; - $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data"; + $sql .= " b.certified, b.tms, b.fk_user, b.user_fullname, b.date_object, b.ref_object, b.object_data, b.object_version"; $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog as b"; if ($id) $sql .= " WHERE b.rowid = ".$id; @@ -704,6 +706,7 @@ class BlockedLog $this->user_fullname = $obj->user_fullname; $this->object_data = $this->dolDecodeBlockedData($obj->object_data); + $this->object_version = $obj->object_version; $this->signature = $obj->signature; $this->signature_line = $obj->signature_line; @@ -826,6 +829,7 @@ class BlockedLog $sql .= " date_object,"; $sql .= " ref_object,"; $sql .= " object_data,"; + $sql .= " object_version,"; $sql .= " certified,"; $sql .= " fk_user,"; $sql .= " user_fullname,"; @@ -841,6 +845,7 @@ class BlockedLog $sql .= "'".$this->db->idate($this->date_object)."',"; $sql .= "'".$this->db->escape($this->ref_object)."',"; $sql .= "'".$this->db->escape(serialize($this->object_data))."',"; + $sql .= "'".$this->db->escape($this->object_version)."',"; $sql .= "0,"; $sql .= $this->fk_user.","; $sql .= "'".$this->db->escape($this->user_fullname)."',"; @@ -914,7 +919,11 @@ class BlockedLog private function buildKeyForSignature() { //print_r($this->object_data); - return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true); + if (((int) $this->object_version) > 12) { + return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true); + } else { + return $this->date_creation.'|'.$this->action.'|'.$this->amounts.'|'.$this->ref_object.'|'.$this->date_object.'|'.$this->user_fullname.'|'.print_r($this->object_data, true); + } } diff --git a/htdocs/blockedlog/lib/blockedlog.lib.php b/htdocs/blockedlog/lib/blockedlog.lib.php index 13c7ac61d1a..998a97e9bab 100644 --- a/htdocs/blockedlog/lib/blockedlog.lib.php +++ b/htdocs/blockedlog/lib/blockedlog.lib.php @@ -53,13 +53,13 @@ function blockedlogadmin_prepare_head() $object=new stdClass(); - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'blockedlog'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'blockedlog', 'remove'); - return $head; + return $head; } diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 37197d641dc..a5b66b9886f 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -60,7 +60,7 @@ $search_agenda_label = GETPOST('search_agenda_label'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 3f1be6c7e4c..887a319aefe 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -520,9 +520,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
    '.$langs->trans("Name").' 
    '.$langs->trans("RESTRICT_API_ON_IP").''.$langs->trans("RESTRICT_ON_IP"); +print ' '.$langs->trans("Example").': '.$langs->trans("IPListExample"); +print ''; print '
    '."\n"; // Common attributes - $keyforbreak = 'efficiency'; + $keyforbreak = 'duration'; include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + print ''; + print ''; + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; @@ -542,11 +545,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (!empty($object->table_element_line)) { - // Show object lines - $result = $object->getLinesArray(); - print ' - + diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 6ac836fdcae..0fc68ed276e 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -48,7 +48,7 @@ $ref = GETPOST('ref', 'alpha'); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 12602f9744a..f8ecfa11996 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -47,7 +47,7 @@ $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; @@ -482,7 +482,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print '
    '.$langs->trans("TotalCost").''.price($object->total_cost).'
    '.$langs->trans("UnitCost").''.price($object->unit_cost).'
    '."\n"; +print '
    '."\n"; // Fields title search @@ -502,7 +502,7 @@ foreach ($object->fields as $key => $val) elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); } - elseif (! preg_match('/^(date|timestamp)/', $val['type'])) print ''; + elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; print ''; } } @@ -582,6 +582,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index ddfb5e78d17..c2779429ebc 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -95,7 +95,7 @@ class BOM extends CommonObject 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp'), 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), - 'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'), + //'efficiency' => array('type'=>'real', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>-1, 'default'=>1, 'position'=>100, 'notnull'=>0, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLossForProductProduced'), 'duration' => array('type'=>'duration', 'label'=>'EstimatedDuration', 'enabled'=>1, 'visible'=>-1, 'position'=>101, 'notnull'=>-1, 'css'=>'maxwidth50imp', 'help'=>'EstimatedDurationDesc'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:0', 'label'=>'WarehouseForProduction', 'enabled'=>1, 'visible'=>-1, 'position'=>102), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>-2, 'position'=>161, 'notnull'=>-1,), @@ -166,6 +166,16 @@ class BOM extends CommonObject */ public $lines = array(); + /** + * @var int Calculated cost for the BOM + */ + public $total_cost = 0; + + /** + * @var int Calculated cost for 1 unit of the product in BOM + */ + public $unit_cost = 0; + /** @@ -324,6 +334,7 @@ class BOM extends CommonObject { $result = $this->fetchCommon($id, $ref); if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines(); + $this->calculateCosts(); return $result; } @@ -561,7 +572,7 @@ class BOM extends CommonObject { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); // Validate $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; @@ -991,6 +1002,29 @@ class BOM extends CommonObject return $error; } + + /** + * BOM costs calculation based on cost_price or pmp of each BOM line + * @return void + */ + public function calculateCosts() + { + include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + $this->unit_cost = 0; + $this->total_cost = 0; + + foreach ($this->lines as &$line) { + $tmpproduct = new Product($this->db); + $tmpproduct->fetch($line->fk_product); + + $line->unit_cost = (!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp; // TODO : add option to work with cost_price or pmp + $line->total_cost = price2num($line->qty * $line->unit_cost, 'MT'); + $this->total_cost += $line->total_cost; + } + + $this->total_cost = price2num($this->total_cost, 'MT'); + $this->unit_cost = price2num($this->total_cost / $this->qty, 'MU'); + } } @@ -1056,7 +1090,7 @@ class BOMLine extends CommonObjectLine 'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',), 'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'), 'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'), - //'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), + 'efficiency' => array('type'=>'double(24,8)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfEfficiencyConsumedMeans'), 'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), ); @@ -1072,6 +1106,16 @@ class BOMLine extends CommonObjectLine public $import_key; // END MODULEBUILDER PROPERTIES + /** + * @var int Calculated cost for the BOM line + */ + public $total_cost = 0; + + /** + * @var int Line unit cost based on product cost price or pmp + */ + public $unit_cost = 0; + /** * Constructor diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index b027b5f397d..66bcf0cece5 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -98,11 +98,11 @@ if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) if (!empty($conf->global->ENTREPOT_EXTRA_STATUS)) { // hide products in closed warehouse, but show products for internal transfer - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, 'warehouseopen,warehouseinternal', GETPOST('combinations', 'array')); } else { - $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); + $form->select_produits(GETPOST('idprod', 'int'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, $statustoshow, 2, '', 1, array(), $buyer->id, '1', 0, 'maxwidth500', 0, '', GETPOST('combinations', 'array')); } echo ''; @@ -128,11 +128,15 @@ $coldisplay++; print ''; -//$coldisplay++; -//print ''; +$coldisplay++; +print ''; +$coldisplay++; +print ''; $coldisplay += $colspan; print ''; -//$coldisplay++; -//print ''; +$coldisplay++; +print ''; $coldisplay+=$colspan; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 706f71af7ec..ce440dbaab6 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -60,13 +60,16 @@ if ($conf->global->PRODUCT_USE_UNITS) } // Qty frozen -print ''; +print ''; // Disable stock change -print ''; +print ''; // Efficiency -//print ''; +print ''; + +// Cost +print ''; print ''; // No width to allow autodim diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 97221d531ad..ad2c2d3e4c6 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -98,10 +98,15 @@ $coldisplay++; echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formating role of function price print ''; -//print ''; +print ''; + +print ''; if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines' ) { print '"; - } - else - { - $counter = ""; + $elements = $categstatic->getObjectsInCateg($type, 1); + $counter = ""; } $data[] = array( diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index ed6091e3568..b9fd23c1a3d 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -36,15 +36,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php'; $langs->loadlangs(array('categories', 'bills')); -$id = GETPOST('id', 'int'); -$ref = GETPOST('ref'); -$type = GETPOST('type'); -$action = GETPOST('action', 'aZ09'); +$id = GETPOST('id', 'int'); +$label = GETPOST('label', 'alpha'); +$type = GETPOST('type'); +$action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm'); -if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility - -if ($id == "") +if ($id == '' && $label == '') { dol_print_error('', 'Missing parameter id'); exit(); @@ -54,13 +52,17 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -if ($id > 0) -{ - $result = $object->fetch($id); - - $upload_dir = $conf->categorie->multidir_output[$object->entity]; +$result = $object->fetch($id, $label, $type); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; } +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} +$upload_dir = $conf->categorie->multidir_output[$object->entity]; +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility /* * Actions @@ -126,7 +128,7 @@ if ($object->id) dol_fiche_head($head, 'photos', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; - + $object->next_prev_filter = ' type = ' . $object->type; $object->ref = $object->label; $morehtmlref='
    '.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); @@ -136,7 +138,7 @@ if ($object->id) } $morehtmlref.='
    '; - dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + dol_banner_tab($object, 'label', $linkback, ($user->socid?0:1), 'label', 'label', $morehtmlref, '&type=' . $type, 0, '', '', 1); /* * Confirmation de la suppression de photo diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php index 03ca6e977bd..697db116881 100644 --- a/htdocs/categories/traduction.php +++ b/htdocs/categories/traduction.php @@ -36,18 +36,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->loadLangs(array('categories', 'languages')); $id = GETPOST('id', 'int'); -$ref = GETPOST('ref', 'alpha'); +$label = GETPOST('label', 'alpha'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); $type = GETPOST('type', 'aZ09'); -if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility - -// Security check -$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); -$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); - -if ($id == "") +if ($id == '' && $label == '') { dol_print_error('', 'Missing parameter id'); exit(); @@ -57,7 +51,16 @@ if ($id == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); +$result = $object->fetch($id, $label, $type); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} +$object->fetch_optionals(); +if ($result <= 0) { + dol_print_error($db, $object->error); exit; +} +if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility /* * Actions @@ -159,8 +162,6 @@ $cancel != $langs->trans("Cancel") && } } -$result = $object->fetch($id, $ref); - /* * View @@ -197,7 +198,7 @@ if (!empty($object->multilangs)) dol_fiche_head($head, 'translation', $title, -1, 'category'); $linkback = ''.$langs->trans("BackToList").''; - +$object->next_prev_filter = ' type = ' . $object->type; $object->ref = $object->label; $morehtmlref = '
    '.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); @@ -207,7 +208,7 @@ foreach ($ways as $way) } $morehtmlref .= '
    '; -dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'label', $morehtmlref, '&type=' . $type, 0, '', '', 1); print '
    '; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5d81ccd7d63..c7242077da4 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -4,6 +4,7 @@ * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -55,7 +56,7 @@ $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always ' $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; @@ -71,7 +72,7 @@ if ($id == "" && $label == "") $result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); -$result = $object->fetch($id, $label); +$result = $object->fetch($id, $label, $type); if ($result <= 0) { dol_print_error($db, $object->error); exit; } @@ -80,7 +81,6 @@ if ($result <= 0) { dol_print_error($db, $object->error); exit; } -$type = $object->type; if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility $extrafields = new ExtraFields($db); @@ -222,8 +222,8 @@ $head = categories_prepare_head($object, $type); dol_fiche_head($head, 'card', $title, -1, 'category'); $backtolist = (GETPOST('backtolist') ? GETPOST('backtolist') : DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$type); -$linkback = ''.$langs->trans("BackToList").''; -$object->next_prev_filter=" type = ".$object->type; +$linkback = ''.$langs->trans("BackToList").''; +$object->next_prev_filter = ' type = ' . $object->type; $object->ref = $object->label; $morehtmlref='
    '.$langs->trans("Root").' >> '; $ways = $object->print_all_ways(" >> ", '', 1); @@ -233,7 +233,7 @@ foreach ($ways as $way) } $morehtmlref.='
    '; -dol_banner_tab($object, 'label', $linkback, ($user->socid?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1); +dol_banner_tab($object, 'label', $linkback, ($user->socid?0:1), 'label', 'label', $morehtmlref, '&type=' . $type, 0, '', '', 1); /* @@ -291,8 +291,18 @@ if ($user->rights->categorie->supprimer) print ""; +if (! empty($user->rights->categorie->creer)) +{ + $link = DOL_URL_ROOT.'/categories/card.php'; + $link .= '?action=create'; + $link .= '&type='.$type; + $link .= '&catorigin='.$object->id; + $link .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.'&id='.$id); - + print '
    '; + print dolGetButtonTitle($langs->trans('NewCategory'), '', 'fa fa-plus-circle', $link); + print "
    "; +} $cats = $object->get_filles(); if ($cats < 0) diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index f01f49921e7..b9ad3015adf 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -64,7 +64,7 @@ if ($id > 0) // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; @@ -143,19 +143,19 @@ if ($object->id > 0) // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - //$morehtmlref.='
    '.$langs->trans('Project') . ' '; - $morehtmlref.=$langs->trans('Project') . ': '; - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - if ($proj->title) $morehtmlref.=' - '.$proj->title; - } else { - $morehtmlref.=''; - } + $langs->load("projects"); + //$morehtmlref.='
    '.$langs->trans('Project') . ' '; + $morehtmlref.=$langs->trans('Project') . ': '; + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + if ($proj->title) $morehtmlref.=' - '.$proj->title; + } else { + $morehtmlref.=''; + } } $morehtmlref.=''; @@ -253,9 +253,9 @@ if ($object->id > 0) print '
    '; print ''; -//print ''; -//print ''; +print ''; +print ''; +print ' '; +print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 10c3ee01e4b..c8899603f58 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -124,14 +124,14 @@ $coldisplay++; print 'disable_stock_change?' checked="checked"':'')).'">'; print ''; -//print ''; +print ''; $coldisplay+=$colspan; -print ''; +print ''; print '
    '; print ''; print '
    '.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('XXX')).''.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).''.$langs->trans('CostPrice').''; -//$coldisplay++; -//echo $line->efficiency; -//print ''; +$coldisplay++; +echo $line->efficiency; +print ''; +$coldisplay++; +echo price($line->total_cost); +print ''; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 85638a51a45..699065520da 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -32,6 +32,7 @@ function printDropdownBookmarksList() global $conf, $user, $db, $langs; require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; $langs->load("bookmarks"); @@ -59,13 +60,13 @@ function printDropdownBookmarksList() } $searchForm = ''."\n"; - $searchForm .= ''; - $searchForm .= ''; - $searchForm .= ''; + $searchForm .= '
    global->MAIN_OPTIMIZEFORTEXTBROWSER)?'onsubmit="return false"':'').'>'; + $searchForm .= ''; + // Url to list bookmark $listbtn = ''; - $listbtn .= ' '.$langs->trans('Bookmarks').''; + $listbtn .= ''.$langs->trans('Bookmarks').''; // Url to go on create new bookmark page $newbtn = ''; @@ -74,10 +75,9 @@ function printDropdownBookmarksList() //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url); $urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); $newbtn .= ''; - $newbtn .= img_picto('', 'bookmark').' '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; + $newbtn .= img_picto('', 'bookmark', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; } - $bookmarkList = ''; - $html = ' - - - '; + $searchForm .= '
    '; - $html .= ' - - - '; + // Generate the return string + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $html = $searchForm; - $html .= ' - - - '; + $html.=' + '; + } else { + $html = ' + + + '; - if ($(this).text().search(new RegExp(filter, "i")) < 0) { - $(this).addClass("hidden-search-result"); - } else { - $(this).removeClass("hidden-search-result"); - count++; - } - }); - $("#top-bookmark-search-filter-count").text(count); - }); - '; + $html .= ' + + + '; + + $html .= ' + + + '; + + $html .= ' + '; + } return $html; } diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 4e9d6851399..067e2abeaa9 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -44,7 +44,7 @@ $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 7122e1b6f59..fcfe9905bae 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -74,11 +74,11 @@ if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { logo_small)) { - print 'Logo company'; + print 'Logo company'; } else { - print '
    '.$mysoc->name.'
    '; + print '
    '.$mysoc->name.'
    '; } ?> diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index b7b37054d91..7783bf7137a 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -305,6 +305,7 @@ switch ($action) $payment->note=$langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice(); $payment->paiementid=$invoice->mode_reglement_id; $payment->num_paiement=''; + $payment->num_payment=''; $paiement_id = $payment->create($user); if ($paiement_id > 0) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 39f94db02eb..2e8afdb0089 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -167,8 +167,9 @@ class Categorie extends CommonObject 'member' => 'adherent', 'contact' => 'socpeople', 'user' => 'user', - 'account' => 'bank_account', - 'project' => 'projet', + 'account' => 'bank_account', // old for bank account + 'bank_account' => 'bank_account', + 'project' => 'projet', 'warehouse'=> 'entrepot', 'actioncomm' => 'actioncomm', ); @@ -242,7 +243,49 @@ class Categorie extends CommonObject */ public function __construct($db) { + global $hookmanager; + $this->db = $db; + + if (is_object($hookmanager)) { + $hookmanager->initHooks(array('category')); + $parameters = array(); + $reshook = $hookmanager->executeHooks('constructCategory', $parameters, $this); // Note that $action and $object may have been modified by some hooks + if ($reshook >= 0 && !empty($hookmanager->resArray)) { + $mapList = $hookmanager->resArray; + $mapId = $mapList['id']; + $mapCode = $mapList['code']; + self::$MAP_ID_TO_CODE[$mapId] = $mapCode; + $this->MAP_ID[$mapCode] = $mapId; + $this->MAP_CAT_FK[$mapCode] = $mapList['cat_fk']; + $this->MAP_CAT_TABLE[$mapCode] = $mapList['cat_table']; + $this->MAP_OBJ_CLASS[$mapCode] = $mapList['obj_class']; + $this->MAP_OBJ_TABLE[$mapCode] = $mapList['obj_table']; + } + } + } + + /** + * Get map list + * + * @return array + */ + public function getMapList() + { + $mapList = array(); + + foreach ($this->MAP_ID as $mapCode => $mapId) { + $mapList[] = array( + 'id' => $mapId, + 'code' => $mapCode, + 'cat_fk' => $this->MAP_CAT_FK[$mapCode], + 'cat_table' => $this->MAP_CAT_TABLE[$mapCode], + 'obj_class' => $this->MAP_OBJ_CLASS[$mapCode], + 'obj_table' => $this->MAP_OBJ_TABLE[$mapCode] + ); + } + + return $mapList; } /** @@ -774,7 +817,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') + * @param string $type Type of category ('customer', 'supplier', 'contact', 'product', 'member', ...) * @param int $onlyids Return only ids of objects (consume less memory) * @param int $limit Limit * @param int $offset Offset @@ -1911,8 +1954,8 @@ class Categorie extends CommonObject /** * Return label of contact status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of contact status + * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of contact status */ public function getLibStatut($mode) { @@ -1957,4 +2000,59 @@ class Categorie extends CommonObject return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); } + + /** + * Return the addtional SQL JOIN query for filtering a list by a category + * + * @param string $type The category type (e.g Categorie::TYPE_WAREHOUSE) + * @param string $rowIdName The name of the row id inside the whole sql query (e.g. "e.rowid") + * @return string A additional SQL JOIN query + */ + public static function getFilterJoinQuery($type, $rowIdName) + { + if ($type == 'bank_account') $type = 'account'; + + return " LEFT JOIN ".MAIN_DB_PREFIX."categorie_".$type." as cp ON ".$rowIdName." = cp.fk_".$type; + } + + /** + * Return the addtional SQL SELECT query for filtering a list by a category + * + * @param string $type The category type (e.g Categorie::TYPE_WAREHOUSE) + * @param string $rowIdName The name of the row id inside the whole sql query (e.g. "e.rowid") + * @param Array $searchList A list with the selected categories + * @return string A additional SQL SELECT query + */ + public static function getFilterSelectQuery($type, $rowIdName, $searchList) + { + if ($type == 'bank_account') $type = 'account'; + + if (empty($searchList) && !is_array($searchList)) + { + return ""; + } + + foreach ($searchList as $searchCategory) + { + if (intval($searchCategory) == -2) + { + $searchCategorySqlList[] = " cp.fk_categorie IS NULL"; + } + elseif (intval($searchCategory) > 0) + { + $searchCategorySqlList[] = " ".$rowIdName + ." IN (SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type + ." WHERE fk_categorie = ".$searchCategory.")"; + } + } + + if (!empty($searchCategorySqlList)) + { + return " AND (".implode(' AND ', $searchCategorySqlList).")"; + } + else + { + return ""; + } + } } diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index c71be0cd919..54a4ff9f1d2 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -40,6 +40,7 @@ $id = GETPOST('id', 'int'); $type = (GETPOST('type', 'aZ09') ? GETPOST('type', 'aZ09') : Categorie::TYPE_PRODUCT); $catname = GETPOST('catname', 'alpha'); +$categstatic = new Categorie($db); if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility @@ -47,25 +48,13 @@ if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backwar * View */ -$categstatic = new Categorie($db); $form = new Form($db); -if ($type == Categorie::TYPE_PRODUCT) { $title=$langs->trans("ProductsCategoriesArea"); $typetext='product'; } -elseif ($type == Categorie::TYPE_SUPPLIER) { $title=$langs->trans("SuppliersCategoriesArea"); $typetext='supplier'; } -elseif ($type == Categorie::TYPE_CUSTOMER) { $title=$langs->trans("CustomersCategoriesArea"); $typetext='customer'; } -elseif ($type == Categorie::TYPE_MEMBER) { $title=$langs->trans("MembersCategoriesArea"); $typetext='member'; } -elseif ($type == Categorie::TYPE_CONTACT) { $title=$langs->trans("ContactsCategoriesArea"); $typetext='contact'; } -elseif ($type == Categorie::TYPE_ACCOUNT) { $title=$langs->trans("AccountsCategoriesArea"); $typetext='bank_account'; } -elseif ($type == Categorie::TYPE_PROJECT) { $title=$langs->trans("ProjectsCategoriesArea"); $typetext='project'; } -elseif ($type == Categorie::TYPE_USER) { $title=$langs->trans("UsersCategoriesArea"); $typetext='user'; } -elseif ($type == Categorie::TYPE_WAREHOUSE) { $title=$langs->trans("StocksCategoriesArea"); $typetext='warehouse'; } -elseif ($type == Categorie::TYPE_ACTIONCOMM) { - $title = $langs->trans("ActionCommCategoriesArea"); - $typetext = 'actioncomm'; -} else { - $title = $langs->trans("CategoriesArea"); - $typetext = 'unknown'; -} +$typetext = $type; +if ($type == Categorie::TYPE_ACCOUNT) $title = $langs->trans('AccountsCategoriesArea'); +elseif ($type == Categorie::TYPE_WAREHOUSE) $title = $langs->trans('StocksCategoriesArea'); +elseif ($type == Categorie::TYPE_ACTIONCOMM) $title = $langs->trans('ActionCommCategoriesArea'); +else $title = $langs->trans(ucfirst($type). 'sCategoriesArea'); $arrayofjs=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js'); $arrayofcss=array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); @@ -182,23 +171,13 @@ foreach ($fulltree as $key => $val) $li = $categstatic->getNomUrl(1, '', 60); $desc = dol_htmlcleanlastbr($val['description']); + $counter = ''; + if($conf->global->CATEGORY_SHOW_COUNTS) { // we need only a count of the elements, so it is enough to consume only the id's from the database - if ($type == Categorie::TYPE_PRODUCT) $elements = $categstatic->getObjectsInCateg("product", 1); - if ($type == Categorie::TYPE_SUPPLIER) $elements = $categstatic->getObjectsInCateg("supplier", 1); - if ($type == Categorie::TYPE_CUSTOMER) $elements = $categstatic->getObjectsInCateg("customer", 1); - if ($type == Categorie::TYPE_MEMBER) $elements = $categstatic->getObjectsInCateg("member", 1); - if ($type == Categorie::TYPE_CONTACT) $elements = $categstatic->getObjectsInCateg("contact", 1); - if ($type == Categorie::TYPE_ACCOUNT) $elements = $categstatic->getObjectsInCateg("account", 1); - if ($type == Categorie::TYPE_PROJECT) $elements = $categstatic->getObjectsInCateg("project", 1); - if ($type == Categorie::TYPE_USER) $elements = $categstatic->getObjectsInCateg("user", 1); - - $counter = "
    ".count($elements)."".(is_countable($elements) ? count($elements) : '0')."
    '; - print '
    '; + print ''; - dol_fiche_end(); + dol_fiche_end(); $modulepart = 'actions'; diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 31808d35991..b480586bc6a 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -58,7 +58,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", "int"); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 895136f82f0..e388bb25fb0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -94,7 +94,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if ($page == -1 || $page == null) { $page = 0; } $offset = $limit * $page; if (!$sortorder) diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 04f334a9551..6dfbc6c7f9c 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -56,7 +56,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", "int"); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; @@ -248,7 +248,7 @@ $nav .= "   ('; -$nav .= ''; +$nav .= ''; $nav .= ''; $nav .= ''; $nav .= ''; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index f906c4cab45..f2cce5c8023 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -56,7 +56,7 @@ $showbirthday = 0; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", "int"); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; @@ -289,7 +289,7 @@ $nav .= "   ".$langs->trans("Today").")"; /*$nav.='  
    '; -$nav.=''; +$nav.=''; $nav.=''; $nav.=''; $nav.=''; diff --git a/htdocs/comm/action/rapport/index.php b/htdocs/comm/action/rapport/index.php index 92744da332c..b9ab38a734e 100644 --- a/htdocs/comm/action/rapport/index.php +++ b/htdocs/comm/action/rapport/index.php @@ -41,7 +41,7 @@ $year=GETPOST('year'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if ($page == -1 || $page == null) { $page = 0 ; } $offset = $limit * $page ; if (! $sortorder) $sortorder="DESC"; diff --git a/htdocs/comm/admin/propaldet_extrafields.php b/htdocs/comm/admin/propaldet_extrafields.php index fc53f90ed55..a0530e8c262 100644 --- a/htdocs/comm/admin/propaldet_extrafields.php +++ b/htdocs/comm/admin/propaldet_extrafields.php @@ -85,9 +85,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -100,9 +100,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -112,10 +112,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } // End of page diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index b5164d6078c..f1ea3c0923d 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -67,7 +67,7 @@ $mode = GETPOST("mode"); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; @@ -666,7 +666,7 @@ if ($object->id > 0) $now = dol_now(); /* - * Last proposals + * Latest proposals */ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { @@ -738,7 +738,7 @@ if ($object->id > 0) } /* - * Last orders + * Latest orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { @@ -751,7 +751,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.entity IN (".getEntity('commande').')'; $sql .= " ORDER BY c.date_commande DESC"; $resql = $db->query($sql); @@ -824,7 +824,7 @@ if ($object->id > 0) } /* - * Last shipments + * Latest shipments */ if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) { @@ -897,7 +897,7 @@ if ($object->id > 0) } /* - * Last linked contracts + * Latest linked contracts */ if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { @@ -905,7 +905,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c"; $sql .= " WHERE c.fk_soc = s.rowid "; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND c.entity IN (".getEntity('contract').")"; $sql .= " ORDER BY c.datec DESC"; $resql = $db->query($sql); @@ -967,7 +967,7 @@ if ($object->id > 0) } /* - * Last interventions + * Latest interventions */ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { @@ -975,7 +975,7 @@ if ($object->id > 0) $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND s.rowid = ".$object->id; - $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.entity IN (".getEntity('intervention').")"; $sql .= " ORDER BY f.tms DESC"; $resql = $db->query($sql); @@ -1028,7 +1028,7 @@ if ($object->id > 0) } /* - * Last invoices templates + * Latest invoices templates */ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { @@ -1044,7 +1044,7 @@ if ($object->id > 0) $sql .= ', s.nom, s.rowid as socid'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_rec as f"; $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id; - $sql .= " AND f.entity = ".$conf->entity; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= ' GROUP BY f.rowid, f.titre, f.total, f.tva, f.total_ttc,'; $sql .= ' f.date_last_gen, f.datec, f.frequency, f.unit_frequency,'; $sql .= ' f.suspended, f.date_when,'; @@ -1063,7 +1063,7 @@ if ($object->id > 0) print ''; print ''; - print ''; print ''; - print ''; + print ''; print ''; $i++; } @@ -320,13 +324,14 @@ if ($resql) } else dol_print_error($db); +$max = 10; /* * Orders to process */ if (!empty($conf->commande->enabled)) { - $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; + $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; $sql .= ", s.client"; $sql .= ", s.code_client"; $sql .= ", s.canvas"; @@ -335,7 +340,7 @@ if (!empty($conf->commande->enabled)) if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('commande').")"; - $sql .= " AND c.fk_statut = 1"; + $sql .= " AND c.fk_statut = ".Commande::STATUS_VALIDATED; if ($socid) $sql .= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " ORDER BY c.rowid DESC"; @@ -344,16 +349,16 @@ if (!empty($conf->commande->enabled)) if ($resql) { $num = $db->num_rows($resql); + print '
    '; print '
    '; + print ''; print ''; } diff --git a/htdocs/comm/contact.php b/htdocs/comm/contact.php index 8b3f4cf4894..3121bc3f1b9 100644 --- a/htdocs/comm/contact.php +++ b/htdocs/comm/contact.php @@ -31,7 +31,7 @@ $langs->load("companies"); $sortfield=GETPOST('sortfield', 'alpha'); $sortorder=GETPOST('sortorder', 'alpha'); -$page=GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; if ($page < 0) { $page = 0; } diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index b85826339e5..b716790aa8f 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -48,7 +48,7 @@ if (!$user->rights->mailing->lire || $user->socid > 0) $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 0900c5b032c..a21ea9d7d0a 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -992,7 +992,7 @@ else print ''.$langs->trans("SetToDraft").''; } - if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer) + if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->rights->mailing->creer) { if (!empty($conf->fckeditor->enabled) && !empty($conf->global->FCKEDITOR_ENABLE_MAILING)) { diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 41e49ed09b3..d8d9873b88b 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -43,13 +43,13 @@ if (!$user->rights->mailing->lire || $user->socid > 0) accessforbidden(); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "email"; -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) $sortfield = "mc.statut,email"; +if (!$sortorder) $sortorder = "DESC,ASC"; $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 7e2baa7274b..1eadb2d0da0 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -34,7 +34,7 @@ $result = restrictedArea($user, 'mailing'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f55861b00cc..262493c9383 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -726,7 +726,7 @@ if (empty($reshook)) $originLine = new $lineClassName($db); if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { - $originLine->fetch_optionals($lineId); + $originLine->fetch_optionals(); $desc = $originLine->desc; $pu_ht = $originLine->subprice; $qty = $originLine->qty; @@ -1523,7 +1523,7 @@ if ($action == 'create') $dateinvoice = (empty($dateinvoice) ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $dateinvoice); // Replicate extrafields - $objectsrc->fetch_optionals($originid); + $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; if (!empty($conf->multicurrency->enabled)) @@ -1541,7 +1541,7 @@ if ($action == 'create') $object = new Propal($db); print ''; - print ''; + print ''; print ''; if ($origin != 'project' && $originid) { print ''; @@ -1675,7 +1675,7 @@ if ($action == 'create') $langs->load("projects"); print ''; print ''; print ''; @@ -1893,7 +1893,7 @@ if ($action == 'create') { //Form to close proposal (signed or not) $formquestion = array( - array('type' => 'select', 'name' => 'statut', 'label' => $langs->trans("CloseAs"), 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), + array('type' => 'select', 'name' => 'statut', 'label' => ''.$langs->trans("CloseAs").'', 'values' => array(2=>$object->LibStatut(Propal::STATUS_SIGNED), 3=>$object->LibStatut(Propal::STATUS_NOTSIGNED))), array('type' => 'text', 'name' => 'note_private', 'label' => $langs->trans("Note"), 'value' => '') // Field to complete private note (not replace) ); @@ -2052,7 +2052,7 @@ if ($action == 'create') print ''; } - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { @@ -577,7 +587,8 @@ if ($socid > 0) /* * Liste remises fixes fournisseur restant en cours (= liees a aucune facture ni ligne de facture) */ - $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; + $sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql .= " rc.datec as dc, rc.description,"; $sql .= " rc.fk_invoice_supplier_source,"; $sql .= " u.login, u.rowid as user_id,"; @@ -666,7 +677,7 @@ if ($socid > 0) { print ''; } - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { @@ -744,7 +755,8 @@ if ($socid > 0) } // Discount linked to invoice lines - $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; + $sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture_source,"; $sql .= " u.login, u.rowid as user_id,"; $sql .= " f.rowid as invoiceid, f.ref,"; @@ -762,7 +774,7 @@ if ($socid > 0) $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Discount linked to invoices - $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; + $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql2 .= " rc.fk_facture_source,"; $sql2 .= " u.login, u.rowid as user_id,"; @@ -881,7 +893,7 @@ if ($socid > 0) { print ''; } - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { @@ -920,7 +932,8 @@ if ($socid > 0) } // Discount linked to invoice lines - $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; + $sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql .= " rc.fk_invoice_supplier_source,"; $sql .= " u.login, u.rowid as user_id,"; @@ -939,7 +952,7 @@ if ($socid > 0) $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; // Discount linked to invoices - $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; + $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql2 .= " rc.fk_invoice_supplier_source,"; $sql2 .= " u.login, u.rowid as user_id,"; @@ -1057,7 +1070,7 @@ if ($socid > 0) { print ''; } - print ''; + print ''; print ''; if (!empty($conf->multicurrency->enabled)) { diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f5efd124322..372e64e4e43 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -112,6 +112,13 @@ $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php $permissiontoadd = $usercancreate; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +if (!empty($conf->expedition->enabled) && $conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER = 1){ + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $object->warehouse_id = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($object->warehouse_id) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $object->warehouse_id = $user->fk_warehouse; +} + +$error = 0; + /* * Actions @@ -378,7 +385,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) // For avoid conflicts if trigger used { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -1355,7 +1362,7 @@ if (empty($reshook)) $originLine = new $lineClassName($db); if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { - $originLine->fetch_optionals($lineId); + $originLine->fetch_optionals(); $desc = $originLine->desc; $pu_ht = $originLine->subprice; $qty = $originLine->qty; @@ -1542,7 +1549,7 @@ if ($action == 'create' && $usercancreate) $objectsrc->fetch_thirdparty(); // Replicate extrafields - $objectsrc->fetch_optionals($originid); + $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); @@ -1595,7 +1602,7 @@ if ($action == 'create' && $usercancreate) } print ''; - print ''; + print ''; print ''; print ''."\n"; print ''; @@ -1734,7 +1741,7 @@ if ($action == 'create' && $usercancreate) $langs->load("projects"); print ''; print ''; print ''; @@ -2100,7 +2107,7 @@ if ($action == 'create' && $usercancreate) $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= ''; $morehtmlref .= ''; } else { @@ -2177,7 +2184,7 @@ if ($action == 'create' && $usercancreate) print ''; print ''; diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 6f71cf5c153..82d71dbe9d0 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -54,7 +54,7 @@ $result = restrictedArea($user, 'commande', $id, ''); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index b8866a7c487..8e1fa07c17a 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -72,7 +72,6 @@ print '
    '; if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { // Search customer orders - $var = false; print ''; print ''; print '
    '; @@ -88,7 +87,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles * Statistics */ -$sql = "SELECT count(c.rowid), c.fk_statut"; +$sql = "SELECT count(c.rowid) as nb, c.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."commande as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -117,7 +116,7 @@ if ($resql) //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { if (! isset($vals[$row[1]])) $vals[$row[1]]=0; - $vals[$row[1].$bool]+=$row[0]; + $vals[$row[1]]+=$row[0]; $totalinprocess+=$row[0]; } $total+=$row[0]; @@ -125,13 +124,32 @@ if ($resql) $i++; } $db->free($resql); + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + print '
    '; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").''.$num.''; print '
    '.$langs->trans("LatestCustomerTemplateInvoices", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllCustomerTemplateInvoices").''.$num.'
    '.$langs->trans("Project").''; - $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1); + $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); print ' id).'">'; print '
    '; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { print ''; - print ''; + print ''; print ''; print $form->selectDate($object->date, 're', '', '', 0, "editdate"); print ''; @@ -2078,7 +2078,7 @@ if ($action == 'create') print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { print ''; - print ''; + print ''; print ''; print $form->selectDate($object->fin_validite, 'ech', '', '', '', "editecheance"); print ''; @@ -2412,7 +2412,7 @@ if ($action == 'create') $result = $object->getLinesArray(); print ' - + diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index d0ce31b5369..87c91d0f621 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2020 Thibault FOUCART * * 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 @@ -64,16 +65,70 @@ class Proposals extends DolibarrApi */ public function get($id, $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + return $this->_fetch($id, '', '', $contact_list); + } + + /** + * Get properties of an proposal object by ref + * + * Return an array with proposal informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', $contact_list); + } + + /** + * Get properties of an proposal object by ref_ext + * + * Return an array with proposal informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, $contact_list); + } + + /** + * Get properties of an proposal object + * + * Return an array with proposal informations + * + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) + { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - $result = $this->propal->fetch($id); - if( ! $result ) { + $result = $this->propal->fetch($id, $ref, $ref_ext); + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -107,18 +162,18 @@ class Proposals extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."propal as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -127,23 +182,23 @@ class Proposals extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -158,7 +213,7 @@ class Proposals extends DolibarrApi { $obj = $db->fetch_object($result); $proposal_static = new Propal($db); - if($proposal_static->fetch($obj->rowid)) { + if ($proposal_static->fetch($obj->rowid)) { // Add external contacts ids $proposal_static->contacts_ids = $proposal_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($proposal_static); @@ -169,7 +224,7 @@ class Proposals extends DolibarrApi else { throw new RestException(503, 'Error when retrieve propal list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No proposal found'); } return $obj_ret; @@ -183,13 +238,13 @@ class Proposals extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->propal->$field = $value; } /*if (isset($request_data["lines"])) { @@ -217,16 +272,16 @@ class Proposals extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->propal->getLinesArray(); @@ -249,16 +304,16 @@ class Proposals extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -313,16 +368,16 @@ class Proposals extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if($result <= 0) { + if ($result <= 0) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -336,27 +391,27 @@ class Proposals extends DolibarrApi $updateRes = $this->propal->updateline( $lineid, - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, - isset($request_data->qty)?$request_data->qty:$propalline->qty, - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, - isset($request_data->desc)?$request_data->desc:$propalline->desc, + isset($request_data->subprice) ? $request_data->subprice : $propalline->subprice, + isset($request_data->qty) ? $request_data->qty : $propalline->qty, + isset($request_data->remise_percent) ? $request_data->remise_percent : $propalline->remise_percent, + isset($request_data->tva_tx) ? $request_data->tva_tx : $propalline->tva_tx, + isset($request_data->localtax1_tx) ? $request_data->localtax1_tx : $propalline->localtax1_tx, + isset($request_data->localtax2_tx) ? $request_data->localtax2_tx : $propalline->localtax2_tx, + isset($request_data->desc) ? $request_data->desc : $propalline->desc, 'HT', - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, + isset($request_data->info_bits) ? $request_data->info_bits : $propalline->info_bits, + isset($request_data->special_code) ? $request_data->special_code : $propalline->special_code, + isset($request_data->fk_parent_line) ? $request_data->fk_parent_line : $propalline->fk_parent_line, 0, - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, - isset($request_data->label)?$request_data->label:$propalline->label, - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice + isset($request_data->fk_fournprice) ? $request_data->fk_fournprice : $propalline->fk_fournprice, + isset($request_data->pa_ht) ? $request_data->pa_ht : $propalline->pa_ht, + isset($request_data->label) ? $request_data->label : $propalline->label, + isset($request_data->product_type) ? $request_data->product_type : $propalline->product_type, + isset($request_data->date_start) ? $request_data->date_start : $propalline->date_start, + isset($request_data->date_end) ? $request_data->date_end : $propalline->date_end, + isset($request_data->array_options) ? $request_data->array_options : $propalline->array_options, + isset($request_data->fk_unit) ? $request_data->fk_unit : $propalline->fk_unit, + isset($request_data->multicurrency_subprice) ? $request_data->multicurrency_subprice : $propalline->subprice ); if ($updateRes > 0) { @@ -383,16 +438,16 @@ class Proposals extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -424,13 +479,13 @@ class Proposals extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } @@ -438,7 +493,7 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -467,17 +522,17 @@ class Proposals extends DolibarrApi */ public function deleteContact($id, $rowid) { - if(!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if(!$result) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -500,16 +555,16 @@ class Proposals extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } foreach ($request_data as $field => $value) { @@ -524,7 +579,7 @@ class Proposals extends DolibarrApi } if (!empty($this->propal->fin_validite)) { - if($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite)<0) + if ($this->propal->set_echeance(DolibarrApiAccess::$user, $this->propal->fin_validite) < 0) { throw new RestException(500, $this->propal->error); } @@ -549,19 +604,19 @@ class Proposals extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->propal->supprimer) { + if (!DolibarrApiAccess::$user->rights->propal->supprimer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->propal->delete(DolibarrApiAccess::$user)) { + if (!$this->propal->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Commercial Proposal : '.$this->propal->error); } @@ -584,15 +639,15 @@ class Proposals extends DolibarrApi */ public function settodraft($id) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -605,11 +660,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -641,15 +696,15 @@ class Proposals extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -662,11 +717,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -689,15 +744,15 @@ class Proposals extends DolibarrApi */ public function close($id, $status, $note_private = '', $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -710,11 +765,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -734,15 +789,15 @@ class Proposals extends DolibarrApi */ public function setinvoiced($id) { - if (! DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Commercial Proposal not found'); } - if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -752,11 +807,11 @@ class Proposals extends DolibarrApi } $result = $this->propal->fetch($id); - if ( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3fa163594a2..ff3038e85d1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -223,6 +223,90 @@ class Propal extends CommonObject public $oldcopy; + + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), + 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), + 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'datep' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'fin_validite' =>array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>70), + 'date_cloture' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>80), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>85), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user cloture', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'price' =>array('type'=>'double', 'label'=>'Price', 'enabled'=>1, 'visible'=>-1, 'position'=>105), + 'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110), + 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115), + //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120), + 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), + 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), + 'total' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>155), + 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>160), + 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>170), + 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>175), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>180), + 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>190), + 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>195), + 'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>0, 'position'=>200), // deprecated + 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>205), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>215), + 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>220), + 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLabel', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>225), + 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>230), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCurrency', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>235), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>240, 'isameasure'=>1), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountHT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>245, 'isameasure'=>1), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>250, 'isameasure'=>1), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>255, 'isameasure'=>1), + 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>260), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), + ); + // END MODULEBUILDER PROPERTIES + /** * Draft status */ @@ -440,8 +524,8 @@ class Propal extends CommonObject * @param int $date_end End date of the line * @param array $array_options extrafields array * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency * @param int $fk_remise_except Id discount if line is from a discount * @return int >0 if OK, <0 if KO @@ -1099,6 +1183,14 @@ class Propal extends CommonObject $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -1122,8 +1214,8 @@ class Propal extends CommonObject $line->date_end, $line->array_options, $line->fk_unit, - $this->element, - $line->id + $origintype, + $originid ); if ($result < 0) @@ -1369,9 +1461,10 @@ class Propal extends CommonObject * * @param int $rowid id of object to load * @param string $ref Ref of proposal + * @param string $ref_ext Ref ext of proposal * @return int >0 if OK, <0 if KO */ - public function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '', $ref_ext = '') { $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; $sql .= ", p.total, p.tva, p.localtax1, p.localtax2, p.total_ht"; @@ -1803,7 +1896,7 @@ class Propal extends CommonObject { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql .= " SET ref = '".$this->db->escape($num)."',"; @@ -3249,8 +3342,8 @@ class Propal extends CommonObject $statusType = ''; if ($status == self::STATUS_DRAFT) $statusType = 'status0'; elseif ($status == self::STATUS_VALIDATED) $statusType = 'status1'; - elseif ($status == self::STATUS_SIGNED) $statusType = 'status3'; - elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status5'; + elseif ($status == self::STATUS_SIGNED) $statusType = 'status4'; + elseif ($status == self::STATUS_NOTSIGNED) $statusType = 'status9'; elseif ($status == self::STATUS_BILLED) $statusType = 'status6'; return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 0859bdb7974..d5c48006430 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -24,10 +24,10 @@ * \brief File of class to manage proposals statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -66,36 +66,36 @@ class PropaleStats extends Stats if ($mode == 'customer') { - $object=new Propal($this->db); + $object = new Propal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.datep'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.datep'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; + $this->where .= " p.fk_statut > 0"; } if ($mode == 'supplier') { - $object=new SupplierProposal($this->db); + $object = new SupplierProposal($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as p"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field_date='p.date_valid'; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field_date = 'p.date_valid'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; - $this->where.= " p.fk_statut > 0"; // Validated, accepted, refused and closed + $this->where .= " p.fk_statut > 0"; // Validated, accepted, refused and closed } //$this->where.= " AND p.fk_soc = s.rowid AND p.entity = ".$conf->entity; - $this->where.= " AND p.entity IN (".getEntity('propal').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if($this->socid) + $this->where .= " AND p.entity IN (".getEntity('propal').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($this->socid) { - $this->where.=" AND p.fk_soc = ".$this->socid; + $this->where .= " AND p.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND fk_user_author = '.$this->userid; } @@ -111,14 +111,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -133,11 +133,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -154,14 +154,14 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, SUM(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -176,12 +176,12 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%m') as dm, AVG(p.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -196,11 +196,11 @@ class PropaleStats extends Stats global $user; $sql = "SELECT date_format(".$this->field_date.",'%Y') as year, COUNT(*) as nb, SUM(".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -210,23 +210,24 @@ class PropaleStats extends Stats /** * Return nb, amount of predefined product for year * - * @param int $year Year to scan - * @return array Array of values + * @param int $year Year to scan + * @param int $limit Limit + * @return array Array of values */ - public function getAllByProduct($year) + public function getAllByProduct($year, $limit = 10) { global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; - $sql.= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND p.rowid = tl.fk_propal AND tl.fk_product = product.rowid"; + $sql .= " AND ".$this->field_date." BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index c052c234eab..e396a5f8b92 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -21,7 +21,7 @@ /** * \file htdocs/comm/propal/contact.php * \ingroup propal - * \brief Onglet de gestion des contacts de propal + * \brief Tab to manage contacts/adresses of proposal */ require '../../main.inc.php'; diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 9279da9b029..4ce7d10c9fd 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -55,7 +55,7 @@ $result = restrictedArea($user, 'propal', $id); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index 11bb4292036..a931af375c5 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -82,7 +82,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles * Statistics */ -$sql = "SELECT count(p.rowid), p.fk_statut"; +$sql = "SELECT count(p.rowid) as nb, p.fk_statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."propal as p"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -101,24 +101,26 @@ if ($resql) $total = 0; $totalinprocess = 0; $dataseries = array(); + $colorseries = array(); $vals = array(); + // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) + $obj = $db->fetch_object($resql); + if ($obj) { - //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) - { - $vals[$row[1]] = $row[0]; - $totalinprocess += $row[0]; - } - $total += $row[0]; + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; + + $total += $obj->nb; } $i++; } $db->free($resql); + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + print '
    '; print ''; print ''."\n"; @@ -126,7 +128,13 @@ if ($resql) foreach ($listofstatus as $status) { $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if (!$conf->use_javascript_ajax) + if ($status == Propal::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Propal::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Propal::STATUS_SIGNED) $colorseries[$status] = $badgeStatus4; + if ($status == Propal::STATUS_NOTSIGNED) $colorseries[$status] = $badgeStatus9; + if ($status == Propal::STATUS_BILLED) $colorseries[$status] = $badgeStatus6; + + if (empty($conf->use_javascript_ajax)) { print ''; print ''; @@ -141,10 +149,11 @@ if ($resql) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphthirdparties'); print $dolgraph->show($total ? 0 : 1); @@ -293,7 +302,8 @@ if ($resql) print ''; print ''; - print ''; + + print ''; print ''; $i++; } @@ -305,7 +315,7 @@ else dol_print_error($db); /* - * Opened proposals + * Open proposals */ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) { @@ -372,9 +382,10 @@ if (!empty($conf->propal->enabled) && $user->rights->propale->lire) $companystatic->canvas = $obj->canvas; print ''."\n"; - print ''."\n"; + print ''."\n"; + print ''; + print ''."\n"; print ''."\n"; $i++; diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index af12c7cdce3..f41bdc4fc67 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -69,6 +69,11 @@ $search_societe = GETPOST('search_societe', 'alpha'); $search_montant_ht = GETPOST('search_montant_ht', 'alpha'); $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_product_category = GETPOST('search_product_category', 'int'); $search_town = GETPOST('search_town', 'alpha'); @@ -98,7 +103,7 @@ $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -162,8 +167,15 @@ $arrayfields = array( 'p.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'p.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'p.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), - 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT), - 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>$conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT), + 'p.total_ht_invoiced'=>array('label'=>"AmountInvoicedHT", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.total_invoiced'=>array('label'=>"AmountInvoicedTTC", 'checked'=>0, 'enabled'=>!empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'p.multicurrency_total_ht_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedHT', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), + 'p.multicurrency_total_invoiced'=>array('label'=>'MulticurrencyAmountInvoicedTTC', 'checked'=>0, 'enabled'=>!empty($conf->multicurrency->enabled) && !empty($conf->global->PROPOSAL_SHOW_INVOICED_AMOUNT)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>1), 'p.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), @@ -209,6 +221,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_montant_ht = ''; $search_montant_vat = ''; $search_montant_ttc = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; $search_login = ''; $search_product_category = ''; $search_town = ''; @@ -269,6 +286,7 @@ $sql .= " typent.code as typent_code,"; $sql .= " ava.rowid as availability,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' p.rowid, p.entity, p.note_private, p.total_ht, p.tva as total_vat, p.total as total_ttc, p.localtax1, p.localtax2, p.ref, p.ref_client, p.fk_statut, p.fk_user_author, p.datep as dp, p.fin_validite as dfv,p.date_livraison as ddelivery,'; +$sql .= ' p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva as multicurrency_total_vat, p.multicurrency_total_ttc,'; $sql .= ' p.datec as date_creation, p.tms as date_update, p.date_cloture as date_cloture,'; $sql .= ' p.note_public, p.note_private,'; $sql .= " pr.rowid as project_id, pr.ref as project_ref, pr.title as project_label,"; @@ -326,6 +344,11 @@ if ($search_login) $sql .= natural_search("u.login", $search_login); if ($search_montant_ht != '') $sql .= natural_search("p.total_ht", $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search("p.tva", $search_montant_vat, 1); if ($search_montant_ttc != '') $sql .= natural_search("p.total", $search_montant_ttc, 1); +if ($search_multicurrency_code != '') $sql .= ' AND p.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('p.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('p.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('p.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('p.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); if ($sall) { $sql .= natural_search(array_keys($fieldstosearchall), $sall); } @@ -428,6 +451,11 @@ if ($resql) if ($search_user > 0) $param .= '&search_user='.urlencode($search_user); if ($search_sale > 0) $param .= '&search_sale='.urlencode($search_sale); if ($search_montant_ht) $param .= '&search_montant_ht='.urlencode($search_montant_ht); + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_town) $param .= '&search_town='.urlencode($search_town); if ($search_zip) $param .= '&search_zip='.urlencode($search_zip); @@ -677,6 +705,53 @@ if ($resql) print ''; } + if (!empty($arrayfields['p.multicurrency_code']['checked'])) + { + // Currency + print ''; + } + if (!empty($arrayfields['p.multicurrency_tx']['checked'])) + { + // Currency rate + print ''; + } + if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) + { + // Amount invoiced + print ''; + } + if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) + { + // Amount invoiced + print ''; + } if (!empty($arrayfields['u.login']['checked'])) { // Author @@ -750,6 +825,13 @@ if ($resql) if (!empty($arrayfields['p.total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.total_ttc']['label'], $_SERVER["PHP_SELF"], 'p.total', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['p.total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'p.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_ht_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) print_liste_field_titre($arrayfields['p.multicurrency_total_invoiced']['label'], $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['sale_representative']['checked'])) print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); // Extra fields @@ -790,6 +872,29 @@ if ($resql) $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; + $totalInvoicedHT = 0; + $totalInvoicedTTC = 0; + $multicurrency_totalInvoicedHT = 0; + $multicurrency_totalInvoicedTTC = 0; + + $TInvoiceData = $objectstatic->InvoiceArrayList($obj->rowid); + + if (!empty($TInvoiceData)) + { + foreach ($TInvoiceData as $invoiceData) + { + $invoice = new Facture($db); + $invoice->fetch($invoiceData->facid); + + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; + + $totalInvoicedHT += $invoice->total_ht; + $totalInvoicedTTC += $invoice->total_ttc; + $multicurrency_totalInvoicedHT += $invoice->multicurrency_total_ht; + $multicurrency_totalInvoicedTTC += $invoice->multicurrency_total_ttc; + } + } + print ''; if (!empty($arrayfields['p.ref']['checked'])) @@ -975,46 +1080,66 @@ if ($resql) $totalarray['val']['p.total_ttc'] += $obj->total_ttc; } // Amount invoiced - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - $totalInvoiced = 0; - $p = new Propal($db); - $TInvoiceData = $p->InvoiceArrayList($obj->rowid); - - if (!empty($TInvoiceData)) { - foreach ($TInvoiceData as $invoiceData) { - $invoice = new Facture($db); - $invoice->fetch($invoiceData->facid); - - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; - $totalInvoiced += $invoice->total_ht; - } - } - - print '\n"; + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) + { + print '\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; - $totalarray['val']['p.total_ht_invoiced'] += $obj->total_ht_invoiced; + $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; } // Amount invoiced - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - $totalInvoiced = 0; - $p = new Propal($db); - $TInvoiceData = $p->InvoiceArrayList($obj->rowid); - - if (!empty($TInvoiceData)) { - foreach ($TInvoiceData as $invoiceData) { - $invoice = new Facture($db); - $invoice->fetch($invoiceData->facid); - - if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS) && $invoice->type == Facture::TYPE_DEPOSIT) continue; - $totalInvoiced += $invoice->total_ttc; - } - } - - print '\n"; + if (!empty($arrayfields['p.total_invoiced']['checked'])) + { + print '\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; - $totalarray['val']['p.total_invoiced'] += $obj->total_invoiced; + $totalarray['val']['p.total_invoiced'] += $totalInvoicedTTC; + } + + // Currency + if (!empty($arrayfields['p.multicurrency_code']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['p.multicurrency_tx']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['p.multicurrency_total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['p.multicurrency_total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['p.multicurrency_total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount invoiced + if (!empty($arrayfields['p.multicurrency_total_ht_invoiced']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount invoiced + if (!empty($arrayfields['p.multicurrency_total_invoiced']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; } $userstatic->id = $obj->fk_user_author; @@ -1040,9 +1165,7 @@ if ($resql) $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) // We print only number { - print ''; print $nbofsalesrepresentative; - print ''; } elseif ($nbofsalesrepresentative > 0) { diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 4a2b8dea419..030db477631 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -242,7 +242,9 @@ print '
    '; //{ // Show filter box print ''; + print ''; print ''; + print '
    '.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
    '.$propalstatic->LibStatut($status, 0).''.$companystatic->getNomUrl(1, 'customer').''.dol_print_date($db->jdate($obj->datec), 'day').''.$propalstatic->LibStatut($obj->fk_statut, 5).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
    '.$companystatic->getNomUrl(1, 'customer', 44).''; - print dol_print_date($db->jdate($obj->dp), 'day').''.dol_print_date($db->jdate($obj->dp), 'day').''.price($obj->total_ttc).''.$propalstatic->LibStatut($obj->fk_statut, 3).'
    '; print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '.price($totalInvoiced)."'.price($totalInvoicedHT)."'.price($totalInvoiced)."'.price($totalInvoicedTTC)."'.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedTTC)."
    '; print ''; // Company diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 651fa556e8a..c312591aeec 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -56,7 +56,7 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) exit; } -if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') +if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes') { //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) @@ -122,6 +122,8 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') $newdiscount2->datec = $discount->datec; $newdiscount1->tva_tx = $discount->tva_tx; $newdiscount2->tva_tx = $discount->tva_tx; + $newdiscount1->vat_src_code = $discount->vat_src_code; + $newdiscount2->vat_src_code = $discount->vat_src_code; $newdiscount1->amount_ttc = $amount_ttc_1; $newdiscount2->amount_ttc = price2num($discount->amount_ttc - $newdiscount1->amount_ttc); $newdiscount1->amount_ht = price2num($newdiscount1->amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); @@ -129,6 +131,13 @@ if ($action == 'confirm_split' && GETPOST("confirm") == 'yes') $newdiscount1->amount_tva = price2num($newdiscount1->amount_ttc - $newdiscount1->amount_ht); $newdiscount2->amount_tva = price2num($newdiscount2->amount_ttc - $newdiscount2->amount_ht); + $newdiscount1->multicurrency_amount_ttc = $amount_ttc_1 * ($discount->multicurrency_amount_ttc / $discount->amount_ttc); + $newdiscount2->multicurrency_amount_ttc = price2num($discount->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ttc); + $newdiscount1->multicurrency_amount_ht = price2num($newdiscount1->multicurrency_amount_ttc / (1 + $newdiscount1->tva_tx / 100), 'MT'); + $newdiscount2->multicurrency_amount_ht = price2num($newdiscount2->multicurrency_amount_ttc / (1 + $newdiscount2->tva_tx / 100), 'MT'); + $newdiscount1->multicurrency_amount_tva = price2num($newdiscount1->multicurrency_amount_ttc - $newdiscount1->multicurrency_amount_ht); + $newdiscount2->multicurrency_amount_tva = price2num($newdiscount2->multicurrency_amount_ttc - $newdiscount2->multicurrency_amount_ht); + $db->begin(); $discount->fk_facture_source = 0; // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_facture_source // This is to delete only the require record (that we will recreate with two records) and not all family with same fk_invoice_supplier_source @@ -154,12 +163,12 @@ if ($action == 'setremise' && $user->rights->societe->creer) //if ($user->rights->societe->creer) //if ($user->rights->facture->creer) - $amount_ht = GETPOST('amount_ht'); + $amount_ht = price2num(GETPOST('amount_ht', 'alpha')); $desc = GETPOST('desc', 'alpha'); $tva_tx = GETPOST('tva_tx', 'alpha'); $discount_type = !empty($_POST['discount_type']) ?GETPOST('discount_type', 'alpha') : 0; - if (price2num($amount_ht) > 0) + if ($amount_ht > 0) { $error = 0; if (empty($desc)) @@ -196,7 +205,7 @@ if ($action == 'setremise' && $user->rights->societe->creer) } else { - setEventMessages($langs->trans("ErrorFieldFormat", $langs->transnoentitiesnoconv("NewGlobalDiscount")), null, 'errors'); + setEventMessages($langs->trans("ErrorFieldFormat", $langs->transnoentitiesnoconv("AmountHT")), null, 'errors'); } } @@ -375,10 +384,10 @@ if ($socid > 0) print ' '.$langs->trans("Currency".$conf->currency).''; print ''; print ''; print ''; - print ''; + print ''; print "
    '.$langs->trans("Filter").'
    '.$langs->trans("VAT").''; - print $form->load_tva('tva_tx', GETPOST('tva_tx'), $mysoc, $object); + print $form->load_tva('tva_tx', GETPOSTISSET('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0, $mysoc, $object, 0, 0, '', 0, 1); print '
    '.$langs->trans("NoteReason").'
    "; @@ -409,7 +418,7 @@ if ($socid > 0) /* - * List remises fixes client restant en cours (= liees a aucune facture ni ligne de facture) + * List not consumed available credits (= linked to no invoice and no invoice line) */ print load_fiche_titre($langs->trans("DiscountStillRemaining")); @@ -421,7 +430,8 @@ if ($socid > 0) print load_fiche_titre($langs->trans("CustomerDiscounts"), '', ''); } - $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; + $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.vat_src_code,"; + $sql .= " rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; $sql .= " rc.datec as dc, rc.description,"; $sql .= " rc.fk_facture_source,"; $sql .= " u.login, u.rowid as user_id,"; @@ -510,7 +520,7 @@ if ($socid > 0) { print '
    '.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''.price($obj->amount_ttc).''.price($obj->multicurrency_amount_ht).''.vatrate($obj->tva_tx, true).''.vatrate($obj->tva_tx.($obj->vat_src_code ? ' ('.$obj->vat_src_code.')' : ''), true).''.price($obj->amount_ttc).'
    '.$langs->trans("Project").''; - $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0); + $numprojet = $formproject->select_projects(($soc->id > 0 ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, 'maxwidth500'); print ' id).'">'; print '
    '; if ($action == 'editdate') { print '
    '; - print ''; + print ''; print ''; print $form->selectDate($object->date, 'order_', '', '', '', "setdate"); print ''; @@ -2198,7 +2205,7 @@ if ($action == 'create' && $usercancreate) print '
    '; if ($action == 'editdate_livraison') { print ''; - print ''; + print ''; print ''; print $form->selectDate($object->date_livraison ? $object->date_livraison : - 1, 'liv_', '', '', '', "setdate_livraison"); print ''; @@ -2492,7 +2499,7 @@ if ($action == 'create' && $usercancreate) $result = $object->getLinesArray(); print ' - + '; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 60c9e23710b..289bbea2c7e 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -64,7 +64,7 @@ class Orders extends DolibarrApi */ public function get($id, $contact_list = 1) { - return $this->_fetch($id, '', '', '', $contact_list); + return $this->_fetch($id, '', '', $contact_list); } /** @@ -82,7 +82,7 @@ class Orders extends DolibarrApi */ public function getByRef($ref, $contact_list = 1) { - return $this->_fetch('', $ref, '', '', $contact_list); + return $this->_fetch('', $ref, '', $contact_list); } /** @@ -100,7 +100,7 @@ class Orders extends DolibarrApi */ public function getByRefExt($ref_ext, $contact_list = 1) { - return $this->_fetch('', '', $ref_ext, '', $contact_list); + return $this->_fetch('', '', $ref_ext, $contact_list); } /** @@ -111,24 +111,23 @@ class Orders extends DolibarrApi * @param int $id ID of order * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param string $ref_int Internal reference of other objec * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @return array|mixed data without useless information * * @throws RestException */ - private function _fetch($id, $ref = '', $ref_ext = '', $ref_int = '', $contact_list = 1) + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - $result = $this->commande->fetch($id, $ref, $ref_ext, $ref_int); - if( ! $result ) { + $result = $this->commande->fetch($id, $ref, $ref_ext); + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -151,7 +150,8 @@ class Orders extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of order objects * - * @throws RestException + * @throws RestException 404 Not found + * @throws RestException 503 Error */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { @@ -164,18 +164,18 @@ class Orders extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."commande as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as t"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale - $sql.= ' WHERE t.entity IN ('.getEntity('commande').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + $sql .= ' WHERE t.entity IN ('.getEntity('commande').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql .= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter if ($search_sale > 0) { @@ -184,23 +184,23 @@ class Orders extends DolibarrApi // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { + $sql .= $db->order($sortfield, $sortorder); + if ($limit) { if ($page < 0) { $page = 0; } $offset = $limit * $page; - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); } dol_syslog("API Rest request"); @@ -210,12 +210,12 @@ class Orders extends DolibarrApi { $num = $db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; + $i = 0; while ($i < $min) { $obj = $db->fetch_object($result); $commande_static = new Commande($db); - if($commande_static->fetch($obj->rowid)) { + if ($commande_static->fetch($obj->rowid)) { // Add external contacts ids $commande_static->contacts_ids = $commande_static->liste_contact(-1, 'external', 1); $obj_ret[] = $this->_cleanObjectDatas($commande_static); @@ -226,7 +226,7 @@ class Orders extends DolibarrApi else { throw new RestException(503, 'Error when retrieve commande list : '.$db->lasterror()); } - if( ! count($obj_ret)) { + if (!count($obj_ret)) { throw new RestException(404, 'No order found'); } return $obj_ret; @@ -240,13 +240,13 @@ class Orders extends DolibarrApi */ public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->commande->$field = $value; } /*if (isset($request_data["lines"])) { @@ -275,16 +275,16 @@ class Orders extends DolibarrApi */ public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (!DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->commande->getLinesArray(); @@ -307,16 +307,16 @@ class Orders extends DolibarrApi */ public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -369,16 +369,16 @@ class Orders extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $request_data = (object) $request_data; @@ -431,16 +431,16 @@ class Orders extends DolibarrApi */ public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -470,16 +470,16 @@ class Orders extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -508,16 +508,16 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -540,19 +540,19 @@ class Orders extends DolibarrApi */ public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (! $result) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->commande->$field = $value; } @@ -581,19 +581,19 @@ class Orders extends DolibarrApi */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->commande->supprimer) { + if (!DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( ! $this->commande->delete(DolibarrApiAccess::$user)) { + if (!$this->commande->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting order : '.$this->commande->error); } @@ -629,15 +629,15 @@ class Orders extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -649,11 +649,11 @@ class Orders extends DolibarrApi throw new RestException(500, 'Error when validating Order: '.$this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -682,21 +682,21 @@ class Orders extends DolibarrApi public function reopen($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->set_reopen(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); - }elseif( $result == 0) { + }elseif ($result == 0) { throw new RestException(304); } @@ -720,28 +720,28 @@ class Orders extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Order ID is mandatory'); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } $result = $this->commande->classifyBilled(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(400, $this->commande->error); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -762,15 +762,15 @@ class Orders extends DolibarrApi */ public function close($id, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -783,11 +783,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -808,15 +808,15 @@ class Orders extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -829,11 +829,11 @@ class Orders extends DolibarrApi } $result = $this->commande->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -860,26 +860,26 @@ class Orders extends DolibarrApi public function createOrderFromProposal($proposalid) { - require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; + require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; - if(! DolibarrApiAccess::$user->rights->propal->lire) { + if (!DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } - if(empty($proposalid)) { + if (empty($proposalid)) { throw new RestException(400, 'Proposal ID is mandatory'); } $propal = new Propal($this->db); $result = $propal->fetch($proposalid); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } $result = $this->commande->createFromProposal($propal, DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(405, $this->commande->error); } $this->commande->fetchObjectLinked(); @@ -922,7 +922,7 @@ class Orders extends DolibarrApi $commande = array(); foreach (Orders::$FIELDS as $field) { if (!isset($data[$field])) - throw new RestException(400, $field ." field missing"); + throw new RestException(400, $field." field missing"); $commande[$field] = $data[$field]; } return $commande; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index b19210f894a..b2d1c09bd25 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -101,6 +101,7 @@ class Commande extends CommonOrder /** * @var string Internal ref for order + * @deprecated */ public $ref_int; @@ -232,6 +233,94 @@ class Commande extends CommonOrder //! key of pos source ('0', '1', ...) public $pos_source; + + /** + * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') + * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'position' is the sort order of field. + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created. + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code. + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * + * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. + */ + + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), + 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>25), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>26), + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>27), // deprecated + 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>28), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>56), + 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'date_cloture' =>array('type'=>'datetime', 'label'=>'DateClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'date_commande' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>70), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>80), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosing', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'source' =>array('type'=>'smallint(6)', 'label'=>'Source', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + //'amount_ht' =>array('type'=>'double(24,8)', 'label'=>'AmountHT', 'enabled'=>1, 'visible'=>-1, 'position'=>105), + 'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>110), + 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>115), + //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>120), + 'tva' =>array('type'=>'double(24,8)', 'label'=>'VAT', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LocalTax1', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LocalTax2', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), + 'total_ht' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), + 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>145, 'isameasure'=>1), + 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>150), + 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>155), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>160), + //'facture' =>array('type'=>'tinyint(4)', 'label'=>'ParentInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>165), + 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>1, 'visible'=>-1, 'position'=>170), + 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>175), + 'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>180), + 'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>190), + 'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>195), + 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>1, 'visible'=>-1, 'position'=>200), + 'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>205), + 'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>210), + //'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>225), + 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>230), + 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLabel', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>235), + 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'Fk multicurrency', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>240), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCurrency', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>245), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>250, 'isameasure'=>1), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountHT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>255, 'isameasure'=>1), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>260, 'isameasure'=>1), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>265, 'isameasure'=>1), + 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>270), + 'module_source' =>array('type'=>'varchar(32)', 'label'=>'POSModule', 'enabled'=>1, 'visible'=>-1, 'position'=>275), + 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>280), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), + ); + // END MODULEBUILDER PROPERTIES + /** * ERR Not enough stock */ @@ -384,7 +473,7 @@ class Commande extends CommonOrder { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; @@ -927,6 +1016,14 @@ class Commande extends CommonOrder $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -951,8 +1048,8 @@ class Commande extends CommonOrder $line->label, $line->array_options, $line->fk_unit, - $this->element, - $line->id + $origintype, + $originid ); if ($result < 0) { @@ -1284,7 +1381,7 @@ class Commande extends CommonOrder $this->origin_id = $object->id; // get extrafields from original line - $object->fetch_optionals($object->id); + $object->fetch_optionals(); $e = new ExtraFields($this->db); $element_extrafields = $e->fetch_name_optionals_label($this->table_element); @@ -1355,8 +1452,8 @@ class Commande extends CommonOrder * @param string $label Label * @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * @param string $fk_unit Code of the unit to use. Null to use the default one - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency * @return int >0 if OK, <0 if KO * @@ -1685,13 +1782,13 @@ class Commande extends CommonOrder * @param int $id Id of object to load * @param string $ref Ref of object * @param string $ref_ext External reference of object - * @param string $ref_int Internal reference of other object + * @param string $notused Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $notused = '') { // Check parameters - if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; + if (empty($id) && empty($ref) && empty($ref_ext)) return -1; $sql = 'SELECT c.rowid, c.entity, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_user_valid, c.fk_statut'; $sql .= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva as total_tva, c.localtax1 as total_localtax1, c.localtax2 as total_localtax2, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_availability, c.fk_input_reason'; @@ -1722,7 +1819,7 @@ class Commande extends CommonOrder if ($ref) $sql .= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND c.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND c.ref_int='".$this->db->escape($ref_int)."'"; + if ($notused) $sql .= " AND c.ref_int='".$this->db->escape($notused)."'"; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -3516,7 +3613,7 @@ class Commande extends CommonOrder if ($status == self::STATUS_CANCELED) { $labelStatus = $langs->trans('StatusOrderCanceled'); $labelStatusShort = $langs->trans('StatusOrderCanceledShort'); - $statusType = 'status5'; + $statusType = 'status9'; } elseif ($status == self::STATUS_DRAFT) { $labelStatus = $langs->trans('StatusOrderDraft'); @@ -3531,7 +3628,7 @@ class Commande extends CommonOrder elseif ($status == self::STATUS_SHIPMENTONPROCESS) { $labelStatus = $langs->trans('StatusOrderSentShort').$billedtext; $labelStatusShort = $langs->trans('StatusOrderSentShort').$billedtext; - $statusType = 'status3'; + $statusType = 'status4'; } elseif ($status == self::STATUS_CLOSED && (!$billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) { $labelStatus = $langs->trans('StatusOrderToBill'); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 0311f4c49ed..8b6dc4db6ec 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -23,10 +23,10 @@ * \ingroup commandes * \brief File of class to manage order statistics */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** @@ -67,31 +67,31 @@ class CommandeStats extends Stats if ($mode == 'customer') { - $object=new Commande($this->db); + $object = new Commande($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled } elseif ($mode == 'supplier') { - $object=new CommandeFournisseur($this->db); + $object = new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; - $this->where.= " c.fk_statut > 2"; // Only approved & ordered + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; + $this->where .= " c.fk_statut > 2"; // Only approved & ordered } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; - $this->where.= ' AND c.entity IN ('.getEntity('commande').')'; + $this->where .= ' AND c.entity IN ('.getEntity('commande').')'; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; if ($this->socid) { - $this->where.=" AND c.fk_soc = ".$this->socid; + $this->where .= " AND c.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + if ($this->userid > 0) $this->where .= ' AND c.fk_user_author = '.$this->userid; } /** @@ -106,14 +106,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); return $res; } @@ -128,11 +128,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -149,14 +149,14 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); return $res; } @@ -171,12 +171,12 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%m') as dm, AVG(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -191,11 +191,11 @@ class CommandeStats extends Stats global $user; $sql = "SELECT date_format(c.date_commande,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -203,23 +203,24 @@ class CommandeStats extends Stats /** * Return nb, amount of predefined product for year * - * @param int $year Year to scan - * @return array Array of values + * @param int $year Year to scan + * @param int $limit Limit + * @return array Array of values */ - public function getAllByProduct($year) + public function getAllByProduct($year, $limit = 10) { global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND c.rowid = tl.fk_commande AND tl.fk_product = product.rowid"; + $sql .= " AND c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/commande/customer.php b/htdocs/commande/customer.php index f6594b5694a..4da1ea48fd6 100644 --- a/htdocs/commande/customer.php +++ b/htdocs/commande/customer.php @@ -48,7 +48,7 @@ $langs->loadLangs(array("companies", "orders")); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -162,13 +162,13 @@ if ($resql) print '
    '; - $result=''; - $link=$linkend=''; - $link = ''; - $linkend=''; - $name=$obj->name; - $result.=($link.img_object($langs->trans("ShowCompany").': '.$name, 'company').$linkend); - $result.=$link.(dol_trunc($name, $maxlen)).$linkend; + $result=''; + $link=$linkend=''; + $link = ''; + $linkend=''; + $name=$obj->name; + $result.=($link.img_object($langs->trans("ShowCompany").': '.$name, 'company').$linkend); + $result.=$link.(dol_trunc($name, $maxlen)).$linkend; print $result; print '
    '; print ''."\n"; $listofstatus=array(0,1,2,3,-1); foreach ($listofstatus as $status) { - $dataseries[]=array($commandestatic->LibStatut($status, $bool, 1), (isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); + $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); + if ($status == Commande::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0; + if ($status == Commande::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1; + if ($status == Commande::STATUS_SHIPMENTONPROCESS) $colorseries[$status] = $badgeStatus4; + if ($status == Commande::STATUS_CLOSED && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CLOSED && (!empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) $colorseries[$status] = $badgeStatus6; + if ($status == Commande::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9; + + if (empty($conf->use_javascript_ajax)) + { + print ''; + print ''; + print ''; + print "\n"; + } } if ($conf->use_javascript_ajax) { @@ -140,28 +158,16 @@ if ($resql) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($total ? 0 : 1); print ''; } - else - { - foreach ($listofstatus as $status) - { - print ''; - print ''; - print ''; - print "\n"; - } - } //if ($totalinprocess != $total) print ''; print "
    '.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
    '.$commandestatic->LibStatut($status, 0, 0, 1).''.(isset($vals[$status]) ? $vals[$status] : 0).' '; + print $commandestatic->LibStatut($status, 0, 3, 1); + print '
    '.$commandestatic->LibStatut($status, $bool, 0).''.(isset($vals[$status.$bool]) ? $vals[$status.$bool] : 0).' '; - print $commandestatic->LibStatut($status, $bool, 3); - print ''; - print '
    '.$langs->trans("Total").''.$total.'

    "; @@ -202,7 +208,6 @@ if (!empty($conf->commande->enabled)) if ($num) { $i = 0; - $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -241,7 +246,7 @@ print '
    '; $max = 5; /* - * Last modified orders + * Lattest modified orders */ $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,"; @@ -272,7 +277,6 @@ if ($resql) if ($num) { $i = 0; - $var = true; while ($i < $num) { $obj = $db->fetch_object($resql); @@ -311,7 +315,7 @@ if ($resql) print $companystatic->getNomUrl(1, 'company', 16); print '
    '.dol_print_date($db->jdate($obj->datem), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 5).''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
    '; print ''; - print ''; + print ''; if ($num) { $i = 0; - $var = true; - while ($i < $num) + while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); print ''; @@ -390,11 +395,16 @@ if (!empty($conf->commande->enabled)) print $companystatic->getNomUrl(1, 'company', 24); print ''; - print ''; + print ''."\n"; + + print ''; print ''; $i++; } + if ($i < $num) { + print ''; + } } print "
    '.$langs->trans("OrdersToProcess").' '.$num.'
    '.$langs->trans("OrdersToProcess").' '.$num.'
    '.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 5).''.dol_print_date($db->jdate($obj->date), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
    '.$langs->trans("More").'...

    "; @@ -403,11 +413,11 @@ if (!empty($conf->commande->enabled)) } /* - * Orders thar are in a shipping process + * Orders that are in process */ if (!empty($conf->commande->enabled)) { - $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, s.nom as name, s.rowid as socid"; + $sql = "SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid"; $sql .= ", s.client"; $sql .= ", s.code_client"; $sql .= ", s.canvas"; @@ -416,7 +426,7 @@ if (!empty($conf->commande->enabled)) if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE c.fk_soc = s.rowid"; $sql .= " AND c.entity IN (".getEntity('commande').")"; - $sql .= " AND c.fk_statut = 2 "; + $sql .= " AND c.fk_statut = ".Commande::STATUS_ACCEPTED; if ($socid) $sql .= " AND c.fk_soc = ".$socid; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; $sql .= " ORDER BY c.rowid DESC"; @@ -429,13 +439,12 @@ if (!empty($conf->commande->enabled)) print '
    '; print ''; print ''; - print ''; + print ''; if ($num) { $i = 0; - $var = true; - while ($i < $num) + while ($i < $num && $i < $max) { $obj = $db->fetch_object($resql); print ''; @@ -472,11 +481,16 @@ if (!empty($conf->commande->enabled)) print $companystatic->getNomUrl(1, 'company'); print ''; - print ''; + print ''."\n"; + + print ''; print ''; $i++; } + if ($i < $num) { + print ''; + } } print "
    '.$langs->trans("OnProcessOrders").' '.$num.'
    '.$langs->trans("OnProcessOrders").' '.$num.'
    '.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 5).''.dol_print_date($db->jdate($obj->date), 'day').''.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'
    '.$langs->trans("More").'...

    "; } diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 845bc4603cd..8448da5b022 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -74,7 +74,13 @@ $socid = GETPOST('socid', 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); $search_total_ht = GETPOST('search_total_ht', 'alpha'); +$search_total_vat = GETPOST('search_total_vat', 'alpha'); $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_login = GETPOST('search_login', 'alpha'); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); @@ -96,7 +102,7 @@ $diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/ma $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -141,6 +147,11 @@ $arrayfields = array( 'c.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'c.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1)), 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>10), 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), @@ -197,6 +208,11 @@ if (empty($reshook)) $search_total_ht = ''; $search_total_vat = ''; $search_total_ttc = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; $search_login = ''; $search_dateorder_start = ''; $search_dateorder_end = ''; @@ -250,6 +266,7 @@ $sql .= ' s.rowid as socid, s.nom as name, s.email, s.town, s.zip, s.fk_pays, s. $sql .= " typent.code as typent_code,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; $sql .= ' c.rowid, c.ref, c.total_ht, c.tva as total_tva, c.total_ttc, c.ref_client, c.fk_user_author,'; +$sql .= ' c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva as multicurrency_total_vat, c.multicurrency_total_ttc,'; $sql .= ' c.date_valid, c.date_commande, c.note_private, c.date_livraison as date_delivery, c.fk_statut, c.facture as billed,'; $sql .= ' c.date_creation as date_creation, c.tms as date_update, c.date_cloture as date_cloture,'; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label,"; @@ -314,25 +331,31 @@ if ($viewstatut <> '') } } -if ($search_dateorder_start) $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; -if ($search_dateorder_end) $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; -if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; -if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; -if ($search_town) $sql .= natural_search('s.town', $search_town); -if ($search_zip) $sql .= natural_search("s.zip", $search_zip); -if ($search_state) $sql .= natural_search("state.nom", $search_state); -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -if ($search_company) $sql .= natural_search('s.nom', $search_company); -if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; -if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; -if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); -if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); -if ($search_login) $sql .= natural_search("u.login", $search_login); -if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); -if ($search_project != '') $sql .= natural_search("p.title", $search_project); -if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); -if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; +if ($search_dateorder_start) $sql .= " AND c.date_commande >= '".$db->idate($search_dateorder_start)."'"; +if ($search_dateorder_end) $sql .= " AND c.date_commande <= '".$db->idate($search_dateorder_end)."'"; +if ($search_datedelivery_start) $sql .= " AND c.date_livraison >= '".$db->idate($search_datedelivery_start)."'"; +if ($search_datedelivery_end) $sql .= " AND c.date_livraison <= '".$db->idate($search_datedelivery_end)."'"; +if ($search_town) $sql .= natural_search('s.town', $search_town); +if ($search_zip) $sql .= natural_search("s.zip", $search_zip); +if ($search_state) $sql .= natural_search("state.nom", $search_state); +if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; +if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; +if ($search_company) $sql .= natural_search('s.nom', $search_company); +if ($search_sale > 0) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale; +if ($search_user > 0) $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='commande' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".$search_user; +if ($search_total_ht != '') $sql .= natural_search('c.total_ht', $search_total_ht, 1); +if ($search_total_vat != '') $sql .= natural_search('c.tva', $search_total_vat, 1); +if ($search_total_ttc != '') $sql .= natural_search('c.total_ttc', $search_total_ttc, 1); +if ($search_multicurrency_code != '') $sql .= ' AND c.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('c.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('c.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('c.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('c.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); +if ($search_login) $sql .= natural_search("u.login", $search_login); +if ($search_project_ref != '') $sql .= natural_search("p.ref", $search_project_ref); +if ($search_project != '') $sql .= natural_search("p.title", $search_project); +if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); +if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -424,6 +447,11 @@ if ($resql) if ($search_total_ht != '') $param .= '&search_total_ht='.urlencode($search_total_ht); if ($search_total_vat != '') $param .= '&search_total_vat='.urlencode($search_total_vat); if ($search_total_ttc != '') $param .= '&search_total_ttc='.urlencode($search_total_ttc); + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); if ($search_login) $param .= '&search_login='.urlencode($search_login); if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); if ($search_town != '') $param .= '&search_town='.urlencode($search_town); @@ -697,6 +725,41 @@ if ($resql) print ''; print ''; } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) + { + // Currency + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) + { + // Currency rate + print ''; + print ''; + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) + { + // Amount + print ''; + print ''; + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) + { + // Amount + print ''; + print ''; + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) + { + // Amount + print ''; + print ''; + print ''; + } if (!empty($arrayfields['u.login']['checked'])) { // Author @@ -775,6 +838,11 @@ if ($resql) if (!empty($arrayfields['c.total_ht']['checked'])) print_liste_field_titre($arrayfields['c.total_ht']['label'], $_SERVER["PHP_SELF"], 'c.total_ht', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_vat']['checked'])) print_liste_field_titre($arrayfields['c.total_vat']['label'], $_SERVER["PHP_SELF"], 'c.tva', '', $param, '', $sortfield, $sortorder, 'right '); if (!empty($arrayfields['c.total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.total_ttc']['label'], $_SERVER["PHP_SELF"], 'c.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($arrayfields['c.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['c.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'c.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); if (!empty($arrayfields['u.login']['checked'])) print_liste_field_titre($arrayfields['u.login']['label'], $_SERVER["PHP_SELF"], 'u.login', '', $param, 'align="center"', $sortfield, $sortorder); // Extra fields @@ -1097,6 +1165,40 @@ if ($resql) $totalarray['val']['c.total_ttc'] += $obj->total_ttc; } + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) + { + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) + { + print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) + { + print ''.price($obj->multicurrency_total_ht)."\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) + { + print ''.price($obj->multicurrency_total_vat)."\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) + { + print ''.price($obj->multicurrency_total_ttc)."\n"; + if (!$i) $totalarray['nbfield']++; + } + $userstatic->id = $obj->fk_user_author; $userstatic->login = $obj->login; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index a473ccbb993..764b31ad0f6 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -287,7 +287,7 @@ if (($action == 'create' || $action == 'add') && !$error) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index e9eca9dafa9..c465cdcb8c9 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -255,7 +255,9 @@ print '
    '; // Show filter box print ''; +print ''; print ''; + print ''; print ''; // Company diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index bab53a8f77b..318db920a52 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -16,11 +16,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -/** + + /** * \file htdocs/compta/accounting-files.php * \ingroup compta * \brief Page to show portoflio and files of a thirdparty and download it */ + +if ($_GET['action'] == 'dl' || $_POST['action'] == 'dl') { // To not replace token when downloading file + if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +} + require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -54,7 +60,7 @@ $hookmanager->initHooks(array('comptafileslist', 'globallist')); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -66,7 +72,14 @@ if (!$sortorder) $sortorder = "DESC"; $arrayfields = array( 'type'=>array('label'=>"Type", 'checked'=>1), 'date'=>array('label'=>"Date", 'checked'=>1), - //... + 'date_due'=>array('label'=>"DateDue", 'checked'=>1), + 'ref'=>array('label'=>"Ref", 'checked'=>1), + 'documents'=>array('label'=>"Documents", 'checked'=>1), + 'paid'=>array('label'=>"Paid", 'checked'=>1), + 'total_ht'=>array('label'=>"TotalHT", 'checked'=>1), + 'total_ttc'=>array('label'=>"TotalTTC", 'checked'=>1), + 'total_vat'=>array('label'=>"TotalVAT", 'checked'=>1), + //... ); // Security check @@ -106,7 +119,7 @@ $error = 0; $filesarray = array(); $result = false; -if (($action == "searchfiles" || $action == "dl")) { +if (($action == 'searchfiles' || $action == 'dl')) { if (empty($date_start)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateStart")), null, 'errors'); @@ -126,8 +139,8 @@ if (($action == "searchfiles" || $action == "dl")) { // Customer invoices if (GETPOST('selectinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, total as total_ht, total_ttc, tva as total_vat, fk_soc, t.datef as date, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= "SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total as total_ht, t.total_ttc, t.tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'Invoice' as item, s.nom as thirdparty_name, s.code_client as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -135,8 +148,8 @@ if (($action == "searchfiles" || $action == "dl")) { } // Vendor invoices if (GETPOST('selectsupplierinvoices')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, paye as paid, total_ht, total_ttc, total_tva as total_vat, fk_soc, datef as date, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paye as paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_soc, t.datef as date, t.date_lim_reglement as date_due, 'SupplierInvoice' as item, s.nom as thirdparty_name, s.code_fournisseur as thirdparty_code, c.code as country_code, s.tva_intra as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as t LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = t.fk_soc LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = s.fk_pays"; $sql .= " WHERE datef between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -144,8 +157,8 @@ if (($action == "searchfiles" || $action == "dl")) { } // Expense reports if (GETPOST('selectexpensereports')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, total_ht, total_ttc, total_tva as total_vat, fk_user_author as fk_soc, date_fin as date, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, t.paid, t.total_ht, t.total_ttc, t.total_tva as total_vat, t.fk_user_author as fk_soc, t.date_fin as date, t.date_fin as date_due, 'ExpenseReport' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user_author LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE date_fin between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -153,8 +166,8 @@ if (($action == "searchfiles" || $action == "dl")) { } // Donations if (GETPOST('selectdonations')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, datedon as date, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref, paid, amount as total_ht, amount as total_ttc, 0 as total_vat, 0 as fk_soc, t.datedon as date, t.datedon as date_due, 'Donation' as item, t.societe as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."don as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_country"; $sql .= " WHERE datedon between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -162,8 +175,8 @@ if (($action == "searchfiles" || $action == "dl")) { } // Paiements of salaries if (GETPOST('selectpaymentsofsalaries')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, datep as date, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.ref as ref, 1 as paid, amount as total_ht, amount as total_ttc, 0 as total_vat, t.fk_user as fk_soc, t.datep as date, t.dateep as date_due, 'SalaryPayment' as item, CONCAT(CONCAT(u.lastname, ' '), u.firstname) as thirdparty_name, '' as thirdparty_code, c.code as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = t.fk_user LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = u.fk_country"; $sql .= " WHERE datep between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -171,8 +184,8 @@ if (($action == "searchfiles" || $action == "dl")) { } // Social contributions if (GETPOST('selectsocialcontributions')) { - if (! empty($sql)) $sql .= " UNION ALL"; - $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, paye as paid, amount as total_ht, amount as total_ttc, 0 as total_tva, 0 as fk_soc, date_creation as date, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; + if (!empty($sql)) $sql .= " UNION ALL"; + $sql .= " SELECT t.rowid as id, t.entity, t.libelle as ref, t.paye as paid, t.amount as total_ht, t.amount as total_ttc, 0 as total_tva, 0 as fk_soc, t.date_creation as date, t.date_ech as date_due, 'SocialContributions' as item, '' as thirdparty_name, '' as thirdparty_code, '' as country_code, '' as vatnum"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as t"; $sql .= " WHERE date_creation between ".$wheretail; $sql .= " AND t.entity IN (".($entity == 1 ? '0,1' : $entity).')'; @@ -252,7 +265,7 @@ if (($action == "searchfiles" || $action == "dl")) { { $result = true; - $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + $files = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', '', SORT_ASC, 1); //var_dump($upload_dir); //var_dump($files); if (count($files) < 1) @@ -261,7 +274,8 @@ if (($action == "searchfiles" || $action == "dl")) { $nofile['id'] = $objd->id; $nofile['entity'] = $objd->entity; $nofile['date'] = $db->idate($objd->date); - $nofile['paid'] = $objd->paid; + $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; $nofile['amount_ttc'] = $objd->total_ttc; $nofile['amount_vat'] = $objd->total_vat; @@ -282,7 +296,8 @@ if (($action == "searchfiles" || $action == "dl")) { $file['id'] = $objd->id; $file['entity'] = $objd->entity; $file['date'] = $db->idate($objd->date); - $file['paid'] = $objd->paid; + $file['date_due'] = $db->idate($objd->date_due); + $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; $file['amount_ttc'] = $objd->total_ttc; $file['amount_vat'] = $objd->total_vat; @@ -357,12 +372,14 @@ if ($result && $action == "dl" && !$error) $log .= ','.$langs->transnoentitiesnoconv("Entity"); } $log .= ','.$langs->transnoentitiesnoconv("Date"); + $log .= ','.$langs->transnoentitiesnoconv("DateDue"); $log .= ','.$langs->transnoentitiesnoconv("Ref"); $log .= ','.$langs->transnoentitiesnoconv("TotalHT"); $log .= ','.$langs->transnoentitiesnoconv("TotalTTC"); $log .= ','.$langs->transnoentitiesnoconv("TotalVAT"); $log .= ','.$langs->transnoentitiesnoconv("Paid"); - $log .= ',filename,item_id'; + $log .= ','.$langs->transnoentitiesnoconv("Document"); + $log .= ','.$langs->transnoentitiesnoconv("ItemID"); $log .= ','.$langs->transnoentitiesnoconv("ThirdParty"); $log .= ','.$langs->transnoentitiesnoconv("Code"); $log .= ','.$langs->transnoentitiesnoconv("Country"); @@ -389,6 +406,7 @@ if ($result && $action == "dl" && !$error) $log .= ',"'.(empty($arrayofentities[$file['entity']]) ? $file['entity'] : $arrayofentities[$file['entity']]).'"'; } $log .= ','.dol_print_date($file['date'], 'dayrfc'); + $log .= ','.dol_print_date($file['date_due'], 'dayrfc'); $log .= ',"'.$file['ref'].'"'; $log .= ','.$file['amount_ht']; $log .= ','.$file['amount_ttc']; @@ -397,7 +415,7 @@ if ($result && $action == "dl" && !$error) $log .= ',"'.$file["name"].'"'; $log .= ','.$file['fk']; $log .= ',"'.$file['thirdparty_name'].'"'; - $log .= ','.$file['thirdparty_code']; + $log .= ',"'.$file['thirdparty_code'].'"'; $log .= ',"'.$file['country_code'].'"'; $log .= ',"'.$file['vatnum'].'"'; $log .= "\n"; @@ -428,6 +446,8 @@ if ($result && $action == "dl" && !$error) $form = new Form($db); $userstatic = new User($db); +$invoice = new Facture($db); +$supplier_invoice = new FactureFournisseur($db); $title = $langs->trans("ComptaFiles").' - '.$langs->trans("List"); $help_url = ''; @@ -453,7 +473,7 @@ print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n if (!empty($conf->multicompany->enabled) && is_object($mc)) { $mc->getInfo($conf->entity); - print '('.$langs->trans("Entity").' : '; + print '('.$langs->trans("Entity").' : '; print "'; print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "item", "", $param, '', $sortfield, $sortorder, 'nowrap '); print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, '', $sortfield, $sortorder, 'center nowrap '); - print ''; + print_liste_field_titre($arrayfields['date_due']['label'], $_SERVER["PHP_SELF"], "date_due", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + print_liste_field_titre($arrayfields['ref']['label'], $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'nowraponall '); print ''; print ''; print ''; @@ -563,8 +584,26 @@ if (!empty($date_start) && !empty($date_stop)) print dol_print_date($data['date'], 'day'); print "\n"; + // Date + print '\n"; + // Ref - print ''; + print ''; // File link print ''; print ''; print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 08447216dda..4c1d06e37fa 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -59,7 +59,7 @@ if ($user->socid) // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; @@ -137,9 +137,9 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; $permission = $user->rights->banque->modifier; $permtoedit = $user->rights->banque->modifier; - $param = '&id='.$object->id.'&num='.$num; - $uri = '&num='.$num; - $relativepathwithnofile = $id."/statement/".$num."/"; + $param = '&id='.$object->id.'&num='.urlencode($num); + $moreparam = '&num='.urlencode($num);; + $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/"; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 297f0dd91d4..26563f98dd4 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -98,7 +98,7 @@ if (empty($dateop)) $dateop = -1; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $pageplusone = GETPOST("pageplusone", 'int'); if ($pageplusone) $page = $pageplusone - 1; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -1157,14 +1157,14 @@ if ($resql) } else { $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR1; } - $backgroundcolor = 'style="background-color: '.$color.';"'; + $backgroundcolor = 'style="background: '.$color.';"'; } else { if (empty($conf->global->BANK_COLORIZE_MOVEMENT_COLOR2)) { $color = '#7fdb86'; } else { $color = '#'.$conf->global->BANK_COLORIZE_MOVEMENT_COLOR2; } - $backgroundcolor = 'style="background-color: '.$color.';"'; + $backgroundcolor = 'style="background: '.$color.';"'; } } print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 6fc0efbd6e0..60d7c4f2463 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1337,6 +1337,10 @@ class Account extends CommonObject $label .= '
    '.$langs->trans('AccountAccounting').': '.length_accountg($this->account_number); $label .= '
    '.$langs->trans('AccountancyJournal').': '.$this->accountancy_journal; } + if (isset($this->status)) { + $label .= '
    '.$langs->trans("Status").": ".$this->getLibStatut(5); + } + $linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $url = DOL_URL_ROOT.'/compta/bank/card.php?id='.$this->id; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index b70a3ba2c77..022e1ceea5a 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -56,7 +56,7 @@ if ($user->socid) // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 2e1f36cbeea..ccf677fa2b8 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -350,10 +350,11 @@ else } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; - if ($xday == '15') + /*if ($xday == '15') // Set only some label for jflot { $labels[$i] = dol_print_date($day, "%b"); - } + }*/ + $labels[$i] = dol_print_date($day, "%Y%m"); $day += 86400; $textdate = strftime("%Y%m%d", $day); $xyear = substr($textdate, 0, 4); @@ -465,10 +466,11 @@ else } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; - if (substr($textdate, 6, 2) == '01' || $i == 0) + /*if (substr($textdate, 6, 2) == '01' || $i == 0) // Set only few label for jflot { - $labels[$i] = substr($textdate, 4, 2); - } + $labels[$i] = substr($textdate, 0, 6); + }*/ + $labels[$i] = substr($textdate, 0, 6); $day += 86400; $textdate = strftime("%Y%m%d", $day); @@ -815,6 +817,8 @@ else } print '

    '; +print '
    '.$langs->trans("Filter").'
    "; if (!empty($conf->global->MULTICOMPANY_ALLOW_EXPORT_ACCOUNTING_DOC_FOR_ALL_ENTITIES)) { print $mc->select_entities(GETPOSTISSET('search_entity') ? GETPOST('search_entity', 'int') : $mc->id, 'search_entity', '', false, false, false, false, true); @@ -474,11 +494,9 @@ $listofchoices = array( 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), 'selectsocialcontributions'=>array('label'=>'SocialContributions') ); -foreach($listofchoices as $choice => $val) { - /*if ($val['lang']) { - $langs->load($val['lang']); - }*/ - print '
    '.$langs->trans($val['label']).'
    '; +foreach ($listofchoices as $choice => $val) { + $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); + print '
    '.$langs->trans($val['label']).'
    '; } print ''; @@ -496,15 +514,17 @@ if (!empty($date_start) && !empty($date_stop)) $param .= '&date_stopday='.GETPOST('date_stopday', 'int'); $param .= '&date_stopmonth='.GETPOST('date_stopmonth', 'int'); $param .= '&date_stopyear='.GETPOST('date_stopyear', 'int'); - + foreach ($listofchoices as $choice => $val) { + $param .= '&'.$choice.'='.(GETPOST($choice, 'int') ? 1 : 0); + } print ''."\n"; - print ''; + print ''; echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); print ''; print ''; - foreach($listofchoices as $choice => $val) { + foreach ($listofchoices as $choice => $val) { print ''; } @@ -518,7 +538,8 @@ if (!empty($date_start) && !empty($date_stop)) print '
    '.$langs->trans("Ref").''.$langs->trans("Document").''.$langs->trans("Paid").''.$langs->trans("TotalHT").''; + print dol_print_date($data['date_due'], 'day'); + print "'.$data['ref'].''; + + if ($data['item'] == 'Invoice') { + $invoice->id = $data['id']; + $invoice->ref = $data['ref']; + print $invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } elseif ($data['item'] == 'SupplierInvoice') { + $supplier_invoice->id = $data['id']; + $supplier_invoice->ref = $data['ref']; + print $supplier_invoice->getNomUrl(1, '', 0, 0, '', 0, 0, 0); + } else { + print $data['ref']; + } + print ''; @@ -618,6 +657,7 @@ if (!empty($date_start) && !empty($date_stop)) print ''.price(price2num($totalET, 'MT')).''.price(price2num($totalIT, 'MT')).''.price(price2num($totalVAT, 'MT')).'
    '; + // Graphs if ($mode == 'standard') @@ -826,39 +830,39 @@ if ($mode == 'standard') // For month $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Month")." ".img_next('', 'class="valignbottom"').""; - print ''.$link.''; + print '
    '.$link.'
    '; - print ''; + print '
    '; $file = "movement".$account."-".$year.$month.".png"; print $show4; - print ''; + print '
    '; - print ''; + print '
    '; print $show1; - print ''; + print '
    '; // For year $prevyear = $year - 1; $nextyear = $year + 1; $link = "".img_previous('', 'class="valignbottom"')." ".$langs->trans("Year")." ".img_next('', 'class="valignbottom"').""; - print ''.$link.''; - print ''; + print '
    '.$link.'
    '; + + print '
    '; print $show5; - print ''; + print '
    '; - print ''; + print '
    '; print $show2; - print ''; + print '
    '; } if ($mode == 'showalltime') { - print ''; + print '
    '; print $show3; - print ''; + print '
    '; } -print ''; // End of page llxFooter(); diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 329ac25ef79..82728fc693d 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018 Ferran Marcet + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -30,36 +31,43 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; -if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingjournal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; // Load translation files required by the page $langs->loadLangs(array('banks', 'categories', 'accountancy', 'compta')); -$action=GETPOST('action', 'alpha'); -$massaction=GETPOST('massaction', 'alpha'); -$show_files=GETPOST('show_files', 'int'); -$confirm=GETPOST('confirm', 'alpha'); +$action = GETPOST('action', 'alpha'); +$massaction = GETPOST('massaction', 'alpha'); +$show_files = GETPOST('show_files', 'int'); +$confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); -$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bankaccountlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bankaccountlist'; // To manage different context of search -$search_ref=GETPOST('search_ref', 'alpha'); -$search_label=GETPOST('search_label', 'alpha'); -$search_number=GETPOST('search_number', 'alpha'); -$search_status=GETPOST('search_status')?GETPOST('search_status', 'alpha'):'opened'; // 'all' or ''='opened' +$search_ref = GETPOST('search_ref', 'alpha'); +$search_label = GETPOST('search_label', 'alpha'); +$search_number = GETPOST('search_number', 'alpha'); +$search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened' $optioncss = GETPOST('optioncss', 'alpha'); +if (!empty($conf->categorie->enabled)) +{ + $search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array"); +} + // Security check -if ($user->socid) $socid=$user->socid; -if (! empty($user->rights->accounting->chartofaccount)) $allowed=1; // Dictionary with list of banks accounting account allowed to manager of chart account -if (! $allowed) $result=restrictedArea($user, 'banque'); +if ($user->socid) $socid = $user->socid; +if (!empty($user->rights->accounting->chartofaccount)) $allowed = 1; // Dictionary with list of banks accounting account allowed to manager of chart account +if (!$allowed) $result = restrictedArea($user, 'banque'); -$diroutputmassaction=$conf->bank->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->bank->dir_output.'/temp/massgeneration/'.$user->id; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -74,7 +82,7 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( @@ -100,10 +108,10 @@ $arrayfields = array( // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $val) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - if (! empty($extrafields->attributes[$object->table_element]['list'][$key])) - $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key])!=3 && $extrafields->attributes[$object->table_element]['perms'][$key])); + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) + $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key])); } } $object->fields = dol_sort_array($object->fields, 'position'); @@ -138,38 +146,50 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -$form=new Form($db); +$form = new FormCategory($db); -$title=$langs->trans('BankAccounts'); +$title = $langs->trans('BankAccounts'); // Load array of financial accounts (opened by default) $accounts = array(); $sql = "SELECT b.rowid, b.label, b.courant, b.rappro, b.account_number, b.fk_accountancy_journal, b.currency_code, b.datec as date_creation, b.tms as date_update"; // Add fields from extrafields -if (! empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (!empty($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } // Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as b"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; -$sql.= " WHERE b.entity IN (".getEntity('bank_account').")"; -if ($search_status == 'opened') $sql.= " AND clos = 0"; -if ($search_status == 'closed') $sql.= " AND clos = 1"; -if ($search_ref != '') $sql.=natural_search('b.ref', $search_ref); -if ($search_label != '') $sql.=natural_search('b.label', $search_label); -if ($search_number != '') $sql.=natural_search('b.number', $search_number); +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; +$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as b"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (b.rowid = ef.fk_object)"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_ACCOUNT, "b.rowid"); +} + +$sql .= " WHERE b.entity IN (".getEntity('bank_account').")"; +if ($search_status == 'opened') $sql .= " AND clos = 0"; +if ($search_status == 'closed') $sql .= " AND clos = 1"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_ACCOUNT, "b.rowid", $search_category_list); +} + +if ($search_ref != '') $sql .= natural_search('b.ref', $search_ref); +if ($search_label != '') $sql .= natural_search('b.label', $search_label); +if ($search_number != '') $sql .= natural_search('b.number', $search_number); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; -$sql.= $db->order($sortfield, $sortorder); +$sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; @@ -263,6 +283,10 @@ if ($sall) $moreforfilter = ''; +if (!empty($conf->categorie->enabled)) +{ + $moreforfilter .= $form->getFilterBox(Categorie::TYPE_ACCOUNT, $search_category_list); +} // Bank accounts $parameters = array(); @@ -414,52 +438,52 @@ foreach ($accounts as $key=>$type) $solde = $objecttmp->solde(1); - if (! empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) + if (!empty($lastcurrencycode) && $lastcurrencycode != $objecttmp->currency_code) { - $lastcurrencycode='various'; // We found several different currencies + $lastcurrencycode = 'various'; // We found several different currencies } if ($lastcurrencycode != 'various') { - $lastcurrencycode=$objecttmp->currency_code; + $lastcurrencycode = $objecttmp->currency_code; } print ''; // Ref - if (! empty($arrayfields['b.ref']['checked'])) + if (!empty($arrayfields['b.ref']['checked'])) { print ''.$objecttmp->getNomUrl(1).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Label - if (! empty($arrayfields['b.label']['checked'])) + if (!empty($arrayfields['b.label']['checked'])) { print ''.$objecttmp->label.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account type - if (! empty($arrayfields['accountype']['checked'])) + if (!empty($arrayfields['accountype']['checked'])) { print ''; print $objecttmp->type_lib[$objecttmp->type]; print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Number - if (! empty($arrayfields['b.number']['checked'])) + if (!empty($arrayfields['b.number']['checked'])) { print ''.$objecttmp->number.''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Account number - if (! empty($arrayfields['b.account_number']['checked'])) + if (!empty($arrayfields['b.account_number']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->account_number)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->account_number)) { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $objecttmp->account_number, 1); @@ -470,14 +494,14 @@ foreach ($accounts as $key=>$type) print $objecttmp->account_number; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Accountancy journal - if (! empty($arrayfields['b.fk_accountancy_journal']['checked'])) + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { print ''; - if (! empty($conf->accounting->enabled) && ! empty($objecttmp->fk_accountancy_journal)) + if (!empty($conf->accounting->enabled) && !empty($objecttmp->fk_accountancy_journal)) { $accountingjournal = new AccountingJournal($db); $accountingjournal->fetch($objecttmp->fk_accountancy_journal); @@ -523,47 +547,47 @@ foreach ($accounts as $key=>$type) print ''.$langs->trans("FeatureDisabled").''; } print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp); // Note that $action and $objecttmpect may have been modified by hook print $hookmanager->resPrint; // Date creation - if (! empty($arrayfields['b.datec']['checked'])) + if (!empty($arrayfields['b.datec']['checked'])) { print ''; print dol_print_date($objecttmp->date_creation, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Date modification - if (! empty($arrayfields['b.tms']['checked'])) + if (!empty($arrayfields['b.tms']['checked'])) { print ''; print dol_print_date($objecttmp->date_update, 'dayhour'); print ''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Status - if (! empty($arrayfields['b.clos']['checked'])) + if (!empty($arrayfields['b.clos']['checked'])) { print ''.$objecttmp->getLibStatut(5).''; - if (! $i) $totalarray['nbfield']++; + if (!$i) $totalarray['nbfield']++; } // Balance - if (! empty($arrayfields['balance']['checked'])) + if (!empty($arrayfields['balance']['checked'])) { print ''; print ''.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).''; print ''; - if (! $i) $totalarray['nbfield']++; - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='balance'; + if (!$i) $totalarray['nbfield']++; + if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'balance'; $totalarray['val']['balance'] += $solde; } diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 9ae1d5d7d83..0350895ca0d 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -49,7 +49,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; $langs->loadLangs(array("banks", "categories", "companies", "bills", "trips", "donations", "loan")); $action = GETPOST('action', 'alpha'); -$id = GETPOST('account', 'int'); +$id = GETPOST('account', 'int') ? GETPOST('account', 'int') : GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $dvid = GETPOST('dvid', 'alpha'); $numref = GETPOST('num', 'alpha'); @@ -80,7 +80,7 @@ if ($user->rights->banque->consolidate && $action == 'dvprev' && !empty($dvid)) $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $pageplusone = GETPOST("pageplusone", 'int'); if ($pageplusone) $page = $pageplusone - 1; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 37ff26b0b4b..618cc6006a5 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -45,7 +45,7 @@ $result = restrictedArea($user, 'banque', '', '', ''); // Get parameters $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index b6cee9a29d0..e2aa6517417 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -56,7 +56,7 @@ if ($search_accountancy_subledger == - 1) $search_accountancy_subledger = ''; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 8e83e6a33a4..8dd3eca5e33 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -47,7 +47,7 @@ $sday = (GETPOSTISSET('closeday') ?GETPOST('closeday', 'int') : dol_print_date($ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -77,6 +77,9 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('cashcontrolcard', 'globalcard')); +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + /* * Actions @@ -96,7 +99,22 @@ if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && empty($conf->global->C if (GETPOST('cancel', 'alpha')) { - $action = 'create'; + if ($action == 'valid') { + $action = 'view'; + } + else { + $action = 'create'; + } +} + +if ($action == "reopen") +{ + $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'CASHFENCE_REOPEN'); + if ($result < 0) { + dol_print_error($db, $object->error, $object->error); + } + + $action = 'view'; } if ($action == "start") @@ -162,18 +180,35 @@ elseif ($action == "add") } } -if ($action == "close") +if ($action == "valid") // validate = close { $object->fetch($id); - $result = $object->valid($user); + $db->begin(); + + /* + $object->day_close = GETPOST('closeday', 'int'); + $object->month_close = GETPOST('closemonth', 'int'); + $object->year_close = GETPOST('closeyear', 'int'); + */ + + $object->cash = price2num(GETPOST('cash_amount', 'alpha')); + $object->card = price2num(GETPOST('card_amount', 'alpha')); + $object->cheque = price2num(GETPOST('cheque_amount', 'alpha')); + + $result = $object->update($user); + + $result = $object->valid($user); + if ($result <= 0) { setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); } else { setEventMessages($langs->trans("CashFenceDone"), null); + $db->commit(); } $action = "view"; @@ -213,15 +248,22 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete)) $form = new Form($db); -if ($action == "create" || $action == "start") +$initialbalanceforterminal = array(); +$theoricalamountforterminal = array(); +$theoricalnbofinvoiceforterminal = array(); + +if ($action == "create" || $action == "start" || $action == 'close') { - llxHeader(); + if ($action == 'close') { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; + $terminaltouse = $terminalid; - $initialbalanceforterminal = array(); - $theoricalamountforterminal = array(); - $theoricalnbofinvoiceforterminal = array(); - - if (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') + $syear = $object->year_close; + $smonth = $object->month_close; + $sday = $object->day_close; + } + elseif (GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '' && GETPOST('posnumber', 'alpha') != '-1') { $posmodule = GETPOST('posmodule', 'alpha'); $terminalid = GETPOST('posnumber', 'alpha'); @@ -234,7 +276,10 @@ if ($action == "create" || $action == "start") setEventMessages($langs->trans("OnlyTerminal1IsAvailableForCashDeskModule"), null, 'errors'); $error++; } + } + if ($terminalid != '') + { // Calculate $initialbalanceforterminal for terminal 0 foreach ($arrayofpaymentmode as $key => $val) { @@ -246,9 +291,7 @@ if ($action == "create" || $action == "start") // Get the bank account dedicated to this point of sale module/terminal $vartouse = 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse; - $bankid = $conf->global->$vartouse; // This value is ok for 'Terminal 0' for module 'CashDesk' and 'TakePos' (they manage only 1 terminal) - // Hook to get the good bank id according to posmodule and posnumber. - // @todo add hook here + $bankid = $conf->global->$vartouse; if ($bankid > 0) { @@ -274,11 +317,9 @@ if ($action == "create" || $action == "start") } } - // Calculate $theoricalamountforterminal for terminal 0 + // Calculate $theoricalamountforterminal foreach ($arrayofpaymentmode as $key => $val) { - /*$sql = "SELECT SUM(amount) as total FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account = ".$bankid;*/ $sql = "SELECT SUM(pf.amount) as total, COUNT(*) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as cp"; $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = p.fk_paiement"; @@ -315,197 +356,230 @@ if ($action == "create" || $action == "start") } } - print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); + //var_dump($theoricalamountforterminal); var_dump($theoricalnbofinvoiceforterminal); + if ($action != 'close') { + llxHeader(); - print ''; - print ''; - if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') - { - print ''; - } - else - { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print load_fiche_titre($langs->trans("CashControl")." - ".$langs->trans("New"), '', 'cash-register'); - $disabled = 0; - $prefix = 'close'; + print ''; + print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } + elseif ($action == 'close') + { + print ''; + print ''; + } + else + { + print ''; + } - print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index e8e806bbbcd..ea2d68cc126 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -45,7 +45,7 @@ $search_company=GETPOST('search_company', 'alpha'); // $search_amount=GETPOST('search_amount','alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index c9c48fd9b93..cf745b784fc 100644 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -227,7 +227,9 @@ print '
    '; // Show filter box print '
    '; +print ''; print ''; + print '
    '.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - $array = array(); - $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); - for($i = 1; $i <= $numterminals; $i++) { - $array[$i] = $i; - } - $selectedposnumber = 0; $showempty = 1; - if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') - { - $selectedposnumber = 1; $showempty = 0; - } - print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); - //print ''; - print ''; - // Year - print ''; - // Month - print ''; - // Day - print ''; - // Button Start - print ''; - print '
    '.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
    '; - $retstring = ''; - for ($year = $syear - 10; $year < $syear + 10; $year++) - { - $retstring .= ''; - } - $retstring .= "\n"; - print $retstring; - print ''; - $retstring = ''; - $retstring .= ''; - for ($month = 1; $month <= 12; $month++) - { - $retstring .= '"; - } - $retstring .= ""; - print $retstring; - print ''; - $retstring = ''; - $retstring .= ''; - for ($day = 1; $day <= 31; $day++) - { - $retstring .= ''; - } - $retstring .= ""; - print $retstring; - print ''; - if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') - { - print ''; - } - else - { - print ''; - } - print '
    '; + $disabled = 0; + $prefix = 'close'; - // Table to see/enter balance - if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') - { - $posmodule = GETPOST('posmodule', 'alpha'); - $terminalid = GETPOST('posnumber', 'alpha'); + print '
    '.$form->selectarray('posmodule', $arrayofposavailable, GETPOST('posmodule', 'alpha'), (count($arrayofposavailable) > 1 ? 1 : 0)).''; - print '
    '; - - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = 0; $showempty = 1; + if ($conf->global->TAKEPOS_NUM_TERMINALS == '1') + { + $selectedposnumber = 1; $showempty = 0; + } + print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty); + //print ''; + print ''; + // Year + print ''; + // Month + print ''; + // Day + print ''; + // Button Start + print ''; + print '
    '.$langs->trans("InitialBankBalance"); - //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); - print '
    '; - print $langs->trans("AmountAtEndOfPeriod"); - print '
    '.$langs->trans("Cash"); - //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); - print '
    '; + $retstring = ''; + for ($year = $syear - 10; $year < $syear + 10; $year++) { - print ''.$langs->trans($val); + $retstring .= ''; + } + $retstring .= "\n"; + print $retstring; + print ''; + $retstring = ''; + $retstring .= ''; + for ($month = 1; $month <= 12; $month++) + { + $retstring .= '"; + } + $retstring .= ""; + print $retstring; + print ''; + $retstring = ''; + $retstring .= ''; + for ($day = 1; $day <= 31; $day++) + { + $retstring .= ''; + } + $retstring .= ""; + print $retstring; + print ''; + if ($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') + { + print ''; + } + else + { + print ''; + } + print '
    '; + print ''; + + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = GETPOST('posmodule', 'alpha'); + $terminalid = GETPOST('posnumber', 'alpha'); + + print '
    '; + + print '
    '; + print ''; + + print ''; + print ''; + print ''; - $i++; - } - print ''; - print ''; - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; - - print ''; - // Initial amount - print ''; - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; - $i++; - } - // Save - print ''; - print ''; + */ + print ''; + print ''; - print ''; - print ''; - // Initial amount - print ''; - // Amount per payment type - $i = 0; - foreach ($arrayofpaymentmode as $key => $val) - { - print ''; + print ''; + print ''; - $i++; - } - // Save - print ''; - print ''; + /* + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + }*/ + print ''; + print ''; - print ''; + /*print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + */ + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + /*$i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + }*/ + // Save + print ''; + print ''; + + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + /*$i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + }*/ + // Save + print ''; + print ''; + + print '
    '.$langs->trans("InitialBankBalance"); //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '.$langs->trans("NbOfInvoices").''; - print ''; - print $theoricalnbofinvoiceforterminal[$terminalid][$key]; - print '
    '.$langs->trans("TheoricalAmount").''; - print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; - print '
    '; - print price($theoricalamountforterminal[$terminalid][$key]).'
    '; + /* + print '
    '; + print $langs->trans("AmountAtEndOfPeriod"); print '
    '.$langs->trans("RealAmount").''; - print ''; - print ''; - print ''; + print '
    '.$langs->trans("Cash"); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); print '
    '; - print ''; - print ''; - print '
    '.$langs->trans($val); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
    '.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; + print '
    '; + print price($theoricalamountforterminal[$terminalid][$key]).'
    '; + print '
    '.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
    '; + print '
    '; + } + + print ''; } - print ''; } -if (empty($action) || $action == "view") +if (empty($action) || $action == "view" || $action == "close") { $result = $object->fetch($id); @@ -520,7 +594,7 @@ if (empty($action) || $action == "view") $head[0][1] = $langs->trans("Card"); $head[0][2] = 'cashcontrol'; - dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'cashcontrol'); + dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'account'); $linkback = ''.$langs->trans("BackToList").''; @@ -533,7 +607,7 @@ if (empty($action) || $action == "view") print '
    '; print '
    '; print '
    '; - print ''; + print '
    '; print ''; print ''; @@ -293,7 +293,7 @@ if ($action == 'create') print ''; print ''; diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 2829e257b3b..d85f4239d02 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -50,7 +50,7 @@ $result = restrictedArea($user, 'deplacement', $id, ''); // Get parameters $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index fde600aff8f..e95d7f95732 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -32,43 +32,43 @@ $langs->loadLangs(array('companies', 'users', 'trips')); // Security check $socid = GETPOST('socid', 'int'); -if ($user->socid) $socid=$user->socid; +if ($user->socid) $socid = $user->socid; $result = restrictedArea($user, 'deplacement', '', ''); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="d.dated"; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "d.dated"; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; /* * View */ -$tripandexpense_static=new Deplacement($db); +$tripandexpense_static = new Deplacement($db); $childids = $user->getAllChildIds(); -$childids[]=$user->id; +$childids[] = $user->id; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; -$help_url=''; +$help_url = ''; llxHeader('', $langs->trans("ListOfFees"), $help_url); -$totalnb=0; +$totalnb = 0; $sql = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d"; -$sql.= " WHERE d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -$sql.= " GROUP BY d.type"; -$sql.= " ORDER BY d.type"; +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d"; +$sql .= " WHERE d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +$sql .= " GROUP BY d.type"; +$sql .= " ORDER BY d.type"; $result = $db->query($sql); if ($result) @@ -102,10 +102,10 @@ print ''; print ''; print "\n"; -$listoftype=$tripandexpense_static->listOfTypes(); +$listoftype = $tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[]=array($label, (isset($nb[$code])?(int) $nb[$code]:0)); + $dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0)); } if ($conf->use_javascript_ajax) @@ -115,12 +115,12 @@ if ($conf->use_javascript_ajax) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); - print $dolgraph->show($totalnb?0:1); + print $dolgraph->show($totalnb ? 0 : 1); print ''; } @@ -137,25 +137,25 @@ print '
    '; print $langs->trans("Ref"); @@ -587,17 +661,212 @@ if (empty($action) || $action == "view") dol_fiche_end(); - print '
    '; - print ''; - if ($object->status == CashControl::STATUS_DRAFT) - { - print ''; + if ($action != 'close') { + print '
    '; - print ''; - } - print '
    '; + print ''; - print '
    '; + if ($object->status == CashControl::STATUS_DRAFT) + { + print ''; + + print ''; + } else { + print ''; + } + + print '
    '; + + print '
    '; + } else { + print '
    '; + print ''; + if ($action == 'start' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '' && GETPOST('posnumber', 'int') != '-1') + { + print ''; + } + elseif ($action == 'close') + { + print ''; + print ''; + } + else + { + print ''; + } + + /* + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $disabled = 1; + $prefix = 'close'; + + print ''; + print ''; + print ''; + print ''; + // Year + print ''; + // Month + print ''; + // Day + print ''; + + print ''; + print '
    '.$langs->trans("Module").''.$langs->trans("Terminal").''.$langs->trans("Year").''.$langs->trans("Month").''.$langs->trans("Day").'
    '.$form->selectarray('posmodulebis', $arrayofposavailable, $object->posmodule, (count($arrayofposavailable) > 1 ? 1 : 0), 0, 0, '', 0, 0, $disabled).''; + + $array = array(); + $numterminals = max(1, $conf->global->TAKEPOS_NUM_TERMINALS); + for($i = 1; $i <= $numterminals; $i++) { + $array[$i] = $i; + } + $selectedposnumber = $object->posnumber; $showempty = 1; + //print $form->selectarray('posnumber', $array, GETPOSTISSET('posnumber') ?GETPOST('posnumber', 'int') : $selectedposnumber, $showempty, 0, 0, '', 0, 0, $disabled); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
    '; + print '
    '; + */ + + // Table to see/enter balance + if (($action == 'start' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '' && GETPOST('posnumber') != '-1') || $action == 'close') + { + $posmodule = $object->posmodule; + $terminalid = $object->posnumber; + + print '
    '; + + print '
    '; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + // Initial amount + print ''; + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print ''; + print ''; + // Initial amount + print ''; + // Amount per payment type + $i = 0; + foreach ($arrayofpaymentmode as $key => $val) + { + print ''; + $i++; + } + // Save + print ''; + print ''; + + print '
    '.$langs->trans("InitialBankBalance"); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '; + print $langs->trans("AmountAtEndOfPeriod"); + print '
    '.$langs->trans("Cash"); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '.$langs->trans($val); + //print '
    '.$langs->trans("TheoricalAmount").'
    '.$langs->trans("RealAmount"); + print '
    '.$langs->trans("NbOfInvoices").''; + print ''; + print $theoricalnbofinvoiceforterminal[$terminalid][$key]; + print '
    '.$langs->trans("TheoricalAmount").''; + print price($initialbalanceforterminal[$terminalid]['cash']).'
    '; + print '
    '; + if ($key == 'cash') { + $deltaforcash = ($object->opening - $initialbalanceforterminal[$terminalid]['cash']); + print price($theoricalamountforterminal[$terminalid][$key] + $deltaforcash).'
    '; + } else { + print price($theoricalamountforterminal[$terminalid][$key]).'
    '; + } + print '
    '.$langs->trans("RealAmount").''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($action == 'start') print ''; + elseif ($action == 'close') print ''; + print '
    '; + print '
    '; + } + + print '
    '; + } } } diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 6c59276d600..d559fad2b30 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -65,7 +65,7 @@ $id = GETPOST('id', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 32f7533b6c3..f30410d187f 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -104,6 +104,7 @@ class CashControl extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; + const STATUS_CLOSED = 1; // For the moment CLOSED = VALIDATED /** @@ -288,6 +289,18 @@ class CashControl extends CommonObject return $result; } + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + /** * Delete object in database * diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index 8cd74f1cccf..1ea06eba9e9 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -40,6 +40,7 @@ $langs->load("bills"); $id = GETPOST('id', 'int'); $_GET['optioncss'] = "print"; + $cashcontrol = new CashControl($db); $cashcontrol->fetch($id); @@ -69,6 +70,8 @@ $terminalid = $cashcontrol->posnumber; * View */ +$param = ''; + llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $param); /*$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,"; @@ -268,21 +271,21 @@ if ($resql) print "

    "; print $langs->trans("Cash").": ".price($cash); - if ($cash != $cashcontrol->cash) { + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cash != $cashcontrol->cash) { print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cash).''; } print "

    "; //print '
    '; print $langs->trans("PaymentTypeCHQ").": ".price($cheque); - if ($cheque != $cashcontrol->cheque) { + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $cheque != $cashcontrol->cheque) { print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->cheque).''; } print "

    "; //print '
    '; print $langs->trans("PaymentTypeCB").": ".price($bank); - if ($bank != $cashcontrol->card) { + if ($cashcontrol->status == $cashcontrol::STATUS_VALIDATED && $bank != $cashcontrol->card) { print ' <> '.$langs->trans("Declared").': '.price($cashcontrol->card).''; } print "

    "; diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 653a13f01a1..e9aa35d80b3 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -58,7 +58,7 @@ $search_account = GETPOST('search_account', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index 8cfeeda613e..b9db96a78bc 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -46,7 +46,7 @@ $mode=GETPOST("mode"); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index cabc3510ea4..c08be32242b 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -281,7 +281,7 @@ if ($action == 'create') print '

    '.$langs->trans('NotePublic').''; - $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); print $doleditor->Create(1); print '
    '.$langs->trans('NotePrivate').''; - $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); + $doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, true, ROWS_8, '90%'); print $doleditor->Create(1); print '
    '.$langs->trans("Statistics").'
    '; print '
    '; -$max=10; +$max = 10; $langs->load("boxes"); $sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut"; -$sql.= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE u.rowid = d.fk_user"; -$sql.= " AND d.entity = ".$conf->entity; -if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql.=' AND d.fk_user IN ('.join(',', $childids).')'; -if (!$user->rights->societe->client->voir && !$user->socid) $sql.= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -if ($socid) $sql.= " AND d.fk_soc = ".$socid; -$sql.= $db->order("d.tms", "DESC"); -$sql.= $db->plimit($max, 0); +$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u"; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql .= " WHERE u.rowid = d.fk_user"; +$sql .= " AND d.entity = ".$conf->entity; +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $sql .= ' AND d.fk_user IN ('.join(',', $childids).')'; +if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND d.fk_soc = s. rowid AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; +if ($socid) $sql .= " AND d.fk_soc = ".$socid; +$sql .= $db->order("d.tms", "DESC"); +$sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { - $var=false; + $var = false; $num = $db->num_rows($result); $i = 0; @@ -171,16 +171,16 @@ if ($result) { $total_ttc = $totalam = $total = 0; - $deplacementstatic=new Deplacement($db); - $userstatic=new User($db); + $deplacementstatic = new Deplacement($db); + $userstatic = new User($db); while ($i < $num && $i < $max) { $obj = $db->fetch_object($result); - $deplacementstatic->ref=$obj->rowid; - $deplacementstatic->id=$obj->rowid; - $userstatic->id=$obj->uid; - $userstatic->lastname=$obj->lastname; - $userstatic->firstname=$obj->firstname; + $deplacementstatic->ref = $obj->rowid; + $deplacementstatic->id = $obj->rowid; + $userstatic->id = $obj->uid; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; print '
    '.$deplacementstatic->getNomUrl(1).''.$userstatic->getNomUrl(1).'
    '; print ''; // Company diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 7d1f529bf82..26eee81375f 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -70,7 +70,7 @@ $month_date_when = GETPOST('month_date_when'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (!$sortorder) $sortorder = 'DESC'; @@ -1680,7 +1680,7 @@ else // Lines print ' - + diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3a36a4b5d70..8495bc8be70 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2006 Andre Cianfarani @@ -302,31 +302,34 @@ if (empty($reshook)) // Also negative lines should not be allowed on 'non Credit notes' invoices. A test is done when adding or updating lines but we must // do it again in validation to avoid cases where invoice is created from another object that allow negative lines. - // Note that we can accept the negative line if sum with other lines with same vat is positivie: Because all the lines will be merged together + // Note that we can accept the negative line if sum with other lines with same vat makes total positive: Because all the lines will be merged together // when converted into 'available credit' and we will get a positive available credit line. // Note: Other solution if you want to add a negative line on invoice, is to create a discount for customer and consumme it (but this is possible on standard invoice only). - $array_of_pu_ht_per_vat_rate = array(); - $array_of_pu_ht_devise_per_vat_rate = array(); + $array_of_total_ht_per_vat_rate = array(); + $array_of_total_ht_devise_per_vat_rate = array(); foreach ($object->lines as $line) { - if (empty($array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; - if (empty($array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code])) $array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] = 0; - $array_of_pu_ht_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->subprice; - $array_of_pu_ht_devise_per_vat_rate[$line->tva_tx.'_'.$line->vat_src_code] += $line->multicurrency_subprice; + //$vat_src_code_for_line = $line->vat_src_code; // TODO We chek sign of total per vat without taking into account the vat code because for the moment the vat code is lost/unknown when we add a down payment. + $vat_src_code_for_line = ''; + if (empty($array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line])) $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] = 0; + if (empty($array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line])) $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] = 0; + $array_of_total_ht_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] += $line->total_ht; + $array_of_total_ht_devise_per_vat_rate[$line->tva_tx.'_'.$vat_src_code_for_line] += $line->multicurrency_total_ht; } - //var_dump($array_of_pu_ht_per_vat_rate);exit; - foreach ($array_of_pu_ht_per_vat_rate as $vatrate => $tmpvalue) - { - $pu_ht = $array_of_pu_ht_per_vat_rate[$vatrate]; - $pu_ht_devise = $array_of_pu_ht_devise_per_vat_rate[$vatrate]; - if (($pu_ht < 0 || $pu_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) + //var_dump($array_of_total_ht_per_vat_rate);exit; + foreach ($array_of_total_ht_per_vat_rate as $vatrate => $tmpvalue) + { + $tmp_total_ht = $array_of_total_ht_per_vat_rate[$vatrate]; + $tmp_total_ht_devise = $array_of_total_ht_devise_per_vat_rate[$vatrate]; + + if (($tmp_total_ht < 0 || $tmp_total_ht_devise < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { $langs->load("errors"); if ($object->type == $object::TYPE_DEPOSIT) { // Using negative lines on deposit lead to headach and blocking problems when you want to consume them. setEventMessages($langs->trans("ErrorLinesCantBeNegativeOnDeposits"), null, 'errors'); } else { - setEventMessages($langs->trans("ErrorFieldCantBeNegativeOnInvoice", $langs->transnoentitiesnoconv("UnitPriceHT"), $langs->transnoentitiesnoconv("CustomerAbsoluteDiscountShort")), null, 'errors'); + setEventMessages($langs->trans("ErrorLinesCantBeNegativeForOneVATRate"), null, 'errors'); } $error++; $action = ''; @@ -490,10 +493,10 @@ if (empty($reshook)) // POST[remise_id] or POST[remise_id_for_payment] // We use the credit to reduce amount of invoice - if (!empty($_POST["remise_id"])) { + if (GETPOST("remise_id", 'int') > 0) { $ret = $object->fetch($id); if ($ret > 0) { - $result = $object->insert_discount($_POST["remise_id"]); + $result = $object->insert_discount(GETPOST("remise_id", 'int')); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } @@ -502,11 +505,11 @@ if (empty($reshook)) } } // We use the credit to reduce remain to pay - if (!empty($_POST["remise_id_for_payment"])) + if (GETPOST("remise_id_for_payment", 'int') > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; $discount = new DiscountAbsolute($db); - $discount->fetch($_POST["remise_id_for_payment"]); + $discount->fetch(GETPOST("remise_id_for_payment", 'int')); //var_dump($object->getRemainToPay(0)); //var_dump($discount->amount_ttc);exit; @@ -814,14 +817,16 @@ if (empty($reshook)) $i = 0; foreach ($object->lines as $line) { - if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 - { // no need to create discount if amount is null - $amount_ht[$line->tva_tx] += $line->total_ht; - $amount_tva[$line->tva_tx] += $line->total_tva; - $amount_ttc[$line->tva_tx] += $line->total_ttc; - $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; - $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; - $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; + if ($line->product_type < 9 && $line->total_ht != 0) // Remove lines with product_type greater than or equal to 9 and no need to create discount if amount is null + { + $keyforvatrate = $line->tva_tx.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''); + + $amount_ht[$keyforvatrate] += $line->total_ht; + $amount_tva[$keyforvatrate] += $line->total_tva; + $amount_ttc[$keyforvatrate] += $line->total_ttc; + $multicurrency_amount_ht[$keyforvatrate] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$keyforvatrate] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$keyforvatrate] += $line->multicurrency_total_ttc; $i++; } } @@ -835,9 +840,9 @@ if (empty($reshook)) $amount_ht[$vatrate] = price2num($amount_ht[$vatrate] * $ratio, 'MU'); $amount_tva[$vatrate] = price2num($amount_tva[$vatrate] * $ratio, 'MU'); $amount_ttc[$vatrate] = price2num($amount_ttc[$vatrate] * $ratio, 'MU'); - $multicurrency_amount_ht[$line->tva_tx] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); - $multicurrency_amount_tva[$line->tva_tx] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); - $multicurrency_amount_ttc[$line->tva_tx] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ht[$vatrate] = price2num($multicurrency_amount_ht[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_tva[$vatrate] = price2num($multicurrency_amount_tva[$vatrate] * $ratio, 'MU'); + $multicurrency_amount_ttc[$vatrate] = price2num($multicurrency_amount_ttc[$vatrate] * $ratio, 'MU'); } } } @@ -892,6 +897,7 @@ if (empty($reshook)) $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; + $discount->vat_src_code = ''; $result = $discount->create($user); if ($result < 0) @@ -909,7 +915,18 @@ if (empty($reshook)) $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); + + // Clean vat code + $reg = array(); + $vat_src_code = ''; + if (preg_match('/\((.*)\)/', $tva_tx, $reg)) + { + $vat_src_code = $reg[1]; + $tva_tx = preg_replace('/\s*\(.*\)/', '', $tva_tx); // Remove code into vatrate. + } + $discount->tva_tx = abs($tva_tx); + $discount->vat_src_code =$vat_src_code; $result = $discount->create($user); if ($result < 0) @@ -1319,14 +1336,14 @@ if (empty($reshook)) $object->situation_cycle_ref = $object->newCycle(); } - $object->retained_warranty = GETPOST('retained_warranty', 'int'); - $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $object->retained_warranty = GETPOST('retained_warranty', 'int'); + $object->retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); - if(!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)){ - $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); - } - $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); + $retained_warranty_date_limit = GETPOST('retained_warranty_date_limit'); + if (!empty($retained_warranty_date_limit) && $db->jdate($retained_warranty_date_limit)) { + $object->retained_warranty_date_limit = $db->jdate($retained_warranty_date_limit); + } + $object->retained_warranty_date_limit = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : $object->calculate_date_lim_reglement($object->retained_warranty_fk_cond_reglement); $object->fetch_thirdparty(); @@ -1596,7 +1613,7 @@ if (empty($reshook)) // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -1744,7 +1761,7 @@ if (empty($reshook)) $line->origin = $object->origin; $line->origin_id = $line->id; $line->fk_prev_id = $line->id; - $line->fetch_optionals($line->id); + $line->fetch_optionals(); $line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note // Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée @@ -2550,7 +2567,7 @@ if (empty($reshook)) $originLine = new $lineClassName($db); if (intval($fromElementid) > 0 && $originLine->fetch($lineId) > 0) { - $originLine->fetch_optionals($lineId); + $originLine->fetch_optionals(); $desc = $originLine->desc; $pu_ht = $originLine->subprice; $qty = $originLine->qty; @@ -2576,7 +2593,12 @@ if (empty($reshook)) $pa_ht = $originLine->pa_ht; $label = $originLine->label; $array_options = $originLine->array_options; - $situation_percent = 100; + if($object->type == Facture::TYPE_SITUATION){ + $situation_percent = 0; + } + else{ + $situation_percent = 100; + } $fk_prev_id = ''; $fk_unit = $originLine->fk_unit; $pu_ht_devise = $originLine->multicurrency_subprice; @@ -2800,7 +2822,7 @@ if ($action == 'create') $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); //Replicate extrafields - $expesrc->fetch_optionals($expeoriginid); + $expesrc->fetch_optionals(); $object->array_options = $expesrc->array_options; } else @@ -2818,7 +2840,7 @@ if ($action == 'create') } // Replicate extrafields - $objectsrc->fetch_optionals($originid); + $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; } } @@ -2860,7 +2882,7 @@ if ($action == 'create') } print ''; - print ''; + print ''; print ''; if ($soc->id > 0) print ''."\n"; print ''; @@ -3056,7 +3078,7 @@ if ($action == 'create') // First situation invoice print '
    '; $tmp = ' '; - $tmp = $tmp.''; + $tmp = $tmp.''; $desc = $form->textwithpicto($tmp, $langs->transnoentities("InvoiceFirstSituationDesc"), 1, 'help', '', 0, 3); print $desc; print '
    '; @@ -3336,38 +3358,51 @@ if ($action == 'create') if($conf->global->INVOICE_USE_RETAINED_WARRANTY){ - $rwStyle = 'display:none;'; - if(in_array(GETPOST('type', 'int'), $RetainedWarrantyInvoiceAvailableType)){ - $rwStyle = ''; - } + $rwStyle = 'display:none;'; + if(in_array(GETPOST('type', 'int'), $RetainedWarrantyInvoiceAvailableType)){ + $rwStyle = ''; + } + $retained_warranty = GETPOST('retained_warranty', 'int'); + if(empty($retained_warranty)){ + if(!empty($objectsrc->retained_warranty)){ // use previous situation value + $retained_warranty = $objectsrc->retained_warranty; + }else{ + $retained_warranty = $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; + } + } - $retained_warranty = GETPOST('retained_warranty', 'int'); - $retained_warranty = !empty($retained_warranty)?$retained_warranty:$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT; - print '
    '; + // Retained warranty payment term + print ''; - print ''; + { + $(".retained-warranty-line").show(); + } + else{ + $(".retained-warranty-line").hide(); + } + }); + }); + '; } // Payment mode @@ -3389,7 +3424,7 @@ if ($action == 'create') { $langs->load('projects'); print ''; } @@ -4272,10 +4307,10 @@ elseif ($id > 0 || !empty($ref)) if(!empty($object->retained_warranty) || !empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { - $displayWarranty = true; + $displayWarranty = true; if(!in_array($object->type, $RetainedWarrantyInvoiceAvailableType) && empty($object->retained_warranty)){ - $displayWarranty = false; - } + $displayWarranty = false; + } if($displayWarranty) { @@ -4286,63 +4321,63 @@ elseif ($id > 0 || !empty($ref)) print $langs->trans('RetainedWarranty'); print ''; if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { - print ''; + print ''; } - print '
    '.$langs->trans("Filter").'
    ' . $langs->trans('RetainedWarranty') . ''; - print '%'; + print '
    '.$langs->trans('RetainedWarranty').''; + print '%'; - // Retained warranty payment term - print '
    ' . $langs->trans('PaymentConditionsShortRetainedWarranty') . ''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement)? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print '
    '.$langs->trans('PaymentConditionsShortRetainedWarranty').''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + if(empty($retained_warranty_fk_cond_reglement)){ + $retained_warranty_fk_cond_reglement = $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + if(!empty($objectsrc->retained_warranty_fk_cond_reglement)){ // use previous situation value + $retained_warranty_fk_cond_reglement = $objectsrc->retained_warranty_fk_cond_reglement; + }else{ + $retained_warranty_fk_cond_reglement = $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + } + } + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print '
    '.$langs->trans('Project').''; - $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1); + $numprojet = $formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500'); print ' id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'">'; print '
    id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
    '; - print ''; - if ($action == 'editretainedwarranty') - { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - else - { - print price($object->retained_warranty).'%'; - } - print ''; + print ''; + print ''; + if ($action == 'editretainedwarranty') + { + print '
    '; + print ''; + print ''; + print ''; + print ''; + print '
    '; + } + else + { + print price($object->retained_warranty).'%'; + } + print ''; - // Retained warranty payment term - print ''; - print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { - print ''; - } + // Retained warranty payment term + print '
    '; - print $langs->trans('PaymentConditionsShortRetainedWarranty'); - print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
    '; + print ''; + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + print ''; + } - print '
    '; + print $langs->trans('PaymentConditionsShortRetainedWarranty'); + print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
    '; - print '
    '; - $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); - if ($object->date > $defaultDate) { - $defaultDate = $object->date; - } + print '
    '; + print ''; + $defaultDate = !empty($object->retained_warranty_date_limit) ? $object->retained_warranty_date_limit : strtotime('-1 years', $object->date_lim_reglement); + if ($object->date > $defaultDate) { + $defaultDate = $object->date; + } - if ($action == 'editretainedwarrantypaymentterms') - { - //date('Y-m-d',$object->date_lim_reglement) - print '
    '; - print ''; - print ''; - $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; - $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; - $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); - print ''; - print '
    '; - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); - if (!$displayWarranty) { - print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); - } - } - print ''; + if ($action == 'editretainedwarrantypaymentterms') + { + //date('Y-m-d',$object->date_lim_reglement) + print '
    '; + print ''; + print ''; + $retained_warranty_fk_cond_reglement = GETPOST('retained_warranty_fk_cond_reglement', 'int'); + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $object->retained_warranty_fk_cond_reglement; + $retained_warranty_fk_cond_reglement = !empty($retained_warranty_fk_cond_reglement) ? $retained_warranty_fk_cond_reglement : $conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID; + $form->select_conditions_paiements($retained_warranty_fk_cond_reglement, 'retained_warranty_fk_cond_reglement', -1, 1); + print ''; + print '
    '; + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?facid='.$object->id, $object->retained_warranty_fk_cond_reglement, 'none'); + if (!$displayWarranty) { + print img_picto($langs->trans('RetainedWarrantyNeed100Percent'), 'warning.png', 'class="pictowarning valignmiddle" '); + } + } + print ''; // Retained Warranty payment date limit print ''; @@ -4444,7 +4479,7 @@ elseif ($id > 0 || !empty($ref)) print ''; if ($action == 'editrevenuestamp') { print '
    '; - print ''; + print ''; print ''; print ''; print $formother->select_revenue_stamp('', 'revenuestamp_type', $mysoc->country_code); @@ -5113,7 +5148,7 @@ elseif ($id > 0 || !empty($ref)) // Reverse back money or convert to reduction if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) { // For credit note only - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercanissuepayment) + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercanissuepayment) { if ($resteapayer == 0) { @@ -5126,12 +5161,12 @@ elseif ($id > 0 || !empty($ref)) } // For standard invoice with excess received - if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && empty($object->paye) && $resteapayer < 0 && $usercancreate && empty($discount->id)) + if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) && $object->statut == Facture::STATUS_VALIDATED && empty($object->paye) && $resteapayer < 0 && $usercancreate && empty($discount->id)) { print ''.$langs->trans('ConvertExcessReceivedToReduc').''; } // For credit note - if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == 1 && $object->paye == 0 && $usercancreate + if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $usercancreate && (!empty($conf->global->INVOICE_ALLOW_REUSE_OF_CREDIT_WHEN_PARTIALLY_REFUNDED) || $object->getSommePaiement() == 0) ) { print ''.$langs->trans('ConvertToReduc').''; @@ -5153,7 +5188,7 @@ elseif ($id > 0 || !empty($ref)) // Classify 'closed not completely paid' (possible si validee et pas encore classee payee) - if ($object->statut == 1 && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment) + if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && $usercanissuepayment) { if ($totalpaye > 0 || $totalcreditnotes > 0) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index e68966f4663..961d07eda2e 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2020 Thibault FOUCART * * 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 @@ -63,11 +64,65 @@ class Invoices extends DolibarrApi */ public function get($id, $contact_list = 1) { + return $this->_fetch($id, '', '', $contact_list); + } + + /** + * Get properties of an invoice object by ref + * + * Return an array with invoice informations + * + * @param string $ref Ref of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref/{ref} + * + * @throws RestException + */ + public function getByRef($ref, $contact_list = 1) + { + return $this->_fetch('', $ref, '', $contact_list); + } + + /** + * Get properties of an invoice object by ref_ext + * + * Return an array with invoice informations + * + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @url GET ref_ext/{ref_ext} + * + * @throws RestException + */ + public function getByRefExt($ref_ext, $contact_list = 1) + { + return $this->_fetch('', '', $ref_ext, $contact_list); + } + + /** + * Get properties of an invoice object + * + * Return an array with invoice informations + * + * @param int $id ID of order + * @param string $ref Ref of object + * @param string $ref_ext External reference of object + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return array|mixed data without useless information + * + * @throws RestException + */ + private function _fetch($id, $ref = '', $ref_ext = '', $contact_list = 1) + { if (!DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); } - $result = $this->invoice->fetch($id); + $result = $this->invoice->fetch($id, $ref, $ref_ext); if (!$result) { throw new RestException(404, 'Invoice not found'); } @@ -87,7 +142,7 @@ class Invoices extends DolibarrApi $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); - } + } /** * List invoices @@ -103,7 +158,8 @@ class Invoices extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of invoice objects * - * @throws RestException + * @throws RestException 404 Not found + * @throws RestException 503 Error */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { @@ -424,7 +480,7 @@ class Invoices extends DolibarrApi * @url DELETE {id}/contact/{rowid} * * @return array - * + * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 @@ -592,6 +648,7 @@ class Invoices extends DolibarrApi * * @return int * + * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 * @throws RestException 400 @@ -1098,6 +1155,7 @@ class Invoices extends DolibarrApi * @url POST {id}/usediscount/{discountid} * * @return int + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1144,6 +1202,7 @@ class Invoices extends DolibarrApi * @url POST {id}/usecreditnote/{discountid} * * @return int + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1189,7 +1248,7 @@ class Invoices extends DolibarrApi * @url GET {id}/payments * * @return array - * + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1239,6 +1298,7 @@ class Invoices extends DolibarrApi * @url POST {id}/payments * * @return int Payment ID + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1358,6 +1418,7 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 403 diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index fdffc320880..524d553effd 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -677,7 +677,7 @@ class FactureRec extends CommonInvoice $line->price = $objp->price; $line->remise = $objp->remise; - $line->fetch_optionals($line->id); + $line->fetch_optionals(); // Multicurrency $line->fk_multicurrency = $objp->fk_multicurrency; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 30a607afc0a..7860ee93f0a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -112,7 +112,13 @@ class Facture extends CommonInvoice public $date; // Date invoice public $datem; public $ref_client; - public $ref_int; + + /** + * @var int Ref Int + * @deprecated + */ + public $ref_int; // deprecated + //Check constants for types public $type = self::TYPE_STANDARD; @@ -255,10 +261,10 @@ class Facture extends CommonInvoice 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>25), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), + 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>30), // deprecated 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'Ref client', 'enabled'=>1, 'visible'=>-1, 'position'=>40), - 'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), + //'increment' =>array('type'=>'varchar(10)', 'label'=>'Increment', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>50), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'datef' =>array('type'=>'date', 'label'=>'DateInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>60), @@ -267,18 +273,17 @@ class Facture extends CommonInvoice 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>75), 'paye' =>array('type'=>'smallint(6)', 'label'=>'InvoicePaidCompletely', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>80), //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>85), - 'remise_percent' =>array('type'=>'double', 'label'=>'Remise percent', 'enabled'=>1, 'visible'=>-1, 'position'=>90), - 'remise_absolue' =>array('type'=>'double', 'label'=>'Remise absolue', 'enabled'=>1, 'visible'=>-1, 'position'=>95), - 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100), + 'remise_percent' =>array('type'=>'double', 'label'=>'RelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'remise_absolue' =>array('type'=>'double', 'label'=>'CustomerRelativeDiscount', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + //'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>100), 'close_code' =>array('type'=>'varchar(16)', 'label'=>'EarlyClosingReason', 'enabled'=>1, 'visible'=>-1, 'position'=>105), 'close_note' =>array('type'=>'varchar(128)', 'label'=>'EarlyClosingComment', 'enabled'=>1, 'visible'=>-1, 'position'=>110), 'tva' =>array('type'=>'double(24,8)', 'label'=>'TotalVAT', 'enabled'=>1, 'visible'=>-1, 'position'=>115, 'isameasure'=>1), - 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'Localtax1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), - 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'Localtax2', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), + 'localtax1' =>array('type'=>'double(24,8)', 'label'=>'LT1', 'enabled'=>1, 'visible'=>-1, 'position'=>120, 'isameasure'=>1), + 'localtax2' =>array('type'=>'double(24,8)', 'label'=>'LT2', 'enabled'=>1, 'visible'=>-1, 'position'=>125, 'isameasure'=>1), 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>130, 'isameasure'=>1), 'total' =>array('type'=>'double(24,8)', 'label'=>'TotalHT', 'enabled'=>1, 'visible'=>-1, 'position'=>135, 'isameasure'=>1), 'total_ttc' =>array('type'=>'double(24,8)', 'label'=>'TotalTTC', 'enabled'=>1, 'visible'=>-1, 'position'=>140, 'isameasure'=>1), - 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Paid', 3=>'Abandonned')), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>155), 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>160), @@ -300,20 +305,21 @@ class Facture extends CommonInvoice 'retained_warranty' =>array('type'=>'double', 'label'=>'Retained warranty', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>245), 'retained_warranty_date_limit' =>array('type'=>'date', 'label'=>'Retained warranty date limit', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>250), 'retained_warranty_fk_cond_reglement' =>array('type'=>'integer', 'label'=>'Retained warranty fk cond reglement', 'enabled'=>'$conf->global->INVOICE_USE_RETAINED_WARRANTY', 'visible'=>-1, 'position'=>255), - 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermsCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260), - 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermsLocation', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265), + 'fk_incoterms' =>array('type'=>'integer', 'label'=>'IncotermCode', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>260), + 'location_incoterms' =>array('type'=>'varchar(255)', 'label'=>'IncotermLabel', 'enabled'=>'$conf->incoterm->enabled', 'visible'=>-1, 'position'=>265), 'date_pointoftax' =>array('type'=>'date', 'label'=>'DatePointOfTax', 'enabled'=>'$conf->global->INVOICE_POINTOFTAX_DATE', 'visible'=>-1, 'position'=>270), 'fk_multicurrency' =>array('type'=>'integer', 'label'=>'MulticurrencyID', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>275), - 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCode', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>280), - 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>285), - 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ht', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>290), - 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total tva', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>295), - 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'Multicurrency total ttc', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>300), + 'multicurrency_code' =>array('type'=>'varchar(255)', 'label'=>'MulticurrencyCurrency', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>280), + 'multicurrency_tx' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyRate', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>285, 'isameasure'=>1), + 'multicurrency_total_ht' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountHT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>290, 'isameasure'=>1), + 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>295, 'isameasure'=>1), + 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'$conf->multicurrency->enabled', 'visible'=>-1, 'position'=>300, 'isameasure'=>1), 'fk_fac_rec_source' =>array('type'=>'integer', 'label'=>'RecurringInvoiceSource', 'enabled'=>1, 'visible'=>-1, 'position'=>305), - 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>310), + 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>310), 'module_source' =>array('type'=>'varchar(32)', 'label'=>'POSModule', 'enabled'=>1, 'visible'=>-1, 'position'=>315), 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>320), - 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>220), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Paid', 3=>'Abandonned')), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), ); // END MODULEBUILDER PROPERTIES @@ -477,7 +483,7 @@ class Facture extends CommonInvoice $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'none') : $_facrec->note_public; $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'none') : $_facrec->note_private; - $this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'apha') : $_facrec->modelpdf; + $this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->modelpdf; $this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id; $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; @@ -807,6 +813,14 @@ class Facture extends CommonInvoice $vatrate = $line->tva_tx; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; + if(!empty($conf->global->MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION)) { + $originid=$line->origin_id; + $origintype=$line->origin; + } else { + $originid=$line->id; + $origintype=$this->element; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -826,8 +840,8 @@ class Facture extends CommonInvoice $line->product_type, $line->rang, $line->special_code, - $this->element, - $line->id, + $origintype, + $originid, $fk_parent_line, $line->fk_fournprice, $line->pa_ht, @@ -1053,6 +1067,11 @@ class Facture extends CommonInvoice $facture->situation_cycle_ref = $this->situation_cycle_ref; $facture->situation_final = $this->situation_final; + $facture->retained_warranty = $this->retained_warranty; + $facture->retained_warranty_fk_cond_reglement = $this->retained_warranty_fk_cond_reglement; + $facture->retained_warranty_date_limit = $this->retained_warranty_date_limit; + + // Loop on each line of new invoice foreach ($facture->lines as $i => $tmpline) { @@ -1298,7 +1317,7 @@ class Facture extends CommonInvoice $this->origin_id = $object->id; // get extrafields from original line - $object->fetch_optionals($object->id); + $object->fetch_optionals(); foreach ($object->array_options as $options_key => $value) $this->array_options[$options_key] = $value; @@ -1397,6 +1416,9 @@ class Facture extends CommonInvoice if (!empty($this->total_ttc)) $label .= '
    '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); if ($moretitle) $label .= ' - '.$moretitle; + if (isset($this->statut) && isset($this->alreadypaid)) { + $label .= '
    '.$langs->trans("Status").": ".$this->getLibStatut(5, $this->alreadypaid); + } } $linkclose = ($target ? ' target="'.$target.'"' : ''); @@ -1450,15 +1472,15 @@ class Facture extends CommonInvoice * @param int $rowid Id of object to load * @param string $ref Reference of invoice * @param string $ref_ext External reference of invoice - * @param int $ref_int Internal reference of other object + * @param int $notused Not used * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) + public function fetch($rowid, $ref = '', $ref_ext = '', $notused = '', $fetch_situation = false) { global $conf; - if (empty($rowid) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1; + if (empty($rowid) && empty($ref) && empty($ref_ext)) return -1; $sql = 'SELECT f.rowid,f.entity,f.ref,f.ref_client,f.ref_ext,f.ref_int,f.type,f.fk_soc'; $sql .= ', f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc, f.revenuestamp'; @@ -1490,7 +1512,7 @@ class Facture extends CommonInvoice $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Dont't use entity if you use rowid if ($ref) $sql .= " AND f.ref='".$this->db->escape($ref)."'"; if ($ref_ext) $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; - if ($ref_int) $sql .= " AND f.ref_int='".$this->db->escape($ref_int)."'"; + if ($notused) $sql .= " AND f.ref_int='".$this->db->escape($notused)."'"; // deprecated } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1630,8 +1652,8 @@ class Facture extends CommonInvoice $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql .= ' l.rang, l.special_code,'; $sql .= ' l.date_start as date_start, l.date_end as date_end,'; $sql .= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; @@ -2234,10 +2256,10 @@ class Facture extends CommonInvoice // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 - * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 + * Tag the invoice as paid completely (if close_code is filled) => this->fk_statut=2, this->paye=1 + * or partialy (if close_code filled) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 * - * @param User $user Objet utilisateur qui modifie + * @param User $user Object user that modify * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet (cas escompte par exemple) * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) * @return int <0 if KO, >0 if OK @@ -2527,7 +2549,7 @@ class Facture extends CommonInvoice { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -2933,8 +2955,8 @@ class Facture extends CommonInvoice * @param int $type Type of line (0=product, 1=service). Not used if fk_product is defined, the type of product is used. * @param int $rang Position of line * @param int $special_code Special code (also used by externals modules!) - * @param string $origin 'order', ... - * @param int $origin_id Id of origin object + * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... + * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param int $fk_parent_line Id of parent line * @param int $fk_fournprice Supplier price id (to calculate margin) or '' * @param int $pa_ht Buying price of line (to calculate margin) or '' @@ -3054,6 +3076,7 @@ class Facture extends CommonInvoice $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); // Clean vat code + $reg = array(); $vat_src_code = ''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { @@ -3682,47 +3705,62 @@ class Facture extends CommonInvoice public function getNextNumRef($soc, $mode = 'next') { global $conf, $langs; - $langs->load("bills"); + + if ($this->module_source == 'takepos') { + $langs->load('cashdesk@cashdesk'); + + $moduleName = 'takepos'; + $moduleSourceName = 'Takepos'; + $addonConstName = 'TAKEPOS_REF_ADDON'; + + // Clean parameters (if not defined or using deprecated value) + if (empty($conf->global->TAKEPOS_REF_ADDON)) $conf->global->TAKEPOS_REF_ADDON = 'mod_takepos_ref_simple'; + + $addon = $conf->global->TAKEPOS_REF_ADDON; + } else { + $langs->load('bills'); + + $moduleName = 'facture'; + $moduleSourceName = 'Invoice'; + $addonConstName = 'FACTURE_ADDON'; // Clean parameters (if not defined or using deprecated value) if (empty($conf->global->FACTURE_ADDON)) $conf->global->FACTURE_ADDON = 'mod_facture_terre'; elseif ($conf->global->FACTURE_ADDON == 'terre') $conf->global->FACTURE_ADDON = 'mod_facture_terre'; elseif ($conf->global->FACTURE_ADDON == 'mercure') $conf->global->FACTURE_ADDON = 'mod_facture_mercure'; - if (!empty($conf->global->FACTURE_ADDON)) - { - dol_syslog("Call getNextNumRef with FACTURE_ADDON = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG); + $addon = $conf->global->FACTURE_ADDON; + } + + if (!empty($addon)) { + dol_syslog("Call getNextNumRef with " . $addonConstName . " = " . $conf->global->FACTURE_ADDON . ", thirdparty=" . $soc->nom . ", type=" . $soc->typent_code, LOG_DEBUG); $mybool = false; - $file = $conf->global->FACTURE_ADDON.".php"; - $classname = $conf->global->FACTURE_ADDON; + $file = $addon . '.php'; + $classname = $addon; // Include file with class $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) { - $dir = dol_buildpath($reldir."core/modules/facture/"); + $dir = dol_buildpath($reldir . 'core/modules/' . $moduleName . '/'); // Load file with numbering class (if found) - if (is_file($dir.$file) && is_readable($dir.$file)) - { + if (is_file($dir . $file) && is_readable($dir . $file)) { $mybool |= include_once $dir.$file; } } // For compatibility - if (!$mybool) - { - $file = $conf->global->FACTURE_ADDON."/".$conf->global->FACTURE_ADDON.".modules.php"; - $classname = "mod_facture_".$conf->global->FACTURE_ADDON; + if (!$mybool) { + $file = $addon . '/' . $addon . '.modules.php'; + $classname = 'mod_' . $moduleName . '_' . $addon; $classname = preg_replace('/\-.*$/', '', $classname); // Include file with class - foreach ($conf->file->dol_document_root as $dirroot) - { - $dir = $dirroot."/core/modules/facture/"; + foreach ($conf->file->dol_document_root as $dirroot) { + $dir = $dirroot . '/core/modules/' . $moduleName . '/'; // Load file with numbering class (if found) if (is_file($dir.$file) && is_readable($dir.$file)) { @@ -3731,14 +3769,12 @@ class Facture extends CommonInvoice } } - if (!$mybool) - { - dol_print_error('', "Failed to include file ".$file); + if (!$mybool) { + dol_print_error('', 'Failed to include file ' . $file); return ''; } $obj = new $classname(); - $numref = ""; $numref = $obj->getNextValue($soc, $this, $mode); /** @@ -3747,17 +3783,14 @@ class Facture extends CommonInvoice */ if ($mode != 'last' && !$numref) { $this->error = $obj->error; - //dol_print_error($this->db,"Facture::getNextNumRef ".$obj->error); - return ""; + return ''; } return $numref; - } - else - { - $langs->load("errors"); - print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Invoice")); - return ""; + } else { + $langs->load('errors'); + print $langs->trans('Error') . ' ' . $langs->trans('ErrorModuleSetupNotComplete', $langs->transnoentitiesnoconv($moduleSourceName)); + return ''; } } @@ -4684,18 +4717,18 @@ class Facture extends CommonInvoice if ($this->statut != Facture::STATUS_VALIDATED) return false; $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); - if($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) + if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { $totalpaye = $this->getSommePaiement(); $totalpaye = floatval($totalpaye); $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); - if($totalpaye >= 0 && $RetainedWarrantyAmount>= 0) + if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) { - if( ($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay) ) + if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; } - elseif($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay) ) + elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; } @@ -4797,8 +4830,8 @@ class Facture extends CommonInvoice $retainedWarrantyAmount = $this->total_ttc * $this->retained_warranty / 100; } - if ($rounding < 0){ - $rounding=min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); + if ($rounding < 0) { + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); } if($rounding>0){ diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index f24f31bbc9a..ea0b17bc59a 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -22,10 +22,10 @@ * \ingroup factures * \brief Fichier de la classe de gestion des stats des factures */ -include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; -include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; -include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; /** * Class to manage stats for invoices (customer and supplier) @@ -64,32 +64,32 @@ class FactureStats extends Stats if ($mode == 'customer') { - $object=new Facture($this->db); + $object = new Facture($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total'; - $this->field_line='total_ht'; + $this->field = 'total'; + $this->field_line = 'total_ht'; } if ($mode == 'supplier') { - $object=new FactureFournisseur($this->db); + $object = new FactureFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as f"; $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='total_ht'; - $this->field_line='total_ht'; + $this->field = 'total_ht'; + $this->field_line = 'total_ht'; } $this->where = " f.fk_statut >= 0"; - $this->where.= " AND f.entity IN (".getEntity('invoice').")"; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($mode == 'customer') $this->where.=" AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) + $this->where .= " AND f.entity IN (".getEntity('invoice').")"; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND f.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($mode == 'customer') $this->where .= " AND (f.fk_statut <> 3 OR f.close_code <> 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) if ($this->socid) { - $this->where.=" AND f.fk_soc = ".$this->socid; + $this->where .= " AND f.fk_soc = ".$this->socid; } - if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; - if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)"; - else $this->where.= " AND f.type IN (0,1,2,3,5)"; + if ($this->userid > 0) $this->where .= ' AND f.fk_user_author = '.$this->userid; + if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where .= " AND f.type IN (0,1,2,5)"; + else $this->where .= " AND f.type IN (0,1,2,3,5)"; } @@ -105,14 +105,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); + $res = $this->_getNbByMonth($year, $sql, $format); //var_dump($res);print '
    '; return $res; } @@ -128,11 +128,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(f.datef,'%Y') as dm, COUNT(*), SUM(c.".$this->field.")"; - $sql.= " FROM ".$this->from; + $sql .= " FROM ".$this->from; if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getNbByYear($sql); } @@ -150,14 +150,14 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); + $res = $this->_getAmountByMonth($year, $sql, $format); //var_dump($res);print '
    '; return $res; } @@ -173,12 +173,12 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); return $this->_getAverageByMonth($year, $sql); } @@ -193,11 +193,11 @@ class FactureStats extends Stats global $user; $sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + $sql .= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY year"; + $sql .= $this->db->order('year', 'DESC'); return $this->_getAllByYear($sql); } @@ -205,23 +205,24 @@ class FactureStats extends Stats /** * Return nb, amount of predefined product for year * - * @param int $year Year to scan - * @return array Array of values + * @param int $year Year to scan + * @param int $limit Limit + * @return array Array of values */ - public function getAllByProduct($year) + public function getAllByProduct($year, $limit = 10) { global $user; $sql = "SELECT product.ref, COUNT(product.ref) as nb, SUM(tl.".$this->field_line.") as total, AVG(tl.".$this->field_line.") as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; - $sql.= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; - $sql.= $this->db->order('nb', 'DESC'); + $sql .= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".$this->where; + $sql .= " AND f.rowid = tl.fk_facture AND tl.fk_product = product.rowid"; + $sql .= " AND f.datef BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " GROUP BY product.ref"; + $sql .= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); + return $this->_getAllByProduct($sql, $limit); } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index e880d77db74..cccae974893 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -58,7 +58,7 @@ $result=restrictedArea($user, 'facture', $id, ''); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index 370bfe9a8b9..c04e9072339 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -33,10 +33,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -if (!empty($conf->projet->enabled)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - //require_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php'; -} +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; @@ -54,6 +51,8 @@ $cancel = GETPOST('cancel', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicetemplatelist'; // To manage different context of search +$socid = GETPOST('socid', 'int'); + // Security check $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $lineid = GETPOST('lineid', 'int'); @@ -62,7 +61,6 @@ if ($user->socid) $socid = $user->socid; $objecttype = 'facture_rec'; if ($action == "create" || $action == "add") $objecttype = ''; $result = restrictedArea($user, 'facture', $id, $objecttype); -$projectid = GETPOST('projectid', 'int'); $search_ref = GETPOST('search_ref'); $search_societe = GETPOST('search_societe'); @@ -85,7 +83,7 @@ $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (!$sortorder) $sortorder = 'DESC'; @@ -146,6 +144,13 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +if ($socid > 0) { + $tmpthirdparty = new Societe($db); + $res = $tmpthirdparty->fetch($socid); + if ($res > 0) $search_societe = $tmpthirdparty->name; +} + + /* * Actions @@ -218,6 +223,7 @@ $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray[' /* * List mode */ + $sql = "SELECT s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title, f.total, f.tva as total_vat, f.total_ttc, f.frequency, f.unit_frequency,"; $sql .= " f.nb_gen_done, f.nb_gen_max, f.date_last_gen, f.date_when, f.suspended,"; $sql .= " f.datec, f.tms,"; @@ -243,6 +249,7 @@ if (!$user->rights->societe->client->voir && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; } if ($search_ref) $sql .= natural_search('f.titre', $search_ref); +if ($socid) $sql .= ' AND s.rowid = '.(int) $socid; if ($search_societe) $sql .= natural_search('s.nom', $search_societe); if ($search_montant_ht != '') $sql .= natural_search('f.total', $search_montant_ht, 1); if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_vat, 1); @@ -286,7 +293,7 @@ if ($resql) $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($socid) $param .= '&socid='.urlencode($socid); + if ($socid > 0) $param .= '&socid='.urlencode($socid); if ($search_day) $param .= '&search_day='.urlencode($search_day); if ($search_month) $param .= '&search_month='.urlencode($search_month); if ($search_year) $param .= '&search_year='.urlencode($search_year); @@ -299,12 +306,11 @@ if ($resql) if ($search_montant_vat != '') $param .= '&search_montant_vat='.urlencode($search_montant_vat); if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_payment_mode != '') $param .= '&search_payment_mode='.urlencode($search_payment_mode); - if ($search_payment_type != '') $param .= '&search_payment_type='.urlencode($search_payment_type); + if ($search_payment_term != '') $param .= '&search_payment_term='.urlencode($search_payment_term); if ($search_recurring != '' && $search_recurrning != '-1') $param .= '&search_recurring='.urlencode($search_recurring); if ($search_frequency > 0) $param .= '&search_frequency='.urlencode($search_frequency); if ($search_unit_frequency != '') $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); if ($search_status != '') $param .= '&search_status='.urlencode($search_status); - if ($option) $param .= "&option=".urlencode($option); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -326,12 +332,16 @@ if ($resql) print ''; print ''; - print_barre_liste($langs->trans("RepeatableInvoices"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit); + $title = $langs->trans("RepeatableInvoices"); + + print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'invoicing', 0, '', '', $limit); print ''.$langs->trans("ToCreateAPredefinedInvoice", $langs->transnoentitiesnoconv("ChangeIntoRepeatableInvoice")).'

    '; $i = 0; + $moreforfilter = ''; + print '
    '; print ''."\n"; @@ -467,7 +477,6 @@ if ($resql) print ''; print "\n"; - print ''; if (!empty($arrayfields['f.titre']['checked'])) print_liste_field_titre($arrayfields['f.titre']['label'], $_SERVER['PHP_SELF'], "f.titre", "", $param, "", $sortfield, $sortorder); if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], "s.nom", "", $param, "", $sortfield, $sortorder); @@ -527,21 +536,21 @@ if ($resql) } if (!empty($arrayfields['f.total']['checked'])) { - print ''."\n"; + print ''."\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total'; $totalarray['val']['f.total'] += $objp->total; } if (!empty($arrayfields['f.tva']['checked'])) { - print ''."\n"; + print ''."\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.tva'; $totalarray['val']['f.tva'] += $objp->total_vat; } if (!empty($arrayfields['f.total_ttc']['checked'])) { - print ''."\n"; + print ''."\n"; if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; $totalarray['val']['f.total_ttc'] += $objp->total_ttc; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index dc685c0a893..db1dc56d488 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -87,6 +87,11 @@ $search_montant_vat = GETPOST('search_montant_vat', 'alpha'); $search_montant_localtax1 = GETPOST('search_montant_localtax1', 'alpha'); $search_montant_localtax2 = GETPOST('search_montant_localtax2', 'alpha'); $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha'); +$search_multicurrency_code = GETPOST('search_multicurrency_code', 'alpha'); +$search_multicurrency_tx = GETPOST('search_multicurrency_tx', 'alpha'); +$search_multicurrency_montant_ht = GETPOST('search_multicurrency_montant_ht', 'alpha'); +$search_multicurrency_montant_vat = GETPOST('search_multicurrency_montant_vat', 'alpha'); +$search_multicurrency_montant_ttc = GETPOST('search_multicurrency_montant_ttc', 'alpha'); $search_status = GETPOST('search_status', 'intcomma'); $search_paymentmode = GETPOST('search_paymentmode', 'int'); $search_paymentterms = GETPOST('search_paymentterms', 'int'); @@ -116,7 +121,7 @@ $filtre = GETPOST('filtre', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || !empty($search_btn) || !empty($search_remove_btn) || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (!$sortorder && !empty($conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER) && $search_status == '1') $sortorder = $conf->global->INVOICE_DEFAULT_UNPAYED_SORT_ORDER; @@ -183,6 +188,13 @@ $arrayfields = array( 'f.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>130), 'dynamount_payed'=>array('label'=>"Received", 'checked'=>0, 'position'=>140), 'rtp'=>array('label'=>"Rest", 'checked'=>0, 'position'=>150), // Not enabled by default because slow + 'f.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>160), + 'f.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>170), + 'f.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>180), + 'f.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>190), + 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>200), + 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>210), + 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>220), // Not enabled by default because slow 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'f.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), @@ -236,6 +248,11 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_montant_localtax1 = ''; $search_montant_localtax2 = ''; $search_montant_ttc = ''; + $search_multicurrency_code = ''; + $search_multicurrency_tx = ''; + $search_multicurrency_montant_ht = ''; + $search_multicurrency_montant_vat = ''; + $search_multicurrency_montant_ttc = ''; $search_status = ''; $search_paymentmode = ''; $search_paymentterms = ''; @@ -383,6 +400,7 @@ $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; $sql .= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql .= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; +$sql .= ' f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva as multicurrency_total_vat, f.multicurrency_total_ttc,'; $sql .= ' f.datef as df, f.date_lim_reglement as datelimite, f.module_source, f.pos_source,'; $sql .= ' f.paye as paye, f.fk_statut, f.close_code,'; $sql .= ' f.datec as date_creation, f.tms as date_update, f.date_closing as date_closing,'; @@ -394,7 +412,7 @@ $sql .= " country.code as country_code,"; $sql .= " p.rowid as project_id, p.ref as project_ref, p.title as project_label"; // We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0) // TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field. -if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed'; +if (!$sall) $sql .= ', SUM(pf.amount) as dynamount_payed, SUM(pf.multicurrency_amount) as multicurrency_dynamount_payed'; if ($search_categ_cus) $sql .= ", cc.fk_categorie, cc.fk_soc"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -459,6 +477,11 @@ if ($search_montant_vat != '') $sql .= natural_search('f.tva', $search_montant_v if ($search_montant_localtax1 != '') $sql .= natural_search('f.localtax1', $search_montant_localtax1, 1); if ($search_montant_localtax2 != '') $sql .= natural_search('f.localtax2', $search_montant_localtax2, 1); if ($search_montant_ttc != '') $sql .= natural_search('f.total_ttc', $search_montant_ttc, 1); +if ($search_multicurrency_code != '') $sql .= ' AND f.multicurrency_code = "'.$db->escape($search_multicurrency_code).'"'; +if ($search_multicurrency_tx != '') $sql .= natural_search('f.multicurrency_tx', $search_multicurrency_tx, 1); +if ($search_multicurrency_montant_ht != '') $sql .= natural_search('f.multicurrency_total_ht', $search_multicurrency_montant_ht, 1); +if ($search_multicurrency_montant_vat != '') $sql .= natural_search('f.multicurrency_total_tva', $search_multicurrency_montant_vat, 1); +if ($search_multicurrency_montant_ttc != '') $sql .= natural_search('f.multicurrency_total_ttc', $search_multicurrency_montant_ttc, 1); if ($search_categ_cus > 0) $sql .= " AND cc.fk_categorie = ".$db->escape($search_categ_cus); if ($search_categ_cus == -2) $sql .= " AND cc.fk_categorie IS NULL"; if ($search_status != '-1' && $search_status != '') @@ -591,6 +614,11 @@ if ($resql) if ($search_montant_localtax1 != '') $param .= '&search_montant_localtax1='.urlencode($search_montant_localtax1); if ($search_montant_localtax2 != '') $param .= '&search_montant_localtax2='.urlencode($search_montant_localtax2); if ($search_montant_ttc != '') $param .= '&search_montant_ttc='.urlencode($search_montant_ttc); + if ($search_multicurrency_code != '') $param .= '&search_multicurrency_code='.urlencode($search_multicurrency_code); + if ($search_multicurrency_tx != '') $param .= '&search_multicurrency_tx='.urlencode($search_multicurrency_tx); + if ($search_multicurrency_montant_ht != '') $param .= '&search_multicurrency_montant_ht='.urlencode($search_multicurrency_montant_ht); + if ($search_multicurrency_montant_vat != '') $param .= '&search_multicurrency_montant_vat='.urlencode($search_multicurrency_montant_vat); + if ($search_multicurrency_montant_ttc != '') $param .= '&search_multicurrency_montant_ttc='.urlencode($search_multicurrency_montant_ttc); if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($search_paymentmode > 0) $param .= '&search_paymentmode='.urlencode($search_paymentmode); if ($search_paymentterms > 0) $param .= '&search_paymentterms='.urlencode($search_paymentterms); @@ -878,13 +906,11 @@ if ($resql) print ''; print ''; } - if (!empty($arrayfields['f.retained_warranty']['checked'])) { print ''; } - if (!empty($arrayfields['dynamount_payed']['checked'])) { print ''; } + if (!empty($arrayfields['f.multicurrency_code']['checked'])) + { + // Currency + print ''; + } + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) + { + // Currency rate + print ''; + } + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) + { + // Amount + print ''; + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) + { + print ''; + } + if (!empty($arrayfields['multicurrency_rtp']['checked'])) + { + print ''; + } if (!empty($arrayfields['f.date_closing']['checked'])) { print '\n"; print ''; - if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); - if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); - if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref']['checked'])) print_liste_field_titre($arrayfields['f.ref']['label'], $_SERVER['PHP_SELF'], 'f.ref', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.ref_client']['checked'])) print_liste_field_titre($arrayfields['f.ref_client']['label'], $_SERVER["PHP_SELF"], 'f.ref_client', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.type']['checked'])) print_liste_field_titre($arrayfields['f.type']['label'], $_SERVER["PHP_SELF"], 'f.type', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.date']['checked'])) print_liste_field_titre($arrayfields['f.date']['label'], $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) print_liste_field_titre($arrayfields['f.date_lim_reglement']['label'], $_SERVER['PHP_SELF'], "f.date_lim_reglement", '', $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['p.title']['checked'])) print_liste_field_titre($arrayfields['p.title']['label'], $_SERVER['PHP_SELF'], "p.title", '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.module_source']['checked'])) print_liste_field_titre($arrayfields['f.module_source']['label'], $_SERVER["PHP_SELF"], "f.module_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.pos_source']['checked'])) print_liste_field_titre($arrayfields['f.pos_source']['label'], $_SERVER["PHP_SELF"], "f.pos_source", "", $param, "", $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_localtax2']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax2']['label'], $_SERVER['PHP_SELF'], 'f.localtax2', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.retained_warranty']['checked'])) print_liste_field_titre($arrayfields['f.retained_warranty']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'align="right"', $sortfield, $sortorder); + if (!empty($arrayfields['dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['rtp']['checked'])) print_liste_field_titre($arrayfields['rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.multicurrency_code']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_code']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_code', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_tx']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_tx', '', $param, '', $sortfield, $sortorder); + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ht']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ht', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_vat']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_tva', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) print_liste_field_titre($arrayfields['f.multicurrency_total_ttc']['label'], $_SERVER['PHP_SELF'], 'f.multicurrency_total_ttc', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) print_liste_field_titre($arrayfields['multicurrency_dynamount_payed']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + if (!empty($arrayfields['multicurrency_rtp']['checked'])) print_liste_field_titre($arrayfields['multicurrency_rtp']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -994,6 +1072,11 @@ if ($resql) $facturestatic->total_ht = $obj->total_ht; $facturestatic->total_tva = $obj->total_vat; $facturestatic->total_ttc = $obj->total_ttc; + $facturestatic->multicurrency_code = $obj->multicurrency_code; + $facturestatic->multicurrency_tx = $obj->multicurrency_tx; + $facturestatic->multicurrency_total_ht = $obj->multicurrency_total_ht; + $facturestatic->multicurrency_total_tva = $obj->multicurrency_total_vat; + $facturestatic->multicurrency_total_ttc = $obj->multicurrency_total_ttc; $facturestatic->statut = $obj->fk_statut; $facturestatic->close_code = $obj->close_code; $facturestatic->total_ttc = $obj->total_ttc; @@ -1031,16 +1114,27 @@ if ($resql) $totaldeposits = $facturestatic->getSumDepositsUsed(); $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = price2num($facturestatic->total_ttc - $totalpay); + $multicurrency_paiement = $facturestatic->getSommePaiement(1); + $multicurrency_totalcreditnotes = $facturestatic->getSumCreditNotesUsed(1); + $multicurrency_totaldeposits = $facturestatic->getSumDepositsUsed(1); + $multicurrency_totalpay = $multicurrency_paiement + $multicurrency_totalcreditnotes + $multicurrency_totaldeposits; + $multicurrency_remaintopay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_totalpay); if ($facturestatic->statut == Facture::STATUS_CLOSED && $facturestatic->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment $remaintopay = 0; + $multicurrency_remaintopay = 0; } if ($facturestatic->type == Facture::TYPE_CREDIT_NOTE && $obj->paye == 1) { // If credit note closed, we take into account the amount not yet consummed - $remaincreditnote = $discount->getAvailableDiscounts($obj->fk_soc, '', 'rc.fk_facture_source='.$facturestatic->id); + $remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic, '', 'rc.fk_facture_source='.$facturestatic->id); $remaintopay = -$remaincreditnote; $totalpay = price2num($facturestatic->total_ttc - $remaintopay); + $multicurrency_remaincreditnote = $discount->getAvailableDiscounts($thirdpartystatic, '', 'rc.fk_facture_source='.$facturestatic->id, 0, 0, 1); + $multicurrency_remaintopay = -$multicurrency_remaincreditnote; + $multicurrency_totalpay = price2num($facturestatic->multicurrency_total_ttc - $multicurrency_remaintopay); } + $facturestatic->alreadypaid = $paiement; + print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."\n"; + if (!$i) $totalarray['nbfield']++; + } + + // Currency rate + if (!empty($arrayfields['f.multicurrency_tx']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount HT + if (!empty($arrayfields['f.multicurrency_total_ht']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount VAT + if (!empty($arrayfields['f.multicurrency_total_vat']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + // Amount TTC + if (!empty($arrayfields['f.multicurrency_total_ttc']['checked'])) + { + print '\n"; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['multicurrency_dynamount_payed']['checked'])) + { + print ''; // TODO Use a denormalized field + if (!$i) $totalarray['nbfield']++; + } + + // Pending amount + if (!empty($arrayfields['multicurrency_rtp']['checked'])) + { + print ''; // TODO Use a denormalized field + if (!$i) $totalarray['nbfield']++; + } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index bd749e02dee..a72b03b47a3 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -235,7 +235,9 @@ print '
    '; // Show filter box print ''; +print ''; print ''; + print '
    '.price($objp->total).''.price($objp->total).''.price($objp->total_vat).''.price($objp->total_vat).''.price($objp->total_ttc).''.price($objp->total_ttc).''; print ''; @@ -895,6 +921,51 @@ if ($resql) print ''; print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; @@ -936,31 +1007,38 @@ if ($resql) print "
    '; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : ' ').''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ' '); + print '
    '; print ''; // Company diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 447f5f47ecc..4c7e0714caa 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -348,7 +348,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) $sql .= " GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,"; $sql .= " s.nom, s.rowid, s.code_client, s.code_compta, s.email,"; $sql .= " cc.rowid, cc.code"; - $sql .= " ORDER BY f.tms DESC "; + $sql .= " ORDER BY f.tms DESC"; $sql .= $db->plimit($max, 0); $resql = $db->query($sql); @@ -455,7 +455,7 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-> $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; $sql .= ", s.nom as name"; $sql .= ", s.rowid as socid"; - $sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; + $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; $sql .= ", SUM(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn"; @@ -503,10 +503,14 @@ if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-> $thirdpartystatic->id = $obj->socid; $thirdpartystatic->name = $obj->name; + $thirdpartystatic->email = $obj->email; + $thirdpartystatic->country_id = 0; + $thirdpartystatic->country_code = ''; + $thirdpartystatic->client = 0; $thirdpartystatic->fournisseur = 1; - //$thirdpartystatic->code_client = $obj->code_client; + $thirdpartystatic->code_client = ''; $thirdpartystatic->code_fournisseur = $obj->code_fournisseur; - //$thirdpartystatic->code_compta = $obj->code_compta; + $thirdpartystatic->code_compta = ''; $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; print ''; + print ''; if (!$i) $totalarray['nbfield']++; // Account diff --git a/htdocs/compta/paiement/tovalidate.php b/htdocs/compta/paiement/tovalidate.php index 1c5e4be20c2..c14c29f3179 100644 --- a/htdocs/compta/paiement/tovalidate.php +++ b/htdocs/compta/paiement/tovalidate.php @@ -42,7 +42,7 @@ if ($user->socid > 0) $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -64,7 +64,7 @@ if (! $sortfield) $sortfield="p.rowid"; llxHeader(); $sql = "SELECT p.rowid, p.datep as dp, p.amount, p.statut"; -$sql.=", c.libelle as paiement_type, p.num_paiement"; +$sql.=", c.libelle as paiement_type, p.num_paiement as num_payment"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id"; if ($socid) { @@ -119,7 +119,7 @@ if ($resql) print ''; print ''; print '\n"; - print "\n"; + print "\n"; print ''; print ''; - print ''."\n"; + print ''."\n"; print ''; print ''; diff --git a/htdocs/compta/prelevement/bons.php b/htdocs/compta/prelevement/bons.php index c623d660aaa..b42e6a4fe62 100644 --- a/htdocs/compta/prelevement/bons.php +++ b/htdocs/compta/prelevement/bons.php @@ -39,7 +39,7 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index d998554b533..68f40999aa7 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -49,7 +49,7 @@ $socid = GETPOST('socid', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 4050d081fe4..41f1ebf5a62 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -484,7 +484,7 @@ class BonPrelevement extends CommonObject $paiement->amounts = $cursoramounts; // Array with detail of dispatching of payments for each invoice $paiement->paiementid = 3; // $paiement->num_payment = $this->ref; // Set ref of direct debit note - $paiement->num_paiement = $this->ref; // For bacward compatibility + $paiement->num_paiement = $this->ref; // For backward compatibility $paiement->id_prelevement = $this->id; $paiement_id = $paiement->create($user); diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index 740a1e47784..c78dbd06259 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -154,6 +154,7 @@ class RejetPrelevement $pai->datepaye = $date_rejet; $pai->paiementid = 3; // type of payment: withdrawal $pai->num_paiement = $fac->ref; + $pai->num_payment = $fac->ref; if ($pai->create($this->user) < 0) // we call with no_commit { diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index d1b6361cc34..45c413efb76 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -48,7 +48,7 @@ $action = GETPOST('action', 'alpha'); $mode = GETPOST('mode', 'alpha') ?GETPOST('mode', 'alpha') : 'real'; $format = GETPOST('format', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; diff --git a/htdocs/compta/prelevement/demandes.php b/htdocs/compta/prelevement/demandes.php index 61c457c9b17..181f71a678c 100644 --- a/htdocs/compta/prelevement/demandes.php +++ b/htdocs/compta/prelevement/demandes.php @@ -50,7 +50,7 @@ $search_societe = trim(GETPOST('search_societe', 'alpha')); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 63db9aea363..3297042407f 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -45,7 +45,7 @@ $ref = GETPOST('ref', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/fiche-rejet.php b/htdocs/compta/prelevement/fiche-rejet.php index 4320a0c6094..44be3d1cd01 100644 --- a/htdocs/compta/prelevement/fiche-rejet.php +++ b/htdocs/compta/prelevement/fiche-rejet.php @@ -45,7 +45,7 @@ $ref = GETPOST('ref', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/fiche-stat.php b/htdocs/compta/prelevement/fiche-stat.php index 70441ff19c2..6e8e8390ae8 100644 --- a/htdocs/compta/prelevement/fiche-stat.php +++ b/htdocs/compta/prelevement/fiche-stat.php @@ -43,7 +43,7 @@ $ref = GETPOST('ref', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/line.php b/htdocs/compta/prelevement/line.php index 5d0734cae22..3615809d21a 100644 --- a/htdocs/compta/prelevement/line.php +++ b/htdocs/compta/prelevement/line.php @@ -43,7 +43,7 @@ $action = GETPOST('action', 'alpha'); $id = GETPOST('id', 'int'); $socid = GETPOST('socid', 'int'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortorder = GETPOST('sortorder', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha'); diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index e5ba1daffa8..bbac6c6232e 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -41,7 +41,7 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/prelevement/rejets.php b/htdocs/compta/prelevement/rejets.php index 4235f5d7fc3..cc4f3fe5e79 100644 --- a/htdocs/compta/prelevement/rejets.php +++ b/htdocs/compta/prelevement/rejets.php @@ -39,7 +39,7 @@ if ($user->socid) $socid=$user->socid; $result = restrictedArea($user, 'prelevement', '', '', 'bons'); // Get supervariables -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortorder = GETPOST('sortorder', 'alpha'); $sortfield = GETPOST('sortfield', 'alpha'); diff --git a/htdocs/compta/prelevement/stats.php b/htdocs/compta/prelevement/stats.php index 55bf5e1f022..fdc1d622e90 100644 --- a/htdocs/compta/prelevement/stats.php +++ b/htdocs/compta/prelevement/stats.php @@ -54,15 +54,15 @@ $sql.= " AND pb.entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - if ( $num > 0 ) - { - $row = $db->fetch_row($resql); - $total = $row[0]; - $nbtotal = $row[1]; - } + if ( $num > 0 ) + { + $row = $db->fetch_row($resql); + $total = $row[0]; + $nbtotal = $row[1]; + } } @@ -150,15 +150,15 @@ $sql.= " AND pl.statut = 3"; $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - if ( $num > 0 ) - { - $row = $db->fetch_row($resql); - $total = $row[0]; - $nbtotal = $row[1]; - } + if ( $num > 0 ) + { + $row = $db->fetch_row($resql); + $total = $row[0]; + $nbtotal = $row[1]; + } } /* diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 60ea008a834..3f2112537b1 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -48,7 +48,7 @@ $hookmanager->initHooks(array('recapcomptacard', 'globalcard')); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -83,7 +83,7 @@ $form = new Form($db); $userstatic = new User($db); $title = $langs->trans("ThirdParty").' - '.$langs->trans("Summary"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Symmary"); +if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.' - '.$langs->trans("Summary"); $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index ee76a29d282..17d2becfc19 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -57,7 +57,7 @@ if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'account $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -67,8 +67,7 @@ if (!$sortorder) $sortorder = 'ASC'; // Date range $year = GETPOST('year', 'int'); -if (empty($year)) -{ +if (empty($year)) { $year_current = strftime("%Y", dol_now()); $month_current = strftime("%m", dol_now()); $year_start = $year_current; @@ -114,7 +113,7 @@ $tmps = dol_getdate($date_start); $year_start = $tmps['year']; $tmpe = dol_getdate($date_end); $year_end = $tmpe['year']; -$nbofyear = ($year_end - $start_year) + 1; +$nbofyear = ($year_end - $year_start) + 1; //var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour')); // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING') @@ -193,17 +192,21 @@ if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') } // Show report array -$param = '&modecompta='.$modecompta; +$param = '&modecompta='.urlencode($modecompta).'&showaccountdetail='.urlencode($showaccountdetail); if ($date_startday) $param .= '&date_startday='.$date_startday; if ($date_startmonth) $param .= '&date_startmonth='.$date_startmonth; if ($date_startyear) $param .= '&date_startyear='.$date_startyear; if ($date_endday) $param .= '&date_endday='.$date_endday; if ($date_endmonth) $param .= '&date_endmonth='.$date_endmonth; -if ($date_endyear) $param .= '&date_endyear='.$date_startyear; +if ($date_endyear) $param .= '&date_endyear='.$date_endyear; print '
    '.$langs->trans("Filter").'
    '; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3853847c363..b4da848ea5a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -49,7 +49,7 @@ $socid = GETPOST('socid', 'int'); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $amounts = array(); $amountsresttopay = array(); diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 526905e2ee9..89445e1ec74 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -48,7 +48,7 @@ $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_ $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "b.dateo,b.rowid"; if (empty($page) || $page == -1) { $page = 0; } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 823ae87d420..4534f08dbb1 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -45,7 +45,7 @@ $search_amount = GETPOST('search_amount', 'alpha'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index b1de388f7ba..c78a010777a 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -68,7 +68,7 @@ $search_payment_num=GETPOST('search_payment_num', 'alpha'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -115,7 +115,7 @@ if (GETPOST("orphelins", "alpha")) { // Payments not linked to an invoice. Should not happend. For debug only. $sql = "SELECT p.rowid, p.ref, p.datep as dp, p.amount,"; - $sql.= " p.statut, p.num_paiement,"; + $sql.= " p.statut, p.num_paiement as num_payment,"; $sql.= " c.code as paiement_code"; // Add fields from hooks $parameters=array(); @@ -133,7 +133,7 @@ if (GETPOST("orphelins", "alpha")) else { $sql = "SELECT DISTINCT p.rowid, p.ref, p.datep as dp, p.amount,"; // DISTINCT is to avoid duplicate when there is a link to sales representatives - $sql.= " p.statut, p.num_paiement,"; + $sql.= " p.statut, p.num_paiement as num_payment,"; $sql.= " c.code as paiement_code,"; $sql.= " ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.fk_accountancy_journal as accountancy_journal,"; $sql.= " s.rowid as socid, s.nom as name, s.email"; @@ -323,7 +323,7 @@ if ($resql) if (!$i) $totalarray['nbfield']++; // Payment number - print ''.$objp->num_paiement.''.$objp->num_payment.'
    '.img_object($langs->trans("ShowPayment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."$objp->paiement_type $objp->num_paiement$objp->paiement_type $objp->num_payment'.price($objp->amount).''; diff --git a/htdocs/compta/paiement_charge.php b/htdocs/compta/paiement_charge.php index 561120aead6..31e13a9d356 100644 --- a/htdocs/compta/paiement_charge.php +++ b/htdocs/compta/paiement_charge.php @@ -108,9 +108,10 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y $paiement->chid = $chid; $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Tableau de montant - $paiement->paiementtype = $_POST["paiementtype"]; - $paiement->num_paiement = $_POST["num_paiement"]; - $paiement->note = $_POST["note"]; + $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); + $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); + $paiement->note = GETPOST("note", 'none'); + $paiement->note_private = GETPOST("note", 'none'); if (!$error) { @@ -243,7 +244,7 @@ if ($action == 'create') print '
    '.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
    '.$langs->trans("Comments").'
    '; print ''; -print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 '); +if ($modecompta == 'BOOKKEEPING') { + print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 '); +} else { + print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'width200 '); +} print_liste_field_titre(''); if ($modecompta == 'BOOKKEEPING') { @@ -243,7 +246,7 @@ if ($modecompta == 'BOOKKEEPING') $sql .= " AND f.entity = ".$conf->entity; if (!empty($date_start) && !empty($date_end)) $sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'"; - $sql .= " GROUP BY pcg_type, pcg_subtype, name, socid"; + $sql .= " GROUP BY pcg_type, name, socid"; $sql .= $db->order($sortfield, $sortorder); $oldpcgtype = ''; diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 69ad435c64c..d7f20622a43 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -603,7 +603,7 @@ if ($id > 0) /* * Payments */ - $sql = "SELECT p.rowid, p.num_paiement, datep as dp, p.amount,"; + $sql = "SELECT p.rowid, p.num_paiement as num_payment, datep as dp, p.amount,"; $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p"; @@ -647,7 +647,7 @@ if ($id > 0) print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''; print '\n"; $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; - print "\n"; + print "\n"; if (!empty($conf->banque->enabled)) { $bankaccountstatic->id = $objp->baid; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 629a73578b2..02c15b099b9 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -69,8 +69,17 @@ class PaymentSocialContribution extends CommonObject */ public $fk_typepaiement; + /** + * @var string + * @deprecated + */ public $num_paiement; + /** + * @var string + */ + public $num_payment; + /** * @var int ID */ @@ -125,7 +134,8 @@ class PaymentSocialContribution extends CommonObject if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; if (isset($this->amount)) $this->amount = trim($this->amount); if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); if (isset($this->note)) $this->note = trim($this->note); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; @@ -149,11 +159,11 @@ class PaymentSocialContribution extends CommonObject if ($totalamount != 0) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementcharge (fk_charge, datec, datep, amount,"; - $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql .= " fk_typepaiement, num_paiement as num_payment, note, fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; $sql .= " ".$totalamount.","; - $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_paiement)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; $sql .= " 0)"; $resql = $this->db->query($sql); @@ -231,7 +241,7 @@ class PaymentSocialContribution extends CommonObject $sql.= " t.datep,"; $sql.= " t.amount,"; $sql.= " t.fk_typepaiement,"; - $sql.= " t.num_paiement,"; + $sql.= " t.num_paiement as num_payment,"; $sql.= " t.note,"; $sql.= " t.fk_bank,"; $sql.= " t.fk_user_creat,"; @@ -260,7 +270,8 @@ class PaymentSocialContribution extends CommonObject $this->datep = $this->db->jdate($obj->datep); $this->amount = $obj->amount; $this->fk_typepaiement = $obj->fk_typepaiement; - $this->num_paiement = $obj->num_paiement; + $this->num_paiement = $obj->num_payment; + $this->num_payment = $obj->num_payment; $this->note = $obj->note; $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; @@ -301,7 +312,8 @@ class PaymentSocialContribution extends CommonObject if (isset($this->fk_charge)) $this->fk_charge = (int) $this->fk_charge; if (isset($this->amount)) $this->amount = trim($this->amount); if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; - if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); if (isset($this->note)) $this->note = trim($this->note); if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; @@ -511,8 +523,9 @@ class PaymentSocialContribution extends CommonObject $this->datep = ''; $this->amount = ''; $this->fk_typepaiement = ''; - $this->num_paiement = ''; - $this->note = ''; + $this->num_payment = ''; + $this->note_private = ''; + $this->note_public = ''; $this->fk_bank = ''; $this->fk_user_creat = ''; $this->fk_user_modif = ''; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 4a714df8bae..2d5d3c48899 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -54,7 +54,7 @@ $result = restrictedArea($user, 'tax', $id, 'chargesociales', 'charges'); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index e449f907bc8..7806e3e4cc1 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -27,8 +27,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; if (! empty($conf->projet->enabled)) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } // Load translation files required by the page @@ -51,10 +51,10 @@ $object = new ChargeSociales($db); if ($action == 'setlib' && $user->rights->tax->charges->creer) { - $object->fetch($id); - $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); - if ($result < 0) - setEventMessages($object->error, $object->errors, 'errors'); + $object->fetch($id); + $result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY'); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); } @@ -84,17 +84,17 @@ $morehtmlref.=$form->editfieldval("Label", 'lib', $object->label, $object, $user // Project if (! empty($conf->projet->enabled)) { - $langs->load("projects"); - $morehtmlref.='
    '.$langs->trans('Project') . ' : '; - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=''; - $morehtmlref.=$proj->ref; - $morehtmlref.=''; - } else { - $morehtmlref.=''; - } + $langs->load("projects"); + $morehtmlref.='
    '.$langs->trans('Project') . ' : '; + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } } $morehtmlref.=''; diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index 54cfcfc37cd..ca58830a7bb 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -60,7 +60,7 @@ $search_project = GETPOST('search_project', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index f89171a082d..5cfa5df06ed 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -48,7 +48,7 @@ if (!$year && $mode != 'sconly') { $year = date("Y", time()); } $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 5a64728029a..86fb598fb8b 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -279,7 +279,7 @@ if ($action == 'create') if (! empty($conf->banque->enabled)) { print ''; } diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 7f860491a8d..037e6baa5c3 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -55,7 +55,7 @@ $result = restrictedArea($user, 'tax', '', 'vat', 'charges'); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } @@ -70,8 +70,8 @@ if (!$sortfield) $sortfield = "name"; $object = new Tva($db); if ($id > 0) $object->fetch($id); -$upload_dir = $conf->tax->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart = 'tax'; +$upload_dir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($object->ref); +$modulepart = 'tax-vat'; /* @@ -144,7 +144,6 @@ if ($object->id) dol_fiche_end(); - $modulepart = 'tax'; $permission = $user->rights->tax->charges->creer; $permtoedit = $user->rights->fournisseur->facture->creer; $param = '&id='.$object->id; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 35492d19821..35c5dc2c052 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -53,7 +53,7 @@ $year = GETPOST("year", "int"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index a742c5c45fd..32c37301a0e 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -218,7 +218,7 @@ $dolibarr_main_authentication='dolibarr'; // 0 = No forced redirect // 1 = Force redirect to https, until SCRIPT_URI start with https into response // 2 = Force redirect to https, until SERVER["HTTPS"] is 'on' into response -// 'https://my.domain.com' = Force reditect to https using this domain name. +// 'https://my.domain.com' = Force redirect to https using this domain name. // Warning: If you enable this parameter, your web server must be configured to // respond URL with https protocol. // According to your web server setup, some values may works and other not. Try @@ -226,7 +226,7 @@ $dolibarr_main_authentication='dolibarr'; // Default value: 0 // Possible values: 0, 1, 2 or 'https://my.domain.com' // Examples: -// $dolibarr_main_force_https='0'; +// $dolibarr_main_force_https='1'; // $dolibarr_main_force_https='0'; diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 24d49040c13..d07b84e1e36 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -90,7 +90,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 458fdae07b1..f27903f559e 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -45,7 +45,7 @@ $socid = $object->thirdparty->id; $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index 8533cb13feb..0825c77a61f 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -57,7 +57,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9903e37cd5e..d7a8d025e21 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -103,12 +103,12 @@ $view = GETPOST("view", 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $userid = GETPOST('userid', 'int'); $begin = GETPOST('begin'); if (!$sortorder) $sortorder = "ASC"; if (!$sortfield) $sortfield = "p.lastname"; -if (empty($page) || $page < 0) { $page = 0; } +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } $offset = $limit * $page; $titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); @@ -497,11 +497,11 @@ print ''; print ''; print ''; print ''; -print ''; +//print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit); +print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "contact"; diff --git a/htdocs/contrat/admin/contract_extrafields.php b/htdocs/contrat/admin/contract_extrafields.php index 5f6bea09a3d..7696e3365d2 100644 --- a/htdocs/contrat/admin/contract_extrafields.php +++ b/htdocs/contrat/admin/contract_extrafields.php @@ -80,9 +80,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -95,9 +95,9 @@ if ($action != 'create' && $action != 'edit') if ($action == 'create') { print '
    '; - print load_fiche_titre($langs->trans('NewAttribute')); + print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -108,9 +108,9 @@ if ($action == 'create') if ($action == 'edit' && ! empty($attrname)) { print '

    '; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } llxFooter(); diff --git a/htdocs/contrat/admin/contractdet_extrafields.php b/htdocs/contrat/admin/contractdet_extrafields.php index 3a8340dfecc..a78669bec22 100644 --- a/htdocs/contrat/admin/contractdet_extrafields.php +++ b/htdocs/contrat/admin/contractdet_extrafields.php @@ -80,9 +80,9 @@ dol_fiche_end(); // Buttons if ($action != 'create' && $action != 'edit') { - print '
    '; - print "".$langs->trans("NewAttribute").""; - print "
    "; + print '
    '; + print "".$langs->trans("NewAttribute").""; + print "
    "; } @@ -97,7 +97,7 @@ if ($action == 'create') print '
    '; print load_fiche_titre($langs->trans('NewAttribute')); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; } /* ************************************************************************** */ @@ -107,10 +107,10 @@ if ($action == 'create') /* ************************************************************************** */ if ($action == 'edit' && ! empty($attrname)) { - print "
    "; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + print "
    "; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; } llxFooter(); diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 6b754dc9551..1fb3f572078 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -58,7 +58,7 @@ $result = restrictedArea($user, 'contrat', $id, ''); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 4e0e5cb5865..9bcae25badd 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -317,7 +317,7 @@ if (empty($reshook)) $array_options = array(); // For avoid conflicts if trigger used if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -1128,12 +1128,12 @@ if ($action == 'create') $classname = ucfirst($subelement); $objectsrc = new $classname($db); - $objectsrc->fetch(GETPOST('originid')); + $objectsrc->fetch($originid); if (empty($objectsrc->lines) && method_exists($objectsrc, 'fetch_lines')) $objectsrc->fetch_lines(); $objectsrc->fetch_thirdparty(); // Replicate extrafields - $objectsrc->fetch_optionals($originid); + $objectsrc->fetch_optionals(); $object->array_options = $objectsrc->array_options; $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); @@ -1703,7 +1703,8 @@ else // Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines) > 0) { $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid); + $line->id = $objp->rowid; + $line->fetch_optionals(); print $line->showOptionals($extrafields, 'view', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', 1); } } @@ -1793,7 +1794,8 @@ else if (is_array($extralabelslines) && count($extralabelslines) > 0) { $line = new ContratLigne($db); - $line->fetch_optionals($objp->rowid); + $line->id = $objp->rowid; + $line->fetch_optionals(); print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), '', '', 1); } } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 71458e76050..ecd03ade1a6 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -99,7 +99,8 @@ class Contracts extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contract objects * - * @throws RestException + * @throws RestException 404 Not found + * @throws RestException 503 Error */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 17a153a2dc4..58bd029f8de 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -225,7 +225,6 @@ class Contrat extends CommonObject 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'date_contrat' =>array('type'=>'datetime', 'label'=>'Date contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed')), 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>70), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>75), 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk commercial signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), @@ -239,6 +238,7 @@ class Contrat extends CommonObject 'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'Ref customer', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>140), + 'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed')) ); // END MODULEBUILDER PROPERTIES @@ -517,7 +517,7 @@ class Contrat extends CommonObject { $num = $this->ref; } - $this->newref = $num; + $this->newref = dol_sanitizeFileName($num); if ($num) { @@ -2785,7 +2785,7 @@ class ContratLigne extends CommonObjectLine elseif ($status == self::STATUS_CLOSED) { $labelStatus = $langs->trans("ServiceStatusClosed"); $labelStatusShort = $langs->trans("ServiceStatusClosed"); } $statusType = 'status'.$status; - if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status3'; + if ($status == self::STATUS_OPEN && $expired == 1) $statusType = 'status1'; if ($status == self::STATUS_CLOSED) $statusType = 'status6'; $params = array(); $reg = array(); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index aae50630eb7..cb350c61b51 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -57,7 +57,7 @@ $result = restrictedArea($user, 'contrat', $id); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index 6dd6fc56e17..3c306453c00 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -39,7 +39,7 @@ $langs->loadLangs(array('products', 'companies', 'contracts')); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $statut = GETPOST('statut') ?GETPOST('statut') : 1; @@ -109,7 +109,7 @@ $dataseries = array(); $vals = array(); // Search by status (except expired) -$sql = "SELECT count(cd.rowid), cd.statut"; +$sql = "SELECT count(cd.rowid) as nb, cd.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -126,16 +126,16 @@ if ($resql) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) + $obj = $db->fetch_object($resql); + if ($obj) { - $nb[$row[1]] = $row[0]; - if ($row[1] != 5) + $nb[$obj->status] = $obj->nb; + if ($obj->status != 5) { - $vals[$row[1]] = $row[0]; - $totalinprocess += $row[0]; + $vals[$obj->status] = $obj->nb; + $totalinprocess += $obj->nb; } - $total += $row[0]; + $total += $obj->nb; } $i++; } @@ -146,7 +146,7 @@ else dol_print_error($db); } // Search by status (only expired) -$sql = "SELECT count(cd.rowid), cd.statut"; +$sql = "SELECT count(cd.rowid) as nb, cd.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= ", ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."contrat as c"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -165,16 +165,16 @@ if ($resql) $i = 0; while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) + $obj = $db->fetch_object($resql); + if ($obj) { - $nb[$row[1].true] = $row[0]; - if ($row[1] != 5) + $nb[$obj->status.true] = $obj->nb; + if ($obj->status != 5) { - $vals[$row[1]] = $row[0]; - $totalinprocess += $row[0]; + $vals[$obj->status.true] = $obj->nb; + $totalinprocess += $obj->nb; } - $total += $row[0]; + $total += $obj->nb; } $i++; } @@ -185,6 +185,10 @@ else dol_print_error($db); } +$colorseries = array(); + +include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + print '
    '; print '
    '.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_paiement."".$labeltype.' '.$objp->num_payment."
    '.$langs->trans("BankAccount").''; - $form->select_comptes($_POST["accountid"], "accountid", 0, "courant=1", 1); // Affiche liste des comptes courant + $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available print '
    '; print ''."\n"; @@ -192,6 +196,11 @@ $listofstatus = array(0, 4, 4, 5); $bool = false; foreach ($listofstatus as $status) { $dataseries[] = array($staticcontratligne->LibStatut($status, 1, ($bool ? 1 : 0)), (isset($nb[$status.$bool]) ? (int) $nb[$status.$bool] : 0)); + if ($status == ContratLigne::STATUS_INITIAL) $colorseries[$status.$bool] = '-'.$badgeStatus0; + if ($status == ContratLigne::STATUS_OPEN && !$bool) $colorseries[$status.$bool] = $badgeStatus4; + if ($status == ContratLigne::STATUS_OPEN && $bool) $colorseries[$status.$bool] = $badgeStatus1; + if ($status == ContratLigne::STATUS_CLOSED) $colorseries[$status.$bool] = $badgeStatus6; + if (empty($conf->use_javascript_ajax)) { print ''; @@ -209,10 +218,11 @@ if (!empty($conf->use_javascript_ajax)) include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $dolgraph = new DolGraph(); $dolgraph->SetData($dataseries); - $dolgraph->setShowLegend(1); + $dolgraph->SetDataColor(array_values($colorseries)); + $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); $dolgraph->SetType(array('pie')); - $dolgraph->setWidth('100%'); + $dolgraph->setHeight('200'); $dolgraph->draw('idgraphstatus'); print $dolgraph->show($total ? 0 : 1); @@ -363,10 +373,10 @@ if ($result) print ''; print ''; //print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print "\n"; $i++; } diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 328507f6722..09dfe2692b8 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -74,7 +74,7 @@ $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -705,9 +705,7 @@ while ($i < min($num, $limit)) $nbofsalesrepresentative = count($listsalesrepresentatives); if ($nbofsalesrepresentative > 3) { // We print only number - print ''; print $nbofsalesrepresentative; - print ''; } elseif ($nbofsalesrepresentative > 0) { @@ -741,7 +739,7 @@ while ($i < min($num, $limit)) // Date if (!empty($arrayfields['c.date_contrat']['checked'])) { - print ''; + print ''; } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index 952a286d773..c8a6c321b6e 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -38,7 +38,7 @@ $langs->loadLangs(array('products', 'contracts', 'companies')); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ebc8e48d742..447c3c5e92f 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -128,6 +128,13 @@ if ($action == 'update' && !empty($permissiontoadd)) if ($object->fields[$key]['type'] == 'duration') { if (!GETPOSTISSET($key.'hour') || !GETPOSTISSET($key.'min')) continue; // The field was not submited to be edited } + elseif ($object->fields[$key]['type'] == 'boolean') { + if (!GETPOSTISSET($key)) { + $object->$key = 0; // use 0 instead null if the field is defined as not null + continue; + } + } + else { if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited } diff --git a/htdocs/core/actions_dellink.inc.php b/htdocs/core/actions_dellink.inc.php index 9fca4502dcf..ca5f05f5f4d 100644 --- a/htdocs/core/actions_dellink.inc.php +++ b/htdocs/core/actions_dellink.inc.php @@ -32,9 +32,9 @@ $addlinkid = GETPOST('idtolinkto', 'int'); // Link invoice to order if ($action == 'addlink' && ! empty($permissiondellink) && ! GETPOST('cancel', 'alpha') && $id > 0 && $addlinkid > 0) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid); + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked(GETPOST('addlink', 'alpha'), $addlinkid); } // Delete link diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index abd82a18351..bb5a7516fb2 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -23,18 +23,18 @@ * \brief Code for actions on extrafields admin pages */ -$maxsizestring=255; -$maxsizeint=10; -$mesg=array(); +$maxsizestring = 255; +$maxsizeint = 10; +$mesg = array(); -$extrasize=GETPOST('size', 'intcomma'); -$type=GETPOST('type', 'alpha'); -$param=GETPOST('param', 'alpha'); +$extrasize = GETPOST('size', 'intcomma'); +$type = GETPOST('type', 'alpha'); +$param = GETPOST('param', 'alpha'); -if ($type=='double' && strpos($extrasize, ',')===false) $extrasize='24,8'; -if ($type=='date') $extrasize=''; -if ($type=='datetime') $extrasize=''; -if ($type=='select') $extrasize=''; +if ($type == 'double' && strpos($extrasize, ',') === false) $extrasize = '24,8'; +if ($type == 'date') $extrasize = ''; +if ($type == 'datetime') $extrasize = ''; +if ($type == 'select') $extrasize = ''; // Add attribute @@ -43,83 +43,83 @@ if ($action == 'add') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'create'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'create'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'create'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'create'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'create'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'create'; } - if ($type=='link' && !$param) + if ($type == 'link' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForLinkType"); + $mesg[] = $langs->trans("ErrorNoValueForLinkType"); $action = 'create'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'create'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } @@ -127,14 +127,14 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'create'; } } } } - if (! $error) + if (!$error) { // attrname must be alphabetical and lower case only if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/", $_POST['attrname']) && !is_numeric($_POST["attrname"])) @@ -144,8 +144,8 @@ if ($action == 'add') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -153,38 +153,38 @@ if ($action == 'add') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->addExtraField( + $result = $extrafields->addExtraField( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, GETPOST('pos', 'int'), $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $default_value, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile', 'alpha'), 1, - (GETPOST('totalizable', 'alpha')?1:0), - (GETPOST('printable', 'alpha')?1:0) + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') ); if ($result > 0) { @@ -195,7 +195,7 @@ if ($action == 'add') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -203,7 +203,7 @@ if ($action == 'add') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); $action = 'create'; } @@ -221,76 +221,76 @@ if ($action == 'update') if ($_POST["button"] != $langs->trans("Cancel")) { // Check values - if (! $type) + if (!$type) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); $action = 'edit'; } - if ($type=='varchar' && $extrasize <= 0) + if ($type == 'varchar' && $extrasize <= 0) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); + $mesg[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Size")); $action = 'edit'; } - if ($type=='varchar' && $extrasize > $maxsizestring) + if ($type == 'varchar' && $extrasize > $maxsizestring) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); + $mesg[] = $langs->trans("ErrorSizeTooLongForVarcharType", $maxsizestring); $action = 'edit'; } - if ($type=='int' && $extrasize > $maxsizeint) + if ($type == 'int' && $extrasize > $maxsizeint) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); + $mesg[] = $langs->trans("ErrorSizeTooLongForIntType", $maxsizeint); $action = 'edit'; } - if ($type=='select' && !$param) + if ($type == 'select' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectType"); $action = 'edit'; } - if ($type=='sellist' && !$param) + if ($type == 'sellist' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForSelectListType"); + $mesg[] = $langs->trans("ErrorNoValueForSelectListType"); $action = 'edit'; } - if ($type=='checkbox' && !$param) + if ($type == 'checkbox' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForCheckBoxType"); + $mesg[] = $langs->trans("ErrorNoValueForCheckBoxType"); $action = 'edit'; } - if ($type=='radio' && !$param) + if ($type == 'radio' && !$param) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorNoValueForRadioType"); + $mesg[] = $langs->trans("ErrorNoValueForRadioType"); $action = 'edit'; } - if ((($type=='radio') || ($type=='checkbox')) && $param) + if ((($type == 'radio') || ($type == 'checkbox')) && $param) { // Construct array for parameter (value of select list) $parameters = $param; $parameters_array = explode("\r\n", $parameters); - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { if (!empty($param_ligne)) { if (preg_match_all('/,/', $param_ligne, $matches)) { - if (count($matches[0])>1) { + if (count($matches[0]) > 1) { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } @@ -298,14 +298,14 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg[]=$langs->trans("ErrorBadFormatValueList", $param_ligne); + $mesg[] = $langs->trans("ErrorBadFormatValueList", $param_ligne); $action = 'edit'; } } } } - if (! $error) + if (!$error) { if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_POST['attrname'])) { @@ -314,8 +314,8 @@ if ($action == 'update') $parameters = $param; $parameters_array = explode("\r\n", $parameters); //In sellist we have only one line and it can have come to do SQL expression - if ($type=='sellist') { - foreach($parameters_array as $param_ligne) + if ($type == 'sellist') { + foreach ($parameters_array as $param_ligne) { $params['options'] = array($parameters=>null); } @@ -323,38 +323,38 @@ if ($action == 'update') else { //Esle it's separated key/value and coma list - foreach($parameters_array as $param_ligne) + foreach ($parameters_array as $param_ligne) { - list($key,$value) = explode(',', $param_ligne); + list($key, $value) = explode(',', $param_ligne); $params['options'][$key] = $value; } } // Visibility: -1=not visible by default in list, 1=visible, 0=hidden $visibility = GETPOST('list', 'alpha'); - if ($type == 'separate') $visibility=3; + if ($type == 'separate') $visibility = 3; - $result=$extrafields->update( + $result = $extrafields->update( GETPOST('attrname', 'alpha'), GETPOST('label', 'alpha'), $type, $extrasize, $elementtype, - (GETPOST('unique', 'alpha')?1:0), - (GETPOST('required', 'alpha')?1:0), + (GETPOST('unique', 'alpha') ? 1 : 0), + (GETPOST('required', 'alpha') ? 1 : 0), $pos, $params, - (GETPOST('alwayseditable', 'alpha')?1:0), - (GETPOST('perms', 'alpha')?GETPOST('perms', 'alpha'):''), + (GETPOST('alwayseditable', 'alpha') ? 1 : 0), + (GETPOST('perms', 'alpha') ?GETPOST('perms', 'alpha') : ''), $visibility, GETPOST('help', 'alpha'), GETPOST('default_value', 'alpha'), GETPOST('computed_value', 'alpha'), - (GETPOST('entitycurrentorall', 'alpha')?0:''), + (GETPOST('entitycurrentorall', 'alpha') ? 0 : ''), GETPOST('langfile'), 1, - (GETPOST('totalizable', 'alpha')?1:0), - (GETPOST('printable', 'alpha')?1:0) + (GETPOST('totalizable', 'alpha') ? 1 : 0), + GETPOST('printable', 'alpha') ); if ($result > 0) { @@ -365,7 +365,7 @@ if ($action == 'update') else { $error++; - $mesg=$extrafields->error; + $mesg = $extrafields->error; setEventMessages($mesg, null, 'errors'); } } @@ -373,7 +373,7 @@ if ($action == 'update') { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); setEventMessages($mesg, null, 'errors'); } } @@ -387,20 +387,20 @@ if ($action == 'update') // Delete attribute if ($action == 'delete') { - if(isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) + if (isset($_GET["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/", $_GET["attrname"])) { - $result=$extrafields->delete($_GET["attrname"], $elementtype); + $result = $extrafields->delete($_GET["attrname"], $elementtype); if ($result >= 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } - else $mesg=$extrafields->error; + else $mesg = $extrafields->error; } else { $error++; $langs->load("errors"); - $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); + $mesg = $langs->trans("ErrorFieldCanNotContainSpecialCharacters", $langs->transnoentities("AttributeCode")); } } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4a00412f800..419296b7341 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -691,11 +691,11 @@ if ($massaction == 'confirm_createbills') // Create bills from orders for ($i = 0; $i < $num; $i++) { - $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); + $desc = ($lines[$i]->desc ? $lines[$i]->desc : ''); // If we build one invoice for several order, we must put the invoice of order on the line if (!empty($createbills_onebythird)) { - $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day', $langs)); + $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } if ($lines[$i]->subprice < 0) @@ -744,7 +744,7 @@ if ($massaction == 'confirm_createbills') // Create bills from orders // Extrafields if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && method_exists($lines[$i], 'fetch_optionals')) { - $lines[$i]->fetch_optionals($lines[$i]->rowid); + $lines[$i]->fetch_optionals(); $array_options = $lines[$i]->array_options; } @@ -1215,6 +1215,8 @@ if (!$error && $massaction == 'closed' && $objectclass == "Propal" && $permissio $db->rollback(); } } + + // Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before) if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permissiontodelete) { diff --git a/htdocs/core/actions_printing.inc.php b/htdocs/core/actions_printing.inc.php index fc0f25a1297..0671e998684 100644 --- a/htdocs/core/actions_printing.inc.php +++ b/htdocs/core/actions_printing.inc.php @@ -29,63 +29,63 @@ // Print file if ($action == 'print_file' && $user->rights->printing->read) { - $langs->load("printing"); - require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; - $objectprint = new PrintingDriver($db); - $list = $objectprint->listDrivers($db, 10); - if (! empty($list)) { - $errorprint=0; - $printerfound=0; - foreach ($list as $driver) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; - $langs->load($driver); - $classname = 'printing_'.$driver; - $printer = new $classname($db); - //print '
    '.print_r($printer, true).'
    '; + $langs->load("printing"); + require_once DOL_DOCUMENT_ROOT . '/core/modules/printing/modules_printing.php'; + $objectprint = new PrintingDriver($db); + $list = $objectprint->listDrivers($db, 10); + if (! empty($list)) { + $errorprint=0; + $printerfound=0; + foreach ($list as $driver) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/printing/'.$driver.'.modules.php'; + $langs->load($driver); + $classname = 'printing_'.$driver; + $printer = new $classname($db); + //print '
    '.print_r($printer, true).'
    '; - if (! empty($conf->global->{$printer->active})) - { - $printerfound++; + if (! empty($conf->global->{$printer->active})) + { + $printerfound++; - $subdir=''; - $module = GETPOST('printer', 'alpha'); - switch ($module ) - { - case 'livraison' : - $subdir = 'receipt'; - $module = 'expedition'; - break; - case 'expedition' : - $subdir = 'sending'; - break; - case 'commande_fournisseur' : - $module = 'fournisseur'; - $subdir = 'commande'; - break; - } - try { - $ret = $printer->printFile(GETPOST('file', 'alpha'), $module, $subdir); - if ($ret > 0) { - //print '
    '.print_r($printer->errors, true).'
    '; - setEventMessages($printer->error, $printer->errors, 'errors'); - } - if ($ret==0) - { - //print '
    '.print_r($printer->errors, true).'
    '; - setEventMessages($printer->error, $printer->errors); - setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); - } - } - catch(Exception $e) - { - $ret = 1; - setEventMessages($e->getMessage(), null, 'errors'); - } - } - } - if ($printerfound==0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); - } else { - setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); - } - $action = ''; + $subdir=''; + $module = GETPOST('printer', 'alpha'); + switch ($module ) + { + case 'livraison' : + $subdir = 'receipt'; + $module = 'expedition'; + break; + case 'expedition' : + $subdir = 'sending'; + break; + case 'commande_fournisseur' : + $module = 'fournisseur'; + $subdir = 'commande'; + break; + } + try { + $ret = $printer->printFile(GETPOST('file', 'alpha'), $module, $subdir); + if ($ret > 0) { + //print '
    '.print_r($printer->errors, true).'
    '; + setEventMessages($printer->error, $printer->errors, 'errors'); + } + if ($ret==0) + { + //print '
    '.print_r($printer->errors, true).'
    '; + setEventMessages($printer->error, $printer->errors); + setEventMessages($langs->transnoentitiesnoconv("FileWasSentToPrinter", basename(GETPOST('file', 'alpha'))).' '.$langs->transnoentitiesnoconv("ViaModule").' '.$printer->name, null); + } + } + catch(Exception $e) + { + $ret = 1; + setEventMessages($e->getMessage(), null, 'errors'); + } + } + } + if ($printerfound==0) setEventMessages($langs->trans("NoActivePrintingModuleFound", $langs->transnoentities("Module64000Name")), null, 'warnings'); + } else { + setEventMessages($langs->trans("NoModuleFound"), null, 'warnings'); + } + $action = ''; } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index 425204e00a4..8c8f23f9b0e 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -60,8 +60,8 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel } } } elseif ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel', 'alpha')) { - // Set public note - if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); + // Set public note + if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('', 'Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private', 'none'), ENT_QUOTES), '_private'); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index e5aa9cbe4bb..a9a7df300c3 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -48,7 +48,7 @@ if (!isset($mode) || $mode != 'noajax') // For ajax call $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); - $page = GETPOST("page", 'int'); + $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/core/ajax/bankconciliate.php b/htdocs/core/ajax/bankconciliate.php index 690ebc80f85..f3e6c379392 100644 --- a/htdocs/core/ajax/bankconciliate.php +++ b/htdocs/core/ajax/bankconciliate.php @@ -51,46 +51,46 @@ if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $ { // Increase date $al = new AccountLine($db); - $al->datev_next(GETPOST('rowid', 'int')); - $al->fetch(GETPOST('rowid', 'int')); + $al->datev_next(GETPOST('rowid', 'int')); + $al->fetch(GETPOST('rowid', 'int')); - print ''.dol_print_date($db->jdate($al->datev), "day").''; + print ''.dol_print_date($db->jdate($al->datev), "day").''; - exit; + exit; } if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'dvprev') { // Decrease date $al =new AccountLine($db); - $al->datev_previous(GETPOST('rowid', 'int')); - $al->fetch(GETPOST('rowid', 'int')); + $al->datev_previous(GETPOST('rowid', 'int')); + $al->fetch(GETPOST('rowid', 'int')); - print ''.dol_print_date($db->jdate($al->datev), "day").''; + print ''.dol_print_date($db->jdate($al->datev), "day").''; - exit; + exit; } if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'donext') { // Increase date $al = new AccountLine($db); - $al->dateo_next(GETPOST('rowid', 'int')); - $al->fetch(GETPOST('rowid', 'int')); + $al->dateo_next(GETPOST('rowid', 'int')); + $al->fetch(GETPOST('rowid', 'int')); - print ''.dol_print_date($db->jdate($al->dateo), "day").''; + print ''.dol_print_date($db->jdate($al->dateo), "day").''; - exit; + exit; } if (($user->rights->banque->modifier || $user->rights->banque->consolidate) && $action == 'doprev') { // Decrease date $al =new AccountLine($db); - $al->dateo_previous(GETPOST('rowid', 'int')); - $al->fetch(GETPOST('rowid', 'int')); + $al->dateo_previous(GETPOST('rowid', 'int')); + $al->fetch(GETPOST('rowid', 'int')); - print ''.dol_print_date($db->jdate($al->dateo), "day").''; + print ''.dol_print_date($db->jdate($al->dateo), "day").''; - exit; + exit; } diff --git a/htdocs/core/ajax/fileupload.php b/htdocs/core/ajax/fileupload.php index 5a3b18da55e..4e2252cee56 100644 --- a/htdocs/core/ajax/fileupload.php +++ b/htdocs/core/ajax/fileupload.php @@ -53,23 +53,23 @@ header('Access-Control-Allow-Headers: X-File-Name, X-File-Type, X-File-Size'); switch ($_SERVER['REQUEST_METHOD']) { case 'OPTIONS': break; - case 'HEAD': - case 'GET': - $upload_handler->get(); - break; - case 'POST': - if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { - $upload_handler->delete(); - } else { - $upload_handler->post(); - } - break; - case 'DELETE': - $upload_handler->delete(); - break; - default: - header('HTTP/1.0 405 Method Not Allowed'); - exit; + case 'HEAD': + case 'GET': + $upload_handler->get(); + break; + case 'POST': + if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { + $upload_handler->delete(); + } else { + $upload_handler->post(); + } + break; + case 'DELETE': + $upload_handler->delete(); + break; + default: + header('HTTP/1.0 405 Method Not Allowed'); + exit; } $db->close(); diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index 0d662b6a0bd..e1a5c451ba5 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -68,4 +68,4 @@ else // Registering new values if (($action == 'set') && ! empty($id)) - $object->setValueFrom($field, $value, $element, $id); + $object->setValueFrom($field, $value, $element, $id); diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index 1cbede80339..39c2bf7b07f 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -44,8 +44,8 @@ if (isset($_GET['action']) && ! empty($_GET['action'])) { if ($_GET['action'] == 'getrandompassword' && $user->admin) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; - $generic = $_GET['generic'] ? true : false; + require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; + $generic = $_GET['generic'] ? true : false; echo getRandomPassword($generic); } } diff --git a/htdocs/core/ajax/ziptown.php b/htdocs/core/ajax/ziptown.php index df9f70da1df..72eb73f84e0 100644 --- a/htdocs/core/ajax/ziptown.php +++ b/htdocs/core/ajax/ziptown.php @@ -62,36 +62,36 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) if (! empty($conf->global->MAIN_USE_ZIPTOWN_DICTIONNARY)) // Use zip-town table { - $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; - $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; - $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; - $sql.= " ".MAIN_DB_PREFIX."c_country as c"; - $sql.= " WHERE z.fk_pays = c.rowid"; - $sql.= " AND z.active = 1 AND c.active = 1"; - if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; - if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; - $sql.= " ORDER BY z.zip, z.town"; - $sql.= $db->plimit(100); // Avoid pb with bad criteria + $sql = "SELECT z.rowid, z.zip, z.town, z.fk_county, z.fk_pays as fk_country"; + $sql.= ", c.rowid as fk_country, c.code as country_code, c.label as country"; + $sql.= ", d.rowid as fk_county, d.code_departement as county_code, d.nom as county"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as z"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON z.fk_county = d.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r ON d.fk_region = r.code_region,"; + $sql.= " ".MAIN_DB_PREFIX."c_country as c"; + $sql.= " WHERE z.fk_pays = c.rowid"; + $sql.= " AND z.active = 1 AND c.active = 1"; + if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'"; + if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'"; + $sql.= " ORDER BY z.zip, z.town"; + $sql.= $db->plimit(100); // Avoid pb with bad criteria } else // Use table of third parties { - $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; - $sql.= ", c.code as country_code, c.label as country"; - $sql.= ", d.code_departement as county_code , d.nom as county"; - $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; - $sql.= " WHERE"; - if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; - if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; - $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; - $sql.= $db->plimit(100); // Avoid pb with bad criteria + $sql = "SELECT DISTINCT s.zip, s.town, s.fk_departement as fk_county, s.fk_pays as fk_country"; + $sql.= ", c.code as country_code, c.label as country"; + $sql.= ", d.code_departement as county_code , d.nom as county"; + $sql.= " FROM ".MAIN_DB_PREFIX.'societe as s'; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX ."c_departements as d ON s.fk_departement = d.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; + $sql.= " WHERE"; + if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'"; + if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'"; + $sql.= " ORDER BY s.fk_pays, s.zip, s.town"; + $sql.= $db->plimit(100); // Avoid pb with bad criteria } - //print $sql; + //print $sql; $resql=$db->query($sql); //var_dump($db); if ($resql) @@ -103,11 +103,11 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town'])) $row_array['label'] = $row['zip'].' '.$row['town']; $row_array['label'] .= ($county || $country)?' (':''; - $row_array['label'] .= $county; + $row_array['label'] .= $county; $row_array['label'] .= ($county && $country?' - ':''); - $row_array['label'] .= $country; - $row_array['label'] .= ($county || $country)?')':''; - if ($zipcode) + $row_array['label'] .= $country; + $row_array['label'] .= ($county || $country)?')':''; + if ($zipcode) { $row_array['value'] = $row['zip']; $row_array['town'] = $row['town']; diff --git a/htdocs/core/antispamimage.php b/htdocs/core/antispamimage.php index 015f4597d12..38bb261e068 100644 --- a/htdocs/core/antispamimage.php +++ b/htdocs/core/antispamimage.php @@ -43,7 +43,7 @@ $number = strlen($letters); $string = ''; for($i = 0; $i < $length; $i++) { - $string .= $letters{mt_rand(0, $number - 1)}; + $string .= $letters{mt_rand(0, $number - 1)}; } //print $string; @@ -54,8 +54,8 @@ $_SESSION[$sessionkey]=$string; $img = imagecreate(80, 32); if (empty($img)) { - dol_print_error('', "Problem with GD creation"); - exit; + dol_print_error('', "Problem with GD creation"); + exit; } // Define mime type diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index 8f27ff739e0..44102f0aab1 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -86,7 +86,7 @@ class box_boms extends ModeleBoxes if ($user->rights->bom->read) { - $sql = "SELECT p.ref as product_ref"; + $sql = "SELECT p.ref as product_ref, p.tobuy, p.tosell"; $sql.= ", c.rowid"; $sql.= ", c.date_creation"; $sql.= ", c.tms"; @@ -109,11 +109,15 @@ class box_boms extends ModeleBoxes while ($line < $num) { $objp = $this->db->fetch_object($result); $datem=$this->db->jdate($objp->tms); + $bomstatic->id = $objp->rowid; $bomstatic->ref = $objp->ref; $bomstatic->id = $objp->socid; $bomstatic->status = $objp->status; + $productstatic->ref = $objp->product_ref; + $productstatic->status = $objp->tobuy; + $productstatic->status_buy = $objp->tosell; $this->info_box_contents[$line][] = array( 'td' => 'class="nowraponall"', diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index c8a050ea1d4..10b9c52acb0 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -72,6 +72,7 @@ class box_commandes extends ModeleBoxes public function loadBox($max = 5) { global $user, $langs, $conf; + $langs->load('orders'); $this->max = $max; diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 6c0a20bc6db..e78b6e235b1 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -160,6 +160,7 @@ class box_graph_invoices_permonth extends ModeleBoxes } $i++; } + $px1->SetLegend($legend); $px1->SetMaxValue($px1->GetCeilMaxValue()); $px1->SetWidth($WIDTH); diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index c61bc2569be..e8337d74303 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -75,6 +75,7 @@ class box_graph_product_distribution extends ModeleBoxes global $conf, $user, $langs; $this->max = $max; + $dir = $conf->user->dir_temp; $refreshaction = 'refresh_'.$this->boxcode; @@ -145,7 +146,8 @@ class box_graph_product_distribution extends ModeleBoxes $showpointvalue = 1; $nocolor = 0; $mode = 'customer'; $stats_invoice = new FactureStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); - $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); + $data1 = $stats_invoice->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); + if (empty($data1)) { $showpointvalue = 0; @@ -159,11 +161,12 @@ class box_graph_product_distribution extends ModeleBoxes $mesg = $px1->isGraphKo(); if (!$mesg) { - $i = 0; $tot = count($data1); $legend = array(); - while ($i <= $tot) + $i = 0; $legend = array(); + + foreach ($data1 as $key => $val) { - $data1[$i][0] = dol_trunc($data1[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[] = $data1[$i][0]; + $data1[$key][0] = dol_trunc($data1[$key][0], 32); + $legend[] = $data1[$key][0]; $i++; } @@ -172,11 +175,11 @@ class box_graph_product_distribution extends ModeleBoxes if ($nocolor) $px1->SetDataColor(array(array(220, 220, 220))); $px1->SetLegend($legend); - $px1->setShowLegend(0); + $px1->setShowLegend(2); $px1->setShowPointValue($showpointvalue); $px1->setShowPercent(0); $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetWidth($WIDTH); + //$px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); //$px1->SetYLabel($langs->trans("NumberOfBills")); $px1->SetShading(3); @@ -202,7 +205,7 @@ class box_graph_product_distribution extends ModeleBoxes $showpointvalue = 1; $nocolor = 0; $stats_proposal = new PropaleStats($this->db, $socid, ($userid > 0 ? $userid : 0)); - $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); + $data2 = $stats_proposal->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); if (empty($data2)) { $showpointvalue = 0; @@ -217,11 +220,12 @@ class box_graph_product_distribution extends ModeleBoxes $mesg = $px2->isGraphKo(); if (!$mesg) { - $i = 0; $tot = count($data2); $legend = array(); - while ($i <= $tot) + $i = 0; $legend = array(); + + foreach ($data2 as $key => $val) { - $data2[$i][0] = dol_trunc($data2[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[] = $data2[$i][0]; + $data2[$key][0] = dol_trunc($data2[$key][0], 32); + $legend[] = $data2[$key][0]; $i++; } @@ -230,11 +234,11 @@ class box_graph_product_distribution extends ModeleBoxes if ($nocolor) $px2->SetDataColor(array(array(220, 220, 220))); $px2->SetLegend($legend); - $px2->setShowLegend(0); + $px2->setShowLegend(2); $px2->setShowPointValue($showpointvalue); $px2->setShowPercent(0); $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetWidth($WIDTH); + //$px2->SetWidth($WIDTH); $px2->SetHeight($HEIGHT); //$px2->SetYLabel($langs->trans("AmountOfBillsHT")); $px2->SetShading(3); @@ -261,7 +265,7 @@ class box_graph_product_distribution extends ModeleBoxes $showpointvalue = 1; $nocolor = 0; $mode = 'customer'; $stats_order = new CommandeStats($this->db, $socid, $mode, ($userid > 0 ? $userid : 0)); - $data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24))); + $data3 = $stats_order->getAllByProductEntry($year, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), 5); if (empty($data3)) { $showpointvalue = 0; @@ -276,11 +280,12 @@ class box_graph_product_distribution extends ModeleBoxes $mesg = $px3->isGraphKo(); if (!$mesg) { - $i = 0; $tot = count($data3); $legend = array(); - while ($i <= $tot) + $i = 0; $legend = array(); + + foreach ($data3 as $key => $val) { - $data3[$i][0] = dol_trunc($data3[$i][0], 5); // Required to avoid error "Could not draw pie with labels contained inside canvas" - $legend[] = $data3[$i][0]; + $data3[$key][0] = dol_trunc($data3[$key][0], 32); + $legend[] = $data3[$key][0]; $i++; } @@ -289,11 +294,11 @@ class box_graph_product_distribution extends ModeleBoxes if ($nocolor) $px3->SetDataColor(array(array(220, 220, 220))); $px3->SetLegend($legend); - $px3->setShowLegend(0); + $px3->setShowLegend(2); $px3->setShowPointValue($showpointvalue); $px3->setShowPercent(0); $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetWidth($WIDTH); + //$px3->SetWidth($WIDTH); $px3->SetHeight($HEIGHT); //$px3->SetYLabel($langs->trans("AmountOfBillsHT")); $px3->SetShading(3); diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index dbb26408b6f..5b40fc61436 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -91,7 +91,7 @@ class box_services_contracts extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity, p.tobuy, p.tosell"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -165,6 +165,9 @@ class box_services_contracts extends ModeleBoxes $productstatic->ref=$objp->product_ref; $productstatic->entity=$objp->pentity; $productstatic->label=$objp->plabel; + $productstatic->status = $objp->tosell; + $productstatic->status_buy = $objp->tobuy; + $text = $productstatic->getNomUrl(1, '', 20); if ($objp->plabel) { diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index 3b07b5bbd68..26f45bc08db 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -77,6 +77,7 @@ class box_shipments extends ModeleBoxes $this->max = $max; include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; $shipmentstatic = new Expedition($this->db); diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index ed267493e97..94983ef6bff 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -127,15 +127,17 @@ class box_task extends ModeleBoxes $boxcontent .= ''; $boxcontent .= ''."\n"; $boxcontent .= ''."\n"; - $boxcontent .= ''; - // set cookie by js - $boxcontent .= ''; + '; + // set cookie by js + $boxcontent .= ''; + } $this->info_box_contents[0][] = array( 'tr'=>'class="nohover showiffilter'.$this->boxcode.' hideobject"', 'td' => 'class="nohover"', diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index a02f00fbac9..7c1713b9453 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -47,6 +47,11 @@ class CSMSFile public $message; public $nostop; + public $socid; + public $contactid; + + public $fk_project; + /** * CSMSFile @@ -125,7 +130,12 @@ class CSMSFile $sms->class=$this->class; $sms->nostop=$this->nostop; + $sms->socid=$this->socid; + $sms->contactid=$this->contactid; + $sms->project=$this->fk_project; + $res=$sms->SmsSend(); + if ($res <= 0) { $this->error=$sms->error; @@ -155,7 +165,12 @@ class CSMSFile $sms->message=$this->message; $sms->nostop=$this->nostop; + $sms->socid=$this->socid; + $sms->contactid=$this->contactid; + $sms->fk_project=$this->fk_project; + $res=$sms->SmsSend(); + $this->error = $sms->error; $this->errors = $sms->errors; if ($res <= 0) diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index cfdb09c527e..80c6ff1b7a6 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -36,7 +36,7 @@ class Canvas /** * @var string Error code (or message) */ - public $error=''; + public $error = ''; /** * @var string[] Error codes (or messages) @@ -45,13 +45,13 @@ class Canvas public $actiontype; - public $dirmodule; // Module directory - public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) - public $canvas; // Name of canvas (ex: company, individual, product, service, ...) - public $card; // Tab (sub-canvas) + public $dirmodule; // Module directory + public $targetmodule; // Module concerned by canvas (ex: thirdparty, contact, ...) + public $canvas; // Name of canvas (ex: company, individual, product, service, ...) + public $card; // Tab (sub-canvas) - public $template_dir; // Initialized by getCanvas with templates directory - public $control; // Initialized by getCanvas with controller instance + public $template_dir; // Initialized by getCanvas with templates directory + public $control; // Initialized by getCanvas with controller instance /** @@ -76,9 +76,9 @@ class Canvas private function _cleanaction($action) { $newaction = $action; - if ($newaction == 'add') $newaction='create'; - if ($newaction == 'update') $newaction='edit'; - if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction='view'; + if ($newaction == 'add') $newaction = 'create'; + if ($newaction == 'update') $newaction = 'edit'; + if (empty($newaction) || $newaction == 'delete' || $newaction == 'create_user' || $newaction == 'presend' || $newaction == 'send') $newaction = 'view'; return $newaction; } @@ -114,7 +114,7 @@ class Canvas if (file_exists($controlclassfile)) { // Include actions class (controller) - $this->control_file=$controlclassfile; + $this->control_file = $controlclassfile; require_once $controlclassfile; // Instantiate actions class (controller) @@ -124,9 +124,9 @@ class Canvas // Template dir $this->template_dir = dol_buildpath('/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/'); - if (! is_dir($this->template_dir)) + if (!is_dir($this->template_dir)) { - $this->template_dir=''; + $this->template_dir = ''; } //print 'dimodule='.$dirmodule.' canvas='.$this->canvas.'
    '; @@ -158,7 +158,7 @@ class Canvas { if (empty($this->template_dir)) return 0; - if (file_exists($this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php')) return 1; + if (file_exists($this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php')) return 1; else return 0; } @@ -176,7 +176,8 @@ class Canvas global $db, $conf, $langs, $user, $canvas; global $form, $formfile; - include $this->template_dir.(!empty($this->card)?$this->card.'_':'').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template + //var_dump($this->card.'-'.$action); + include $this->template_dir.(!empty($this->card) ? $this->card.'_' : '').$this->_cleanaction($action).'.tpl.php'; // Include native PHP template } diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 1bd051d4b55..bd3dcb01e76 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -221,24 +221,24 @@ abstract class CommonDocGenerator ); // Retrieve extrafields - if(is_array($object->array_options) && count($object->array_options)) + if (is_array($object->array_options) && count($object->array_options)) { require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { $object->array_options['options_'.$key] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_thirdparty = array_merge($array_thirdparty, array ('company_options_'.$key => $object->array_options ['options_' . $key])); + $array_thirdparty = array_merge($array_thirdparty, array('company_options_'.$key => $object->array_options ['options_'.$key])); } } return $array_thirdparty; @@ -258,61 +258,62 @@ abstract class CommonDocGenerator // phpcs:enable global $conf; - if(empty($object->country) && ! empty($object->country_code)) + if (empty($object->country) && !empty($object->country_code)) { - $object->country = $outputlangs->transnoentitiesnoconv("Country" . $object->country_code); + $object->country = $outputlangs->transnoentitiesnoconv("Country".$object->country_code); } - if(empty($object->state) && ! empty($object->state_code)) + if (empty($object->state) && !empty($object->state_code)) { $object->state = getState($object->state_code, 0); } $array_contact = array ( - $array_key . '_fullname' => $object->getFullName($outputlangs, 1), - $array_key . '_lastname' => $object->lastname, - $array_key . '_firstname' => $object->firstname, - $array_key . '_address' => $object->address, - $array_key . '_zip' => $object->zip, - $array_key . '_town' => $object->town, - $array_key . '_state_id' => $object->state_id, - $array_key . '_state_code' => $object->state_code, - $array_key . '_state' => $object->state, - $array_key . '_country_id' => $object->country_id, - $array_key . '_country_code' => $object->country_code, - $array_key . '_country' => $object->country, - $array_key . '_poste' => $object->poste, - $array_key . '_socid' => $object->socid, - $array_key . '_statut' => $object->statut, - $array_key . '_code' => $object->code, - $array_key . '_email' => $object->email, - $array_key . '_jabberid' => $object->jabberid, - $array_key . '_phone_pro' => $object->phone_pro, - $array_key . '_phone_perso' => $object->phone_perso, - $array_key . '_phone_mobile' => $object->phone_mobile, - $array_key . '_fax' => $object->fax, - $array_key . '_birthday' => $object->birthday, - $array_key . '_default_lang' => $object->default_lang, - $array_key . '_note_public' => $object->note_public, - $array_key . '_note_private' => $object->note_private + $array_key . '_fullname' => $object->getFullName($outputlangs, 1), + $array_key . '_lastname' => $object->lastname, + $array_key . '_firstname' => $object->firstname, + $array_key . '_address' => $object->address, + $array_key . '_zip' => $object->zip, + $array_key . '_town' => $object->town, + $array_key . '_state_id' => $object->state_id, + $array_key . '_state_code' => $object->state_code, + $array_key . '_state' => $object->state, + $array_key . '_country_id' => $object->country_id, + $array_key . '_country_code' => $object->country_code, + $array_key . '_country' => $object->country, + $array_key . '_poste' => $object->poste, + $array_key . '_socid' => $object->socid, + $array_key . '_statut' => $object->statut, + $array_key . '_code' => $object->code, + $array_key . '_email' => $object->email, + $array_key . '_jabberid' => $object->jabberid, // deprecated + $array_key . '_phone_pro' => $object->phone_pro, + $array_key . '_phone_perso' => $object->phone_perso, + $array_key . '_phone_mobile' => $object->phone_mobile, + $array_key . '_fax' => $object->fax, + $array_key . '_birthday' => $object->birthday, + $array_key . '_default_lang' => $object->default_lang, + $array_key . '_note_public' => $object->note_public, + $array_key . '_note_private' => $object->note_private, + $array_key . '_civility' => $object->civility, ); // Retrieve extrafields - require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($object->table_element, true); $object->fetch_optionals(); - foreach($extrafields->attributes[$object->table_element]['label'] as $key => $label) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') { - $object->array_options['options_' . $key] = price($object->array_options ['options_' . $key], 0, $outputlangs, 0, 0, - 1, $conf->currency); + $object->array_options['options_'.$key] = price($object->array_options ['options_'.$key], 0, $outputlangs, 0, 0, - 1, $conf->currency); } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'select' || $extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $object->array_options['options_' . $key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_' . $key]]; + $object->array_options['options_'.$key] = $extrafields->attributes[$object->table_element]['param'][$key]['options'][$object->array_options['options_'.$key]]; } - $array_contact = array_merge($array_contact, array($array_key.'_options_' . $key => $object->array_options['options_'. $key])); + $array_contact = array_merge($array_contact, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); } return $array_contact; } @@ -478,20 +479,20 @@ abstract class CommonDocGenerator } // Add vat by rates - if (is_array($object->lines) && count($object->lines)>0) + if (is_array($object->lines) && count($object->lines) > 0) { $totalUp = 0; foreach ($object->lines as $line) { // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility - if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx]=0; - $resarray[$array_key.'_total_vat_'.$line->tva_tx]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx]=price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); + if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; + $resarray[$array_key.'_total_vat_'.$line->tva_tx] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$line->tva_tx] = price($resarray[$array_key.'_total_vat_'.$line->tva_tx]); // $vatformated is vat without not expected chars (so 20, or 8.5 or 5.99 for example) - $vatformated=vatrate($line->tva_tx); - if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; - $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; - $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); + $vatformated = vatrate($line->tva_tx); + if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated] = 0; + $resarray[$array_key.'_total_vat_'.$vatformated] += $line->total_tva; + $resarray[$array_key.'_total_vat_locale_'.$vatformated] = price($resarray[$array_key.'_total_vat_'.$vatformated]); $totalUp += $line->subprice * $line->qty; } @@ -536,14 +537,16 @@ abstract class CommonDocGenerator * * @param Object $line Object line * @param Translate $outputlangs Lang object to use for output + * @param int $linenumber The number of the line for the substitution of "object_line_pos" * @return array Return a substitution array */ - public function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs, $linenumber = 0) { // phpcs:enable global $conf; $resarray = array( + 'line_pos' => $linenumber, 'line_fulldesc'=>doc_getlinedesc($line, $outputlangs), 'line_product_ref'=>$line->product_ref, 'line_product_ref_fourn'=>$line->ref_fourn, // for supplier doc lines @@ -566,12 +569,12 @@ abstract class CommonDocGenerator 'line_price_ttc_locale'=>price($line->total_ttc, 0, $outputlangs), 'line_price_vat_locale'=>price($line->total_tva, 0, $outputlangs), // Dates - 'line_date_start'=>dol_print_date($line->date_start, 'day', 'tzuser'), - 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzuser', $outputlangs), - 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc', 'tzuser'), - 'line_date_end'=>dol_print_date($line->date_end, 'day', 'tzuser'), - 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzuser', $outputlangs), - 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc', 'tzuser'), + 'line_date_start'=>dol_print_date($line->date_start, 'day'), + 'line_date_start_locale'=>dol_print_date($line->date_start, 'day', 'tzserver', $outputlangs), + 'line_date_start_rfc'=>dol_print_date($line->date_start, 'dayrfc'), + 'line_date_end'=>dol_print_date($line->date_end, 'day'), + 'line_date_end_locale'=>dol_print_date($line->date_end, 'day', 'tzserver', $outputlangs), + 'line_date_end_rfc'=>dol_print_date($line->date_end, 'dayrfc'), 'line_multicurrency_code' => price2num($line->multicurrency_code), 'line_multicurrency_subprice' => price2num($line->multicurrency_subprice), @@ -587,13 +590,13 @@ abstract class CommonDocGenerator // Units if ($conf->global->PRODUCT_USE_UNITS) { - $resarray['line_unit']=$outputlangs->trans($line->getLabelOfUnit('long')); - $resarray['line_unit_short']=$outputlangs->trans($line->getLabelOfUnit('short')); + $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); + $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } // Retrieve extrafields - $extrafieldkey=$line->element; - $array_key="line"; + $extrafieldkey = $line->element; + $array_key = "line"; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label($extrafieldkey, true); @@ -606,22 +609,33 @@ abstract class CommonDocGenerator { // Add the product supplier extrafields to the substitutions $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels=$extrafields->attributes["product_fournisseur_price"]['label']; - $columns = ""; - foreach ($extralabels as $key => $value) - $columns .= "$key, "; + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; - if ($columns != "") - { - $columns = substr($columns, 0, strlen($columns) - 2); - $resql = $this->db->query("SELECT $columns FROM " . MAIN_DB_PREFIX . "product_fournisseur_price_extrafields AS ex INNER JOIN " . MAIN_DB_PREFIX . "product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '" . $line->ref_supplier . "'"); - if ($this->db->num_rows($resql) > 0) { - $resql = $this->db->fetch_object($resql); + if (!empty($extralabels) && is_array($extralabels)) + { + $columns = ""; - foreach ($extralabels as $key => $value) - $resarray['line_product_supplier_'.$key] = $resql->{$key}; - } - } + foreach ($extralabels as $key) + { + $columns .= "$key, "; + } + + if ($columns != "") + { + $columns = substr($columns, 0, strlen($columns) - 2); + $resql = $this->db->query("SELECT $columns FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields AS ex INNER JOIN ".MAIN_DB_PREFIX."product_fournisseur_price AS f ON ex.fk_object = f.rowid WHERE f.ref_fourn = '".$line->ref_supplier."'"); + + if ($this->db->num_rows($resql) > 0) + { + $resql = $this->db->fetch_object($resql); + + foreach ($extralabels as $key) + { + $resarray['line_product_supplier_'.$key] = $resql->{$key}; + } + } + } + } } // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" @@ -724,14 +738,14 @@ abstract class CommonDocGenerator 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, - 'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''), + 'line_discount_percent'=>($line->remise_percent ? $line->remise_percent.'%' : ''), 'line_price_ht'=>price($line->total_ht), 'line_price_ttc'=>price($line->total_ttc), 'line_price_vat'=>price($line->total_tva), - 'line_weight'=>empty($line->weight) ? '' : $line->weight*$line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), - 'line_length'=>empty($line->length) ? '' : $line->length*$line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), - 'line_surface'=>empty($line->surface) ? '' : $line->surface*$line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), - 'line_volume'=>empty($line->volume) ? '' : $line->volume*$line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), + 'line_weight'=>empty($line->weight) ? '' : $line->weight * $line->qty_shipped.' '.measuringUnitString(0, 'weight', $line->weight_units), + 'line_length'=>empty($line->length) ? '' : $line->length * $line->qty_shipped.' '.measuringUnitString(0, 'size', $line->length_units), + 'line_surface'=>empty($line->surface) ? '' : $line->surface * $line->qty_shipped.' '.measuringUnitString(0, 'surface', $line->surface_units), + 'line_volume'=>empty($line->volume) ? '' : $line->volume * $line->qty_shipped.' '.measuringUnitString(0, 'volume', $line->volume_units), ); // Retrieve extrafields @@ -792,81 +806,84 @@ abstract class CommonDocGenerator { // phpcs:enable global $conf; - foreach($extrafields->attributes[$object->table_element]['label'] as $key=>$label) - { - if($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + + if (is_array($extrafields->attributes[$object->table_element]['label'])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key=>$label) { - $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); - $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); - //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]]; - } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { - $valArray=explode(',', $object->array_options['options_'.$key]); - $output=array(); - foreach($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { - if (in_array($keyopt, $valArray)) { - $output[]=$valopt; + if ($extrafields->attributes[$object->table_element]['type'][$key] == 'price') + { + $object->array_options['options_'.$key] = price2num($object->array_options['options_'.$key]); + $object->array_options['options_'.$key.'_currency'] = price($object->array_options['options_'.$key], 0, $outputlangs, 0, 0, -1, $conf->currency); + //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]]; + } + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'checkbox') { + $valArray = explode(',', $object->array_options['options_'.$key]); + $output = array(); + foreach ($extrafields->attributes[$object->table_element]['param'][$key]['options'] as $keyopt=>$valopt) { + if (in_array($keyopt, $valArray)) { + $output[] = $valopt; + } } + $object->array_options['options_'.$key] = implode(', ', $output); } - $object->array_options['options_'.$key] = implode(', ', $output); - } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'date') - { - if (strlen($object->array_options['options_'.$key])>0) + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'date') { - $date = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language - $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format - $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format - } - else - { - $object->array_options['options_'.$key] = ''; - $object->array_options['options_'.$key.'_locale'] = ''; - $object->array_options['options_'.$key.'_rfc'] = ''; - } - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); - } - elseif($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') - { - $datetime = $object->array_options['options_'.$key]; - $object->array_options['options_'.$key] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour'):''); // using company output language - $object->array_options['options_'.$key.'_locale'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs):''); // using output language format - $object->array_options['options_'.$key.'_rfc'] = ($datetime!="0000-00-00 00:00:00"?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc'):''); // international format - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); - $array_to_fill=array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); - } - elseif($extrafields->attributes[$object->table_element]['type'][$key] == 'link') - { - $id = $object->array_options['options_'.$key]; - if ($id != "") - { - $param = $extrafields->attributes[$object->table_element]['param'][$key]; - $param_list=array_keys($param['options']); // $param_list='ObjectName:classPath' - $InfoFieldList = explode(":", $param_list[0]); - $classname=$InfoFieldList[0]; - $classpath=$InfoFieldList[1]; - if (! empty($classpath)) + if (strlen($object->array_options['options_'.$key]) > 0) { - dol_include_once($InfoFieldList[1]); - if ($classname && class_exists($classname)) + $date = $object->array_options['options_'.$key]; + $object->array_options['options_'.$key] = dol_print_date($date, 'day'); // using company output language + $object->array_options['options_'.$key.'_locale'] = dol_print_date($date, 'day', 'tzserver', $outputlangs); // using output language format + $object->array_options['options_'.$key.'_rfc'] = dol_print_date($date, 'dayrfc'); // international format + } + else + { + $object->array_options['options_'.$key] = ''; + $object->array_options['options_'.$key.'_locale'] = ''; + $object->array_options['options_'.$key.'_rfc'] = ''; + } + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + } + elseif ($extrafields->attributes[$object->table_element]['label'][$key] == 'datetime') + { + $datetime = $object->array_options['options_'.$key]; + $object->array_options['options_'.$key] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour') : ''); // using company output language + $object->array_options['options_'.$key.'_locale'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhour', 'tzserver', $outputlangs) : ''); // using output language format + $object->array_options['options_'.$key.'_rfc'] = ($datetime != "0000-00-00 00:00:00" ?dol_print_date($object->array_options['options_'.$key], 'dayhourrfc') : ''); // international format + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_locale' => $object->array_options['options_'.$key.'_locale'])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key.'_rfc' => $object->array_options['options_'.$key.'_rfc'])); + } + elseif ($extrafields->attributes[$object->table_element]['type'][$key] == 'link') + { + $id = $object->array_options['options_'.$key]; + if ($id != "") + { + $param = $extrafields->attributes[$object->table_element]['param'][$key]; + $param_list = array_keys($param['options']); // $param_list='ObjectName:classPath' + $InfoFieldList = explode(":", $param_list[0]); + $classname = $InfoFieldList[0]; + $classpath = $InfoFieldList[1]; + if (!empty($classpath)) { - $tmpobject = new $classname($this->db); - $tmpobject->fetch($id); - // completely replace the id with the linked object name - $object->array_options['options_'.$key] = $tmpobject->name; + dol_include_once($InfoFieldList[1]); + if ($classname && class_exists($classname)) + { + $tmpobject = new $classname($this->db); + $tmpobject->fetch($id); + // completely replace the id with the linked object name + $object->array_options['options_'.$key] = $tmpobject->name; + } } } } - } - $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + $array_to_fill = array_merge($array_to_fill, array($array_key.'_options_'.$key => $object->array_options['options_'.$key])); + } } return $array_to_fill; @@ -932,27 +949,27 @@ abstract class CommonDocGenerator uasort($this->cols, array($this, 'columnSort')); // Positionning - $curX = $this->page_largeur-$this->marge_droite; // start from right + $curX = $this->page_largeur - $this->marge_droite; // start from right // Array width - $arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche; + $arrayWidth = $this->page_largeur - $this->marge_droite - $this->marge_gauche; // Count flexible column $totalDefinedColWidth = 0; $countFlexCol = 0; foreach ($this->cols as $colKey =>& $colDef) { - if(!$this->getColumnStatus($colKey)) continue; // continue if disabled + if (!$this->getColumnStatus($colKey)) continue; // continue if disabled - if(!empty($colDef['scale'])){ + if (!empty($colDef['scale'])) { // In case of column width is defined by percentage $colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100); } - if(empty($colDef['width'])){ + if (empty($colDef['width'])) { $countFlexCol++; } - else{ + else { $totalDefinedColWidth += $colDef['width']; } } @@ -1074,7 +1091,7 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param PDF $pdf pdf object + * @param TCPDF $pdf pdf object * @param float $curY curent Y position * @param string $colKey the column key * @param string $columnText column text @@ -1094,9 +1111,59 @@ abstract class CommonDocGenerator if (!$reshook) { if (empty($columnText)) return; - $pdf->SetXY($this->getColumnContentXStart($colKey) - 1, $curY); // Set curent position + $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; - $pdf->writeHTMLCell($this->getColumnContentWidth($colKey) + 2, 2, $this->getColumnContentXStart($colKey) - 1, $curY, $columnText, 0, 0, 0, true, $colDef['content']['align']); + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + $pdf->writeHTMLCell($colDef['width'], 2, $colDef['xStartPos'], $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); + } + } + + + /** + * print description column content + * + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param object $object CommonObject + * @param int $i the $object->lines array key + * @param Translate $outputlangs Output language + * @param int $hideref hide ref + * @param int $hidedesc hide desc + * @param int $issupplierline if object need supplier product + * @return null + */ + public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) + { + // load desc col params + $colDef = $this->cols[$colKey]; + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + + // line description + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $colDef['width'], 3, $colDef['xStartPos'], $curY, $hideref, $hidedesc, $issupplierline); + $posYAfterDescription = $pdf->GetY() - $colDef['content']['padding'][0]; + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if (!empty($extrafieldDesc)) { + $this->printStdColumnContent($pdf, $posYAfterDescription, $colKey, $extrafieldDesc); } } @@ -1112,13 +1179,13 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ return; } + if (empty($object->table_element)) { return; } $extrafieldsKeyPrefix = "options_"; // Cleanup extrafield key to remove prefix if present $pos = strpos($extrafieldKey, $extrafieldsKeyPrefix); - if($pos===0){ + if ($pos === 0) { $extrafieldKey = substr($extrafieldKey, strlen($extrafieldsKeyPrefix)); } @@ -1126,14 +1193,14 @@ abstract class CommonDocGenerator // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); // TODO : allow showOutputField to be pdf public friendly, ex: in a link to object, clean getNomUrl to remove link and images... like a getName methode ... - if($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link'){ + if ($extrafields->attributes[$object->table_element]['type'][$extrafieldKey] == 'link') { // for lack of anything better we cleanup all html tags $extrafieldOutputContent = dol_string_nohtmltag($extrafieldOutputContent); } @@ -1167,18 +1234,20 @@ abstract class CommonDocGenerator { global $hookmanager; - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; $defaultParams = array( 'style' => '', 'display' => 'auto', // auto, table, list + 'printableEnable' => array(1), + 'printableEnableNotEmpty' => array(2), 'table' => array( 'maxItemsInRow' => 2, @@ -1213,9 +1282,20 @@ abstract class CommonDocGenerator foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Enable extrafield ? - $enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]); + $enabled = 0; + $disableOnEmpty = 0; + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); + if (in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty'])) { + $enabled = 1; + } - if(empty($enabled)){ + if (in_array($printable, $params['printableEnableNotEmpty'])) { + $disableOnEmpty = 1; + } + } + + if (empty($enabled)) { continue; } @@ -1225,45 +1305,49 @@ abstract class CommonDocGenerator $field->label = $outputlangs->transnoentities($label); $field->type = $extrafields->attributes[$object->table_element]['type'][$key]; + // dont display if empty + if ($disableOnEmpty && empty($field->content)) { + continue; + } + $fields[] = $field; } } - if(!empty($fields)) + if (!empty($fields)) { // Sort extrafields by rank uasort($fields, function ($a, $b) { return ($a->rank > $b->rank) ? -1 : 1; - } - ); - - + }); // define some HTML content with style - $html.= ''; + $html .= !empty($params['style']) ? '' : ''; // auto select display format - if($params['display'] == 'auto') { + if ($params['display'] == 'auto') { $lastNnumbItems = 0; - foreach ($params['auto'] as $display => $numbItems){ - if($lastNnumbItems <= $numbItems && count($fields) > $numbItems){ + foreach ($params['auto'] as $display => $numbItems) { + if ($lastNnumbItems <= $numbItems && count($fields) > $numbItems) { $lastNnumbItems = $numbItems; $params['display'] = $display; } } } - if($params['display'] == 'list') { + if ($params['display'] == 'list') { // Display in list format + $i = 0; foreach ($fields as $field) { - $html .= !empty($html)?$params['list']['separator']:''; - $html .= '' . $field->label . ' : '; + $html .= !empty($i) ? $params['list']['separator'] : ''; + $html .= ''.$field->label.' : '; $html .= $field->content; + $i++; } } - elseif($params['display'] == 'table') { + elseif ($params['display'] == 'table') { // Display in table format - $html .= '
    '.$langs->trans("Statistics").' - '.$langs->trans("Services").'
    '.dol_print_date($db->jdate($obj->tms), 'dayhour').''.$staticcontrat->LibStatut($obj->statut,2).''.($obj->nb_initial > 0 ? $obj->nb_initial.$staticcontratligne->LibStatut(0, 3) : '').''.($obj->nb_running > 0 ? $obj->nb_running.$staticcontratligne->LibStatut(4, 3, 0) : '').''.($obj->nb_expired > 0 ? $obj->nb_expired.$staticcontratligne->LibStatut(4, 3, 1) : '').''.($obj->nb_closed > 0 ? $obj->nb_closed.$staticcontratligne->LibStatut(5, 3) : '').''.($obj->nb_initial > 0 ? ''.$obj->nb_initial.''.$staticcontratligne->LibStatut(0, 3, -1, 'class="paddingleft"') : '').''.($obj->nb_running > 0 ? ''.$obj->nb_running.''.$staticcontratligne->LibStatut(4, 3, 0, 'class="marginleft"') : '').''.($obj->nb_expired > 0 ? ''.$obj->nb_expired.''.$staticcontratligne->LibStatut(4, 3, 1, 'class="paddingleft"') : '').''.($obj->nb_closed > 0 ? ''.$obj->nb_closed.''.$staticcontratligne->LibStatut(5, 3, -1, 'class="paddingleft"') : '').'
    '.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzuser').''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').'
    '; + $html .= '
    '; $html .= ""; $itemsInRow = 0; @@ -1290,14 +1374,14 @@ abstract class CommonDocGenerator } $itemsInRow = $maxItemsInRow; - $html .= '"; } else { $itemsInRow++; $html .= '"; @@ -1333,7 +1417,7 @@ abstract class CommonDocGenerator /** * Print standard column content * - * @param PDF $pdf Pdf object + * @param TCPDI $pdf Pdf object * @param float $tab_top Tab top position * @param float $tab_height Default tab height * @param Translate $outputlangs Output language @@ -1369,18 +1453,35 @@ abstract class CommonDocGenerator } if (empty($hidetop)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); - $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; - $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); global $outputlangsbis; if (is_object($outputlangsbis)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] + 4); + // set cell padding with column title definition + $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], 0.5); + } + else { + // set cell padding with column title definition + $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], $colDef['title']['padding'][2]); + } + + $pdf->SetXY($colDef['xStartPos'], $tab_top); + $textWidth = $colDef['width']; + $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); + + + if (is_object($outputlangsbis)) { + $pdf->setCellPaddings($colDef['title']['padding'][3], 0, $colDef['title']['padding'][1], $colDef['title']['padding'][2]); + $pdf->SetXY($colDef['xStartPos'], $pdf->GetY()); $textbis = $outputlangsbis->transnoentities($colDef['title']['textkey']); $pdf->MultiCell($textWidth, 2, $textbis, '', $colDef['title']['align']); } - $this->tabTitleHeight = max($pdf->GetY() - $tab_top + $colDef['title']['padding'][2], $this->tabTitleHeight); + $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight); + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } } @@ -1401,17 +1502,17 @@ abstract class CommonDocGenerator { global $conf; - if(!empty($hidedetails)){ + if (!empty($hidedetails)) { return; } - if(empty($object->table_element)){ + if (empty($object->table_element)) { return; } // Load extrafiels if not allready does - if(empty($this->extrafieldsCache)){ $this->extrafieldsCache = new ExtraFields($this->db); } - if(empty($this->extrafieldsCache->attributes[$object->table_element])){ $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } + if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } + if (empty($this->extrafieldsCache->attributes[$object->table_element])) { $this->extrafieldsCache->fetch_name_optionals_label($object->table_element); } $extrafields = $this->extrafieldsCache; @@ -1425,8 +1526,16 @@ abstract class CommonDocGenerator } // Enable extrafield ? - $enabled = !empty($extrafields->attributes[$object->table_element]['printable'][$key]); + $enabled = 0; + if (!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { + $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); + if ($printable === 1 || $printable === 2) { + $enabled = 1; + } + // Note : if $printable === 3 or 4 so, it's displayed after line description not in cols + } + if (!$enabled) { continue; } // don't wast resourses if we don't need them... // Load language if required if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); @@ -1448,12 +1557,12 @@ abstract class CommonDocGenerator ); $alignTypeRight = array('double', 'int', 'price'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)){ + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeRight)) { $def['content']['align'] = 'R'; } - $alignTypeLeft = array('text', 'html'); - if(in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)){ + $alignTypeLeft = array('text', 'html'); + if (in_array($extrafields->attributes[$object->table_element]['type'][$key], $alignTypeLeft)) { $def['content']['align'] = 'L'; } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index c231a36402d..1c09d2ed48e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -95,7 +95,7 @@ abstract class CommonInvoice extends CommonObject * This does not include open direct debit requests. * * @param int $multicurrency Return multicurrency_amount instead of amount - * @return double Remain of amount to pay + * @return double Remain of amount to pay */ public function getRemainToPay($multicurrency = 0) { @@ -104,7 +104,7 @@ abstract class CommonInvoice extends CommonObject $alreadypaid+=$this->getSumDepositsUsed($multicurrency); $alreadypaid+=$this->getSumCreditNotesUsed($multicurrency); - $remaintopay = ($this->total_ttc - $alreadypaid); + $remaintopay = price2num($this->total_ttc - $alreadypaid, 'MT'); if ($this->statut == self::STATUS_CLOSED && $this->close_code == 'discount_vat') { // If invoice closed with discount for anticipated payment $remaintopay = 0; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 80e9f4c8ab4..e3e072f34a8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -87,6 +87,11 @@ abstract class CommonObject */ public $array_options = array(); + /** + * @var mixed Array to store alternative languages values of object + */ + public $array_languages = null; // Value is array() when load already tried + /** * @var int[][] Array of linked objects ids. Loaded by ->fetchObjectLinked */ @@ -2949,7 +2954,7 @@ abstract class CommonObject $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_ORDER"; elseif ($this->element == 'facture' || $this->element == 'invoice') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_INVOICE"; - elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice') + elseif ($this->element == 'facture_fourn' || $this->element == 'supplier_invoice' || $this->element == 'invoice_supplier') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_INVOICE"; elseif ($this->element == 'order_supplier' || $this->element == 'supplier_order') $MODULE = "MODULE_DISALLOW_UPDATE_PRICE_SUPPLIER_ORDER"; @@ -3369,6 +3374,9 @@ abstract class CommonObject elseif ($objecttype == 'subscription') { $classpath = 'adherents/class'; $module = 'adherent'; } + elseif ($objecttype == 'contact') { + $module = 'societe'; + } // Set classfile $classfile = strtolower($subelement); $classname = ucfirst($subelement); @@ -3391,6 +3399,9 @@ abstract class CommonObject elseif ($objecttype == 'subscription') { $classfile = 'subscription'; $classname = 'Subscription'; } + elseif ($objecttype == 'project' || $objecttype == 'projet') { + $classpath = 'projet/class'; $classfile = 'project'; $classname = 'Project'; + } // Here $module, $classfile and $classname are set if ($conf->$module->enabled && (($element != $this->element) || $alsosametype)) @@ -4077,6 +4088,7 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer + // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook 'formAddObjectLine'. $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach ($dirtpls as $module => $reldir) { @@ -4119,7 +4131,7 @@ abstract class CommonObject */ public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/core/tpl') { - global $conf, $hookmanager, $langs, $user, $object, $form, $extrafields; + global $conf, $hookmanager, $langs, $user, $form, $extrafields, $object; // TODO We should not use global var for this global $inputalsopricewithtax, $usemargins, $disableedit, $disablemove, $disableremove, $outputalsopricetotalwithtax; @@ -4143,6 +4155,7 @@ abstract class CommonObject { // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer + // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook. $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach ($dirtpls as $module => $reldir) { @@ -4209,7 +4222,7 @@ abstract class CommonObject * @param string $buyer Object of buyer third party * @param int $selected Object line selected * @param Extrafields $extrafields Object of extrafields - * @param string $defaulttpldir Directory where to find the template + * @param string $defaulttpldir Directory where to find the template (deprecated) * @return void */ public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl') @@ -4222,15 +4235,9 @@ abstract class CommonObject $element = $this->element; - $text = ''; $description = ''; $type = 0; + $text = ''; $description = ''; - // Show product and description - $type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type); - // Try to enhance type detection using date_start and date_end for free lines where type was not saved. - if (!empty($line->date_start)) $type = 1; // deprecated - if (!empty($line->date_end)) $type = 1; // deprecated - - // Ligne en mode visu + // Line in view mode if ($action != 'editline' || $selected != $line->id) { // Product @@ -4281,6 +4288,7 @@ abstract class CommonObject // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer + // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine. $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach ($dirtpls as $module => $reldir) { @@ -4306,12 +4314,12 @@ abstract class CommonObject if ($this->statut == 0 && $action == 'editline' && $selected == $line->id) { $label = (!empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : '')); - $placeholder = ' placeholder="'.$langs->trans("Label").'"'; $line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU'); // Output template part (modules that overwrite templates must declare this into descriptor) // Use global variables + $dateSelector + $seller and $buyer + // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine. $dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir)); foreach ($dirtpls as $module => $reldir) { @@ -5038,6 +5046,163 @@ abstract class CommonObject } + /* Functions for data in other language */ + + + /** + * Function to get alternative languages of a data into $this->array_languages + * This method is NOT called by method fetch of objects but must be called separately. + * + * @return int <0 if error, 0 if no values of alternative languages to find nor found, 1 if a value was found and loaded + */ + public function fetchValueForAlternateLanguages() + { + // To avoid SQL errors. Probably not the better solution though + if (!$this->element) { + return 0; + } + if (! ($this->id > 0)) { + return 0; + } + if (is_array($this->array_languages)) { + return 1; + } + + $this->array_languages = array(); + + $element = $this->element; + if ($element == 'categorie') $element = 'categories'; // For compatibility + + // Request to get translation values for object + $sql = "SELECT rowid, property, lang , value"; + $sql .= " FROM ".MAIN_DB_PREFIX."object_lang"; + $sql .= " WHERE type_object = '".$element."'"; + $sql .= " AND fk_object = ".$this->id; + + //dol_syslog(get_class($this)."::fetch_optionals get extrafields data for ".$this->table_element, LOG_DEBUG); // Too verbose + $resql = $this->db->query($sql); + if ($resql) + { + $numrows = $this->db->num_rows($resql); + if ($numrows) + { + $i = 0; + while ($i < $numrows) { + $obj = $this->db->fetch_object($resql); + $key = $obj->property; + $value = $obj->value; + $codelang = $obj->lang; + $type = $this->fields[$key]['type']; + + // we can add this attribute to object + if (preg_match('/date/', $type)) + { + $this->array_languages[$key][$codelang] = $this->db->jdate($value); + } + else + { + $this->array_languages[$key][$codelang] = $value; + } + + $i++; + } + } + + $this->db->free($resql); + + if ($numrows) return $numrows; + else return 0; + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Fill array_options property of object by extrafields value (using for data sent by forms) + * + * @param string $onlykey Only the following key is filled. When we make update of only one language field ($action = 'update_languages'), calling page must set this to avoid to have other languages being reset. + * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example) + */ + public function setValuesForAlternateLanguages($onlykey = '') + { + global $_POST, $langs; + + // Get extra fields + foreach($_POST as $postfieldkey => $postfieldvalue) { + $tmparray = explode('-', $postfieldkey); + if ($tmparray[0] != 'field') continue; + + $element = $tmparray[1]; + $key = $tmparray[2]; + $codelang = $tmparray[3]; + //var_dump("postfieldkey=".$postfieldkey." element=".$element." key=".$key." codelang=".$codelang); + + if (!empty($onlykey) && $key != $onlykey) continue; + if ($element != $this->element) continue; + + $key_type = $this->fields[$key]['type']; + + $enabled = 1; + if (isset($this->fields[$key]['enabled'])) + { + $enabled = dol_eval($this->fields[$key]['enabled'], 1); + } + /*$perms = 1; + if (isset($this->fields[$key]['perms'])) + { + $perms = dol_eval($this->fields[$key]['perms'], 1); + }*/ + if (empty($enabled)) continue; + //if (empty($perms)) continue; + + if (in_array($key_type, array('date'))) + { + // Clean parameters + // TODO GMT date in memory must be GMT so we should add gm=true in parameters + $value_key = dol_mktime(0, 0, 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]); + } + elseif (in_array($key_type, array('datetime'))) + { + // Clean parameters + // TODO GMT date in memory must be GMT so we should add gm=true in parameters + $value_key = dol_mktime($_POST[$postfieldkey."hour"], $_POST[$postfieldkey."min"], 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]); + } + elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) + { + $value_arr = GETPOST($postfieldkey, 'array'); // check if an array + if (!empty($value_arr)) { + $value_key = implode($value_arr, ','); + } else { + $value_key = ''; + } + } + elseif (in_array($key_type, array('price', 'double'))) + { + $value_arr = GETPOST($postfieldkey, 'alpha'); + $value_key = price2num($value_arr); + } + else + { + $value_key = GETPOST($postfieldkey); + if (in_array($key_type, array('link')) && $value_key == '-1') $value_key = ''; + } + + $this->array_languages[$key][$codelang] = $value_key; + + /*if ($nofillrequired) { + $langs->load('errors'); + setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors'); + return -1; + }*/ + } + + return 1; + } + + /* Functions for extrafields */ @@ -5056,6 +5221,7 @@ abstract class CommonObject global $extrafields; if (empty($rowid)) $rowid = $this->id; + if (empty($rowid)) $rowid = $this->rowid; // To avoid SQL errors. Probably not the better solution though if (!$this->table_element) { @@ -5107,7 +5273,6 @@ abstract class CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->array_options = array(); $numrows = $this->db->num_rows($resql); if ($numrows) { @@ -5414,7 +5579,7 @@ abstract class CommonObject // Add field of attribute if ($extrafields->attributes[$this->table_element]['type'][$attributeKey] != 'separate') // Only for other type than separator) { - if ($new_array_options[$key] != '') + if ($new_array_options[$key] != '' || $new_array_options[$key] == '0') { $sql .= ",'".$this->db->escape($new_array_options[$key])."'"; } @@ -5516,7 +5681,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } - elseif ($value == '') + elseif ($value === '') { $this->array_options["options_".$key] = null; } @@ -5529,7 +5694,7 @@ abstract class CommonObject $this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel); return -1; } - elseif ($value == '') + elseif ($value === '') { $this->array_options["options_".$key] = null; } @@ -6676,9 +6841,10 @@ abstract class CommonObject if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list elseif ($mode == 'view' && empty($visibility)) continue; if (empty($perms)) continue; - // Load language if required - if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); + if (!empty($extrafields->attributes[$this->table_element]['langfile'][$key])) { + $langs->load($extrafields->attributes[$this->table_element]['langfile'][$key]); + } $colspan = ''; if (is_array($params) && count($params) > 0) { @@ -6777,8 +6943,8 @@ abstract class CommonObject { $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ?price2num(GETPOST($keyprefix.'options_'.$key.$keysuffix, 'alpha', 3)) : $this->array_options['options_'.$key]; } - $labeltoshow = $langs->trans($label); + $helptoshow = $langs->trans($extrafields->attributes[$this->table_element]['help'][$key]); $out .= ''; diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index 023a2e6dc6d..448d1ffdf8d 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -50,13 +50,13 @@ abstract class CommonObjectLine extends CommonObject public $fk_unit; - /** - * Returns the translation key from units dictionary. - * A langs->trans() must be called on result to get translated value. - * - * @param string $type Label type (long or short) - * @return string|int <0 if ko, label if ok - */ + /** + * Returns the translation key from units dictionary. + * A langs->trans() must be called on result to get translated value. + * + * @param string $type Label type (long or short) + * @return string|int <0 if ko, label if ok + */ public function getLabelOfUnit($type = 'long') { global $langs; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 87204294947..9a804256dac 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -683,6 +683,8 @@ class Conf if (!isset($this->global->MAIN_USE_OLD_TITLE_BUTTON)) $this->global->MAIN_USE_OLD_TITLE_BUTTON = 0; + if (!isset($this->global->MAIN_JS_GRAPH)) $this->global->MAIN_JS_GRAPH = 'chart'; // Use chart.js library + if (empty($this->global->MAIN_MODULE_DOLISTORE_API_SRV)) $this->global->MAIN_MODULE_DOLISTORE_API_SRV = 'https://www.dolistore.com'; if (empty($this->global->MAIN_MODULE_DOLISTORE_API_KEY)) $this->global->MAIN_MODULE_DOLISTORE_API_KEY = 'dolistorecatalogpublickey1234567'; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index ca40910aacd..bf85699a9fe 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -62,6 +62,7 @@ class DiscountAbsolute public $multicurrency_amount_ttc; // Vat rate public $tva_tx; + public $vat_src_code; /** * @var int User ID Id utilisateur qui accorde la remise @@ -133,7 +134,7 @@ class DiscountAbsolute $sql = "SELECT sr.rowid, sr.fk_soc, sr.discount_type,"; $sql.= " sr.fk_user,"; - $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx,"; + $sql.= " sr.amount_ht, sr.amount_tva, sr.amount_ttc, sr.tva_tx, sr.vat_src_code,"; $sql.= " sr.multicurrency_amount_ht, sr.multicurrency_amount_tva, sr.multicurrency_amount_ttc,"; $sql.= " sr.fk_facture_line, sr.fk_facture, sr.fk_facture_source, sr.fk_invoice_supplier_line, sr.fk_invoice_supplier, sr.fk_invoice_supplier_source, sr.description,"; $sql.= " sr.datec,"; @@ -168,6 +169,8 @@ class DiscountAbsolute $this->multicurrency_amount_ttc = $obj->multicurrency_amount_ttc; $this->tva_tx = $obj->tva_tx; + $this->vat_src_code = $obj->vat_src_code; + $this->fk_user = $obj->fk_user; $this->fk_facture_line = $obj->fk_facture_line; $this->fk_facture = $obj->fk_facture; @@ -244,12 +247,12 @@ class DiscountAbsolute // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_remise_except"; $sql .= " (entity, datec, fk_soc, discount_type, fk_user, description,"; - $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx,"; + $sql .= " amount_ht, amount_tva, amount_ttc, tva_tx, vat_src_code,"; $sql .= " multicurrency_amount_ht, multicurrency_amount_tva, multicurrency_amount_ttc,"; $sql .= " fk_facture_source, fk_invoice_supplier_source"; $sql .= ")"; $sql .= " VALUES (".$conf->entity.", '".$this->db->idate($this->datec != '' ? $this->datec : dol_now())."', ".$this->fk_soc.", ".(empty($this->discount_type) ? 0 : intval($this->discount_type)).", ".$userid.", '".$this->db->escape($this->description)."',"; - $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.","; + $sql .= " ".$this->amount_ht.", ".$this->amount_tva.", ".$this->amount_ttc.", ".$this->tva_tx.", '".$this->db->escape($this->vat_src_code)."',"; $sql .= " ".$this->multicurrency_amount_ht.", ".$this->multicurrency_amount_tva.", ".$this->multicurrency_amount_ttc.", "; $sql .= " ".($this->fk_facture_source ? "'".$this->db->escape($this->fk_facture_source)."'" : "null").","; $sql .= " ".($this->fk_invoice_supplier_source ? "'".$this->db->escape($this->fk_invoice_supplier_source)."'" : "null"); @@ -504,15 +507,16 @@ class DiscountAbsolute * @param string $filter Filtre autre * @param int $maxvalue Filter on max value for discount * @param int $discount_type 0 => customer discount, 1 => supplier discount + * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, amount otherwise */ - public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0, $multicurrency = 0) { global $conf; dol_syslog(get_class($this)."::getAvailableDiscounts discount_type=".$discount_type, LOG_DEBUG); - $sql = "SELECT SUM(rc.amount_ttc) as amount"; + $sql = "SELECT SUM(rc.amount_ttc) as amount, SUM(rc.multicurrency_amount_ttc) as multicurrency_amount"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc"; $sql .= " WHERE rc.entity = ".$conf->entity; $sql .= " AND rc.discount_type=".intval($discount_type); @@ -535,6 +539,11 @@ class DiscountAbsolute //print 'zz'.$obj->amount; //$obj = $this->db->fetch_object($resql); //} + if ($multicurrency) + { + return $obj->amount_multicurrency; + } + return $obj->amount; } return -1; @@ -604,14 +613,14 @@ class DiscountAbsolute $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture as f'; $sql .= ' WHERE rc.fk_facture_source=f.rowid AND rc.fk_facture = '.$invoice->id; - $sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess received + $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ', ' . $invoice::TYPE_SITUATION . ')'; // Find discount coming from credit note or excess received } elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc, '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql .= ' WHERE rc.fk_invoice_supplier_source=f.rowid AND rc.fk_invoice_supplier = '.$invoice->id; - $sql .= ' AND (f.type = 2 OR f.type = 0)'; // Find discount coming from credit note or excess paid + $sql .= ' AND f.type IN (' . $invoice::TYPE_STANDARD . ', ' . $invoice::TYPE_CREDIT_NOTE . ')'; // Find discount coming from credit note or excess paid } else { diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index a38c25f7614..de5ef1f2e9f 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -85,44 +85,6 @@ class DolEditor if ($okforextendededitor === 'ace') $this->tool = 'ace'; //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile - // Define content and some properties - if ($this->tool == 'ckeditor') - { - $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. - } - /*if ($this->tool == 'fckeditor') - { - require_once DOL_DOCUMENT_ROOT.'/includes/fckeditor/fckeditor.php'; - - $content = dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. - - $this->editor = new FCKeditor($htmlname); - $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/'; - $this->editor->Value = $content; - $this->editor->Height = $height; - if (!empty($width)) $this->editor->Width = $width; - $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js - $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) - $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; - $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; - - // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. - // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. - // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? - $modulepart = 'fckeditor'; - $this->editor->Config['UserFilesPath'] = '/viewimage.php?modulepart='.$modulepart.'&entity='.$conf->entity.'&file='; - $this->editor->Config['UserFilesAbsolutePath'] = DOL_DATA_ROOT.'/'.$modulepart.'/'; - - $this->editor->Config['LinkBrowser'] = ($uselocalbrowser ? 'true' : 'false'); - $this->editor->Config['ImageBrowser'] = ($uselocalbrowser ? 'true' : 'false'); - - if (file_exists(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js')) - { - $this->editor->Config['CustomConfigurationsPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/fckconfig.js'; - $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; - } - }*/ - // Define some properties if (in_array($this->tool, array('textarea', 'ckeditor', 'ace'))) { @@ -172,7 +134,8 @@ class DolEditor { $found = 1; //$out.= ''; diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 9aa54498edc..d59ab8ce6bc 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -30,10 +30,10 @@ * $dolgraph->SetTitle($langs->transnoentities('MyTitle').'
    '.$langs->transnoentities('MyTitlePercent').'%'); * $dolgraph->SetMaxValue(50); * $dolgraph->SetData($data); - * $dolgraph->setShowLegend(1); + * $dolgraph->setShowLegend(2); * $dolgraph->setShowPercent(1); * $dolgraph->SetType(array('pie')); - * $dolgraph->setWidth('100%'); + * $dolgraph->setHeight('200'); * $dolgraph->draw('idofgraph'); * print $dolgraph->show($total?0:1); */ @@ -92,31 +92,13 @@ class DolGraph /** * Constructor * - * @param string $library 'jflot' (default) or 'artichow' (no more supported) + * @param string $library 'auto' (default) */ - public function __construct($library = 'jflot') + public function __construct($library = 'auto') { global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor; - // To use old feature - if ($library == 'artichow') - { - $this->_library = 'artichow'; - - // Test if module GD present - $modules_list = get_loaded_extensions(); - $isgdinstalled = 0; - foreach ($modules_list as $module) - { - if ($module == 'gd') $isgdinstalled = 1; - } - if (!$isgdinstalled) - { - $this->error = "Error: PHP GD module is not available. It is required to build graphics."; - } - } - $this->bordercolor = array(235, 235, 224); $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220)); $this->bgcolor = array(235, 235, 224); @@ -130,23 +112,14 @@ class DolGraph if (isset($theme_bgcolor)) $this->bgcolor = $theme_bgcolor; } //print 'bgcolor: '.join(',',$this->bgcolor).'
    '; + + $this->_library = $library; + if ($this->_library == 'auto') { + $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ? 'jflot' : $conf->global->MAIN_JS_GRAPH); + } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Set Y precision - * - * @param float $which_prec Precision - * @return boolean - * @deprecated - */ - public function SetPrecisionY($which_prec) - { - // phpcs:enable - return true; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 @@ -287,7 +260,8 @@ class DolGraph /** * Set type * - * @param array $type Array with type for each serie. Example: array('pie'), array('lines',...,'bars') + * @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be: + * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', ... * @return void */ public function SetType($type) @@ -448,7 +422,7 @@ class DolGraph /** * Show legend or not * - * @param int $showlegend 1=Show legend (default), 0=Hide legend + * @param int $showlegend 1=Show legend (default), 0=Hide legend, 2=Show legend on right * @return void */ public function setShowLegend($showlegend) @@ -561,6 +535,8 @@ class DolGraph public function GetMaxValueInData() { // phpcs:enable + if (!is_array($this->data)) return 0; + $k = 0; $vals = array(); @@ -588,6 +564,8 @@ class DolGraph public function GetMinValueInData() { // phpcs:enable + if (!is_array($this->data)) return 0; + $k = 0; $vals = array(); @@ -686,188 +664,6 @@ class DolGraph call_user_func_array(array($this, $call), array($file, $fileurl)); } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Build a graph onto disk using Artichow library and return img string to it - * - * @param string $file Image file name to use if we save onto disk - * @param string $fileurl Url path to show image if saved onto disk - * @return void - */ - private function draw_artichow($file, $fileurl) - { - // phpcs:enable - global $artichow_defaultfont; - - dol_syslog(get_class($this)."::draw_artichow this->type=".join(',', $this->type)); - - if (!defined('SHADOW_RIGHT_TOP')) define('SHADOW_RIGHT_TOP', 3); - if (!defined('LEGEND_BACKGROUND')) define('LEGEND_BACKGROUND', 2); - if (!defined('LEGEND_LINE')) define('LEGEND_LINE', 1); - - // Create graph - $classname = ''; - if (!isset($this->type[0]) || $this->type[0] == 'bars') $classname = 'BarPlot'; // Only one type (first one) is supported by artichow - elseif ($this->type[0] == 'lines' || $this->type[0] == 'linesnopoint') $classname = 'LinePlot'; - else $classname = 'TypeUnknown'; - include_once ARTICHOW_PATH.$classname.'.class.php'; - - // Definition de couleurs - $bgcolor = new Color($this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]); - $bgcolorgrid = new Color($this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]); - $colortrans = new Color(0, 0, 0, 100); - $colorsemitrans = new Color(255, 255, 255, 60); - $colorgradient = new LinearGradient(new Color(235, 235, 235), new Color(255, 255, 255), 0); - $colorwhite = new Color(255, 255, 255); - - // Graph - $graph = new Graph($this->width, $this->height); - $graph->border->hide(); - $graph->setAntiAliasing(true); - if (isset($this->title)) - { - $graph->title->set($this->title); - //print $artichow_defaultfont;exit; - $graph->title->setFont(new $artichow_defaultfont(10)); - } - - if (is_array($this->bgcolor)) $graph->setBackgroundColor($bgcolor); - else $graph->setBackgroundGradient($colorgradient); - - $group = new PlotGroup; - //$group->setSpace(5, 5, 0, 0); - - $paddleft = 50; - $paddright = 10; - $strl = dol_strlen(max(abs($this->MaxValue), abs($this->MinValue))); - if ($strl > 6) $paddleft += ($strl * 4); - $group->setPadding($paddleft, $paddright); // Width on left and right for Y axis values - $group->legend->setSpace(0); - $group->legend->setPadding(2, 2, 2, 2); - $group->legend->setPosition(null, 0.1); - $group->legend->setBackgroundColor($colorsemitrans); - - if (is_array($this->bgcolorgrid)) $group->grid->setBackgroundColor($bgcolorgrid); - else $group->grid->setBackgroundColor($colortrans); - - if ($this->hideXGrid) $group->grid->hideVertical(true); - if ($this->hideYGrid) $group->grid->hideHorizontal(true); - - // On boucle sur chaque lot de donnees - $legends = array(); - $i = 0; - $nblot = count($this->data[0]) - 1; - - while ($i < $nblot) - { - $x = 0; - $values = array(); - foreach ($this->data as $key => $valarray) - { - $legends[$x] = $valarray[0]; - $values[$x] = $valarray[$i + 1]; - $x++; - } - - // We fix unknown values to null - $newvalues = array(); - foreach ($values as $val) - { - $newvalues[] = (is_numeric($val) ? $val : null); - } - - - if ($this->type[0] == 'bars') - { - //print "Lot de donnees $i
    "; - //print_r($values); - //print '
    '; - - $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20); - $colorbis = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 50); - - $colorgrey = new Color(100, 100, 100); - $colorborder = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]); - - if ($this->mode == 'side') $plot = new BarPlot($newvalues, $i + 1, $nblot); - if ($this->mode == 'depth') $plot = new BarPlot($newvalues, 1, 1, ($nblot - $i - 1) * 5); - - $plot->barBorder->setColor($colorgrey); - //$plot->setBarColor($color); - $plot->setBarGradient(new LinearGradient($colorbis, $color, 90)); - - if ($this->mode == 'side') $plot->setBarPadding(0.1, 0.1); - if ($this->mode == 'depth') $plot->setBarPadding(0.1, 0.4); - if ($this->mode == 'side') $plot->setBarSpace(5); - if ($this->mode == 'depth') $plot->setBarSpace(2); - - $plot->barShadow->setSize($this->SetShading); - $plot->barShadow->setPosition(SHADOW_RIGHT_TOP); - $plot->barShadow->setColor(new Color(160, 160, 160, 50)); - $plot->barShadow->smooth(true); - //$plot->setSize(1, 0.96); - //$plot->setCenter(0.5, 0.52); - - // Le mode automatique est plus efficace - $plot->SetYMax($this->MaxValue); - $plot->SetYMin($this->MinValue); - } - - if ($this->type[0] == 'lines' || $this->type[0] == 'linesnopoint') - { - $color = new Color($this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2], 20); - $colorbis = new Color(min($this->datacolor[$i][0] + 20, 255), min($this->datacolor[$i][1] + 20, 255), min($this->datacolor[$i][2] + 20, 255), 60); - $colorter = new Color(min($this->datacolor[$i][0] + 50, 255), min($this->datacolor[$i][1] + 50, 255), min($this->datacolor[$i][2] + 50, 255), 90); - - $plot = new LinePlot($newvalues); - //$plot->setSize(1, 0.96); - //$plot->setCenter(0.5, 0.52); - - $plot->setColor($color); - $plot->setThickness(1); - - // Set line background gradient - $plot->setFillGradient(new LinearGradient($colorter, $colorbis, 90)); - - $plot->xAxis->setLabelText($legends); - - // Le mode automatique est plus efficace - $plot->SetYMax($this->MaxValue); - $plot->SetYMin($this->MinValue); - //$plot->setYAxis(0); - //$plot->hideLine(true); - } - - //$plot->reduce(80); // Evite temps d'affichage trop long et nombre de ticks absisce satures - - $group->legend->setTextFont(new $artichow_defaultfont(10)); // This is to force Artichow to use awFileFontDriver to - // solve a bug in Artichow with UTF8 - if (count($this->Legend)) - { - if ($this->type[0] == 'bars') $group->legend->add($plot, $this->Legend[$i], LEGEND_BACKGROUND); - if ($this->type[0] == 'lines' || $this->type[0] == 'linesnopoint') $group->legend->add($plot, $this->Legend[$i], LEGEND_LINE); - } - $group->add($plot); - - $i++; - } - - $group->axis->bottom->setLabelText($legends); - $group->axis->bottom->label->setFont(new $artichow_defaultfont(7)); - - //print $group->axis->bottom->getLabelNumber(); - if ($this->labelInterval > 0) $group->axis->bottom->setLabelInterval($this->labelInterval); - - $graph->add($group); - - // Generate file - $graph->draw($file); - - $this->stringtoshow = ''.dol_escape_htmltag($this->title ? $this->title : $this->YLabel).''; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a graph using JFlot library. Input when calling this method should be: @@ -875,7 +671,7 @@ class DolGraph * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated * $this->legend= array("Val1",...,"Valn"); // list of n series name - * $this->type = array('bars',...'lines'); or array('pie') + * $this->type = array('bars',...'lines','linesnopoint'); or array('pie') or array('polar') * $this->mode = 'depth' ??? * $this->bgcolorgrid * $this->datacolor @@ -888,7 +684,7 @@ class DolGraph private function draw_jflot($file, $fileurl) { // phpcs:enable - global $langs; + global $conf, $langs; dol_syslog(get_class($this)."::draw_jflot this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); @@ -924,8 +720,7 @@ class DolGraph $x++; } - // TODO Avoid push by adding generated long array... - if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie') + if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { foreach ($values as $x => $y) { if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n"; @@ -943,38 +738,46 @@ class DolGraph } $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); - $this->stringtoshow = ''."\n"; + $this->stringtoshow = ''."\n"; if (!empty($this->title)) $this->stringtoshow .= '
    '.$this->title.'
    '; if (!empty($this->shownographyet)) { $this->stringtoshow .= '
    '; - $this->stringtoshow .= '
    '.$langs->trans("NotEnoughDataYet").'
    '; + $this->stringtoshow .= '
    '.$langs->trans("NotEnoughDataYet").'...
    '; return; } - $this->stringtoshow .= '
    '."\n"; + + // Start the div that will contains all the graph + $dolxaxisvertical = ''; + if (count($this->data) > 20) $dolxaxisvertical = 'dol-xaxis-vertical'; + $this->stringtoshow .= '
    '."\n"; $this->stringtoshow .= ''."\n"; } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Build a graph using Chart library. Input when calling this method should be: + * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); + * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x + * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated + * $this->legend= array("Val1",...,"Valn"); // list of n series name + * $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle'); + * $this->mode = 'depth' ??? + * $this->bgcolorgrid + * $this->datacolor + * $this->shownodatagraph + * + * @param string $file Image file name to use to save onto disk (also used as javascript unique id) + * @param string $fileurl Url path to show image if saved onto disk. Never used here. + * @return void + */ + private function draw_chart($file, $fileurl) + { + // phpcs:enable + global $conf, $langs; + + dol_syslog(get_class($this)."::draw_chart this->type=".join(',', $this->type)." this->MaxValue=".$this->MaxValue); + + if (empty($this->width) && empty($this->height)) + { + print 'Error width or height not set'; + return; + } + + $showlegend = $this->showlegend; + + $legends = array(); + $nblot = 0; + if (is_array($this->data)) { + foreach ($this->data as $valarray) // Loop on each x + { + $nblot = max($nblot, count($valarray) - 1); // -1 to remove legend + } + } + //var_dump($nblot); + if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING); + $firstlot = 0; + // Works with line but not with bars + //if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x + + $serie = array(); $arrayofgroupslegend = array(); + //var_dump($this->data); + + $i = $firstlot; + while ($i < $nblot) // Loop on each serie + { + $values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x (with x=0,1,2,...) + $serie[$i] = ""; + + // Fill array $values + $x = 0; + foreach ($this->data as $valarray) // Loop on each x + { + $legends[$x] = (array_key_exists('label', $valarray) ? $valarray['label'] : $valarray[0]); + $array_of_ykeys = array_keys($valarray); + $alabelexists = 1; + $tmpykey = explode('_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3); + if (!empty($tmpykey[2]) || $tmpykey[2] == '0') { // This is a 'Group by' array + $tmpvalue = (array_key_exists('y_'.$tmpykey[1].'_'.$tmpykey[2], $valarray) ? $valarray['y_'.$tmpykey[1].'_'.$tmpykey[2]] : $valarray[$i + 1]); + $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null); + $arrayofgroupslegend[$i] = array( + 'stacknum'=> $tmpykey[1], + 'legend' => $this->Legend[$tmpykey[1]], + 'legendwithgroup' => $this->Legend[$tmpykey[1]].' - '.$tmpykey[2] + ); + } else { + $tmpvalue = (array_key_exists('y_'.$i, $valarray) ? $valarray['y_'.$i] : $valarray[$i + 1]); + //var_dump($i.'_'.$x.'_'.$tmpvalue); + $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue : null); + } + $x++; + } + //var_dump($values); + $j = 0; + foreach ($values as $x => $y) { + if (isset($y)) { + $serie[$i] .= ($j > 0 ? ", " : "").$y; + } else { + $serie[$i] .= ($j > 0 ? ", " : "").'null'; + } + $j++; + } + + $values = null; // Free mem + $i++; + } + //var_dump($serie); + //var_dump($arrayofgroupslegend); + + $tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.')))); + + $this->stringtoshow = ''."\n"; + if (!empty($this->title)) $this->stringtoshow .= '
    '.$this->title.'
    '; + if (!empty($this->shownographyet)) + { + $this->stringtoshow .= '
    '; + $this->stringtoshow .= '
    '.$langs->trans("NotEnoughDataYet").'...
    '; + return; + } + + // Start the div that will contains all the graph + $dolxaxisvertical=''; + if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical'; + // No height for the pie grah + $cssfordiv = 'dolgraphchart'; + if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar'.$this->type[$firstlot]; + $this->stringtoshow .= '
    '."\n"; + + $this->stringtoshow .= ''."\n"; + } + + /** * Output HTML string to total value * @@ -1155,11 +1313,11 @@ class DolGraph if ($shownographyet) { $s = '
    '; - $s .= '
    '; + $s .= '
    '; if (is_numeric($shownographyet)) { - $s .= $langs->trans("NotEnoughDataYet"); + $s .= $langs->trans("NotEnoughDataYet").'...'; } else { - $s .= $shownographyet; + $s .= $shownographyet.'...'; } $s .= '
    '; return $s; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index d241c2a8c5a..468cdf050bc 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -104,6 +104,7 @@ require_once DOL_DOCUMENT_ROOT.'/includes/mike42/escpos-php/autoload.php'; use Mike42\Escpos\PrintConnectors\FilePrintConnector; use Mike42\Escpos\PrintConnectors\NetworkPrintConnector; use Mike42\Escpos\PrintConnectors\WindowsPrintConnector; +use Mike42\Escpos\PrintConnectors\CupsPrintConnector; use Mike42\Escpos\PrintConnectors\DummyPrintConnector; use Mike42\Escpos\CapabilityProfile; use Mike42\Escpos\Printer; @@ -119,7 +120,7 @@ class dolReceiptPrinter extends Printer const CONNECTOR_FILE_PRINT = 2; const CONNECTOR_NETWORK_PRINT = 3; const CONNECTOR_WINDOWS_PRINT = 4; - //const CONNECTOR_JAVA = 5; + const CONNECTOR_CUPS_PRINT = 5; /** * @var DoliDB Database handler. @@ -262,7 +263,7 @@ class dolReceiptPrinter extends Printer $row['fk_type_name'] = 'CONNECTOR_WINDOWS_PRINT'; break; case 5: - $row['fk_type_name'] = 'CONNECTOR_JAVA'; + $row['fk_type_name'] = 'CONNECTOR_CUPS_PRINT'; break; default: $row['fk_type_name'] = 'CONNECTOR_UNKNOWN'; @@ -343,6 +344,7 @@ class dolReceiptPrinter extends Printer 2 => $langs->trans('CONNECTOR_FILE_PRINT'), 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT'), + 5 => $langs->trans('CONNECTOR_CUPS_PRINT'), ); $this->resprint = Form::selectarray($htmlname, $options, $selected); @@ -839,6 +841,9 @@ class dolReceiptPrinter extends Printer break; case 4: $this->connector = new WindowsPrintConnector($parameter); + break; + case 5: + $this->connector = new CupsPrintConnector($parameter); break; default: $this->connector = 'CONNECTOR_UNKNOWN'; diff --git a/htdocs/core/class/evalmath.class.php b/htdocs/core/class/evalmath.class.php new file mode 100644 index 00000000000..a520ebb3a21 --- /dev/null +++ b/htdocs/core/class/evalmath.class.php @@ -0,0 +1,507 @@ + + * + * ================================================================================ + * + * NAME + * EvalMath - safely evaluate math expressions + * + * SYNOPSIS + * include('evalmath.class.php'); + * $m = new EvalMath; + * // basic evaluation: + * $result = $m->evaluate('2+2'); + * // supports: order of operation; parentheses; negation; built-in functions + * $result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8'); + * // create your own variables + * $m->evaluate('a = e^(ln(pi))'); + * // or functions + * $m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1'); + * // and then use them + * $result = $m->evaluate('3*f(42,a)'); + * + * DESCRIPTION + * Use the EvalMath class when you want to evaluate mathematical expressions + * from untrusted sources. You can define your own variables and functions, + * which are stored in the object. Try it, it's fun! + * + * METHODS + * $m->evalute($expr) + * Evaluates the expression and returns the result. If an error occurs, + * prints a warning and returns false. If $expr is a function assignment, + * returns true on success. + * + * $m->e($expr) + * A synonym for $m->evaluate(). + * + * $m->vars() + * Returns an associative array of all user-defined variables and values. + * + * $m->funcs() + * Returns an array of all user-defined functions. + * + * PARAMETERS + * $m->suppress_errors + * Set to true to turn off warnings when evaluating expressions + * + * $m->last_error + * If the last evaluation failed, contains a string describing the error. + * (Useful when suppress_errors is on). + * + * $m->last_error_code + * If the last evaluation failed, 2 element array with numeric code and extra info + * + * AUTHOR INFORMATION + * Copyright 2005, Miles Kaufmann. + * + * LICENSE + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1 Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * \file core/class/evalmath.class.php + * \ingroup core + * \brief This file for Math evaluation + */ + +/** + * Class EvalMath + */ +class EvalMath +{ + + public $suppress_errors = false; + + public $last_error = null; + + public $last_error_code = null; + + public $v = array('e' => 2.71,'pi' => 3.14159); + + // variables (and constants) + public $f = array(); + + // user-defined functions + public $vb = array('e','pi'); + + // constants + public $fb = array( // built-in functions + 'sin','sinh','arcsin','asin','arcsinh','asinh','cos','cosh','arccos','acos','arccosh','acosh','tan','tanh','arctan','atan','arctanh','atanh','sqrt','abs','ln','log','intval'); + + /** + * Constructor + */ + public function __construct() + { + // make the variables a little more accurate + $this->v['pi'] = pi(); + $this->v['e'] = exp(1); + } + + /** + * Evaluate + * + * @param string $expr String + * @return boolean|number|NULL|mixed Result + */ + public function e($expr) + { + return $this->evaluate($expr); + } + + /** + * Evaluate + * + * @param string $expr String + * @return boolean|number|NULL|mixed Result + */ + public function evaluate($expr) + { + $this->last_error = null; + $this->last_error_code = null; + $expr = trim($expr); + if (substr($expr, - 1, 1) == ';') + $expr = substr($expr, 0, strlen($expr) - 1); // strip semicolons at the end + // =============== + // is it a variable assignment? + $matches = array(); + if (preg_match('/^\s*([a-z]\w*)\s*=\s*(.+)$/', $expr, $matches)) { + if (in_array($matches[1], $this->vb)) { // make sure we're not assigning to a constant + return $this->trigger(1, "cannot assign to constant '$matches[1]'", $matches[1]); + } + if (($tmp = $this->pfx($this->nfx($matches[2]))) === false) + return false; // get the result and make sure it's good + $this->v[$matches[1]] = $tmp; // if so, stick it in the variable array + return $this->v[$matches[1]]; // and return the resulting value + // =============== + // is it a function assignment? + } elseif (preg_match('/^\s*([a-z]\w*)\s*\(\s*([a-z]\w*(?:\s*,\s*[a-z]\w*)*)\s*\)\s*=\s*(.+)$/', $expr, $matches)) { + $fnn = $matches[1]; // get the function name + if (in_array($matches[1], $this->fb)) { // make sure it isn't built in + return $this->trigger(2, "cannot redefine built-in function '$matches[1]()'", $matches[1]); + } + $args = explode(",", preg_replace("/\s+/", "", $matches[2])); // get the arguments + if (($stack = $this->nfx($matches[3])) === false) + return false; // see if it can be converted to postfix + $nbstack = count($stack); + for ($i = 0; $i < $nbstack; $i ++) { // freeze the state of the non-argument variables + $token = $stack[$i]; + if (preg_match('/^[a-z]\w*$/', $token) and ! in_array($token, $args)) { + if (array_key_exists($token, $this->v)) { + $stack[$i] = $this->v[$token]; + } else { + return $this->trigger(3, "undefined variable '$token' in function definition", $token); + } + } + } + $this->f[$fnn] = array('args' => $args,'func' => $stack); + return true; + // =============== + } else { + return $this->pfx($this->nfx($expr)); // straight up evaluation, woo + } + } + + /** + * vars + * + * @return string Output + */ + private function vars() + { + $output = $this->v; + unset($output['pi']); + unset($output['e']); + return $output; + } + + /** + * vars + * + * @return string Output + */ + private function funcs() + { + $output = array(); + foreach ($this->f as $fnn => $dat) + $output[] = $fnn . '(' . implode(',', $dat['args']) . ')'; + return $output; + } + + // ===================== HERE BE INTERNAL METHODS ====================\\ + + /** + * Convert infix to postfix notation + * + * @param string $expr Expression + * @return string Output + */ + private function nfx($expr) + { + $index = 0; + $stack = new EvalMathStack(); + $output = array(); // postfix form of expression, to be passed to pfx() + $expr = trim(strtolower($expr)); + + $ops = array('+','-','*','/','^','_'); + $ops_r = array('+' => 0,'-' => 0,'*' => 0,'/' => 0,'^' => 1); // right-associative operator? + $ops_p = array('+' => 0,'-' => 0,'*' => 1,'/' => 1,'_' => 1,'^' => 2); // operator precedence + + $expecting_op = false; // we use this in syntax-checking the expression + // and determining when a - is a negation + + $matches = array(); + if (preg_match("/[^\w\s+*^\/()\.,-]/", $expr, $matches)) { // make sure the characters are all good + return $this->trigger(4, "illegal character '{$matches[0]}'", $matches[0]); + } + + while (1) { // 1 Infinite Loop ;) + $op = substr($expr, $index, 1); // get the first character at the current index + // find out if we're currently at the beginning of a number/variable/function/parenthesis/operand + $match = array(); + $ex = preg_match('/^([a-z]\w*\(?|\d+(?:\.\d*)?|\.\d+|\()/', substr($expr, $index), $match); + // =============== + if ($op == '-' and ! $expecting_op) { // is it a negation instead of a minus? + $stack->push('_'); // put a negation on the stack + $index ++; + } elseif ($op == '_') { // we have to explicitly deny this, because it's legal on the stack + return $this->trigger(4, "illegal character '_'", "_"); // but not in the input expression + // =============== + } elseif ((in_array($op, $ops) or $ex) and $expecting_op) { // are we putting an operator on the stack? + if ($ex) { // are we expecting an operator but have a number/variable/function/opening parethesis? + $op = '*'; + $index --; // it's an implicit multiplication + } + // heart of the algorithm: + while ($stack->count > 0 and ($o2 = $stack->last()) and in_array($o2, $ops) and ($ops_r[$op] ? $ops_p[$op] < $ops_p[$o2] : $ops_p[$op] <= $ops_p[$o2])) { + $output[] = $stack->pop(); // pop stuff off the stack into the output + } + // many thanks: http://en.wikipedia.org/wiki/Reverse_Polish_notation#The_algorithm_in_detail + $stack->push($op); // finally put OUR operator onto the stack + $index ++; + $expecting_op = false; + // =============== + } elseif ($op == ')' and $expecting_op) { // ready to close a parenthesis? + while (($o2 = $stack->pop()) != '(') { // pop off the stack back to the last ( + if (is_null($o2)) + return $this->trigger(5, "unexpected ')'", ")"); + else + $output[] = $o2; + } + if (preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) { // did we just close a function? + $fnn = $matches[1]; // get the function name + $arg_count = $stack->pop(); // see how many arguments there were (cleverly stored on the stack, thank you) + $output[] = $stack->pop(); // pop the function and push onto the output + if (in_array($fnn, $this->fb)) { // check the argument count + if ($arg_count > 1) + return $this->trigger(6, "wrong number of arguments ($arg_count given, 1 expected)", array($arg_count,1)); + } elseif (array_key_exists($fnn, $this->f)) { + if ($arg_count != count($this->f[$fnn]['args'])) + return $this->trigger(6, "wrong number of arguments ($arg_count given, " . count($this->f[$fnn]['args']) . " expected)", array($arg_count,count($this->f[$fnn]['args']))); + } else { // did we somehow push a non-function on the stack? this should never happen + return $this->trigger(7, "internal error"); + } + } + $index ++; + // =============== + } elseif ($op == ',' and $expecting_op) { // did we just finish a function argument? + while (($o2 = $stack->pop()) != '(') { + if (is_null($o2)) + return $this->trigger(5, "unexpected ','", ","); // oops, never had a ( + else + $output[] = $o2; // pop the argument expression stuff and push onto the output + } + // make sure there was a function + if (! preg_match("/^([a-z]\w*)\($/", $stack->last(2), $matches)) + return $this->trigger(5, "unexpected ','", ","); + $stack->push($stack->pop() + 1); // increment the argument count + $stack->push('('); // put the ( back on, we'll need to pop back to it again + $index ++; + $expecting_op = false; + // =============== + } elseif ($op == '(' and ! $expecting_op) { + $stack->push('('); // that was easy + $index ++; + $allow_neg = true; + // =============== + } elseif ($ex and ! $expecting_op) { // do we now have a function/variable/number? + $expecting_op = true; + $val = $match[1]; + if (preg_match("/^([a-z]\w*)\($/", $val, $matches)) { // may be func, or variable w/ implicit multiplication against parentheses... + if (in_array($matches[1], $this->fb) or array_key_exists($matches[1], $this->f)) { // it's a func + $stack->push($val); + $stack->push(1); + $stack->push('('); + $expecting_op = false; + } else { // it's a var w/ implicit multiplication + $val = $matches[1]; + $output[] = $val; + } + } else { // it's a plain old var or num + $output[] = $val; + } + $index += strlen($val); + // =============== + } elseif ($op == ')') { // miscellaneous error checking + return $this->trigger(5, "unexpected ')'", ")"); + } elseif (in_array($op, $ops) and ! $expecting_op) { + return $this->trigger(8, "unexpected operator '$op'", $op); + } else { // I don't even want to know what you did to get here + return $this->trigger(9, "an unexpected error occured"); + } + if ($index == strlen($expr)) { + if (in_array($op, $ops)) { // did we end with an operator? bad. + return $this->trigger(10, "operator '$op' lacks operand", $op); + } else { + break; + } + } + while (substr($expr, $index, 1) == ' ') { // step the index past whitespace (pretty much turns whitespace + $index ++; // into implicit multiplication if no operator is there) + } + } + while (! is_null($op = $stack->pop())) { // pop everything off the stack and push onto output + if ($op == '(') + return $this->trigger(11, "expecting ')'", ")"); // if there are (s on the stack, ()s were unbalanced + $output[] = $op; + } + return $output; + } + + /** + * evaluate postfix notation + * + * @param string $tokens Expression + * @param array $vars Array + * @return string Output + */ + private function pfx($tokens, $vars = array()) + { + if ($tokens == false) + return false; + + $stack = new EvalMathStack(); + + foreach ($tokens as $token) { // nice and easy + // if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on + $matches = array(); + if (in_array($token, array('+','-','*','/','^'))) { + if (is_null($op2 = $stack->pop())) + return $this->trigger(12, "internal error"); + if (is_null($op1 = $stack->pop())) + return $this->trigger(13, "internal error"); + switch ($token) { + case '+': + $stack->push($op1 + $op2); + break; + case '-': + $stack->push($op1 - $op2); + break; + case '*': + $stack->push($op1 * $op2); + break; + case '/': + if ($op2 == 0) + return $this->trigger(14, "division by zero"); + $stack->push($op1 / $op2); + break; + case '^': + $stack->push(pow($op1, $op2)); + break; + } + // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on + } elseif ($token == "_") { + $stack->push(- 1 * $stack->pop()); + // if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on + } elseif (preg_match("/^([a-z]\w*)\($/", $token, $matches)) { // it's a function! + $fnn = $matches[1]; + if (in_array($fnn, $this->fb)) { // built-in function: + if (is_null($op1 = $stack->pop())) + return $this->trigger(15, "internal error"); + $fnn = preg_replace("/^arc/", "a", $fnn); // for the 'arc' trig synonyms + if ($fnn == 'ln') + $fnn = 'log'; + eval('$stack->push(' . $fnn . '($op1));'); // perfectly safe eval() + } elseif (array_key_exists($fnn, $this->f)) { // user function + // get args + $args = array(); + for ($i = count($this->f[$fnn]['args']) - 1; $i >= 0; $i --) { + if (is_null($args[$this->f[$fnn]['args'][$i]] = $stack->pop())) + return $this->trigger(16, "internal error"); + } + $stack->push($this->pfx($this->f[$fnn]['func'], $args)); // yay... recursion!!!! + } + // if the token is a number or variable, push it on the stack + } else { + if (is_numeric($token)) { + $stack->push($token); + } elseif (array_key_exists($token, $this->v)) { + $stack->push($this->v[$token]); + } elseif (array_key_exists($token, $vars)) { + $stack->push($vars[$token]); + } else { + return $this->trigger(17, "undefined variable '$token'", $token); + } + } + } + // when we're out of tokens, the stack should have a single element, the final result + if ($stack->count != 1) + return $this->trigger(18, "internal error"); + return $stack->pop(); + } + + /** + * trigger an error, but nicely, if need be + * + * @param string $code Code + * @param string $msg Msg + * @param string|null $info String + * @return boolean False + */ + public function trigger($code, $msg, $info = null) + { + $this->last_error = $msg; + $this->last_error_code = array($code,$info); + if (! $this->suppress_errors) + trigger_error($msg, E_USER_WARNING); + return false; + } +} + +/** + * Class for internal use + */ +class EvalMathStack +{ + + public $stack = array(); + + public $count = 0; + + /** + * push + * + * @param string $val Val + * @return void + */ + public function push($val) + { + $this->stack[$this->count] = $val; + $this->count ++; + } + + /** + * pop + * + * @return mixed Stack + */ + public function pop() + { + if ($this->count > 0) { + $this->count --; + return $this->stack[$this->count]; + } + return null; + } + + /** + * last + * + * @param int $n N + * @return mixed Stack + */ + public function last($n = 1) + { + if (isset($this->stack[$this->count - $n])) { + return $this->stack[$this->count - $n]; + } + return; + } +} diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a9b908203fe..7a9373d59db 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -392,6 +392,7 @@ class ExtraFields if (empty($list)) $list = '0'; if (empty($required)) $required = 0; if (empty($unique)) $unique = 0; + if (empty($printable)) $printable = 0; if (empty($alwayseditable)) $alwayseditable = 0; if (empty($totalizable)) $totalizable = 0; @@ -1590,9 +1591,9 @@ class ExtraFields if ($type == 'date') $out.=' (YYYY-MM-DD)'; elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)'; */ - if (! empty($help) && $keyprefix != 'search_options_') { + /*if (! empty($help) && $keyprefix != 'search_options_') { $out .= $form->textwithpicto('', $help, 1, 'help', '', 0, 3); - } + }*/ return $out; } @@ -1944,6 +1945,10 @@ class ExtraFields { $align = "right"; } + elseif ($type == 'price') + { + $align="right"; + } elseif ($type == 'double') { $align = "right"; @@ -2163,7 +2168,7 @@ class ExtraFields if (in_array($key_type, array('date', 'datetime'))) { - if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)."year") continue; // Value was not provided, we should not set it. + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) continue; // Value was not provided, we should not set it. // Clean parameters $value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); } diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php index 0eed1a56580..10015e3c363 100644 --- a/htdocs/core/class/fiscalyear.class.php +++ b/htdocs/core/class/fiscalyear.class.php @@ -1,5 +1,7 @@ +/* Copyright (C) 2014-2020 Alexandre Spangaro + * Copyright (C) 2020 OScss-Shop + * * * 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 @@ -381,13 +383,19 @@ class Fiscalyear extends CommonObject * @param int $dateend Date end to scan * @return string Number of entries */ - public function getAccountancyEntriesByFiscalYear($datestart, $dateend) + public function getAccountancyEntriesByFiscalYear($datestart = '', $dateend = '') { global $conf; + if(empty($datestart) ) + $datestart = $this->date_start; + if(empty($dateend) ) + $dateend = $this->date_end; + $sql = "SELECT count(DISTINCT piece_num) as nb"; - $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping "; - $sql.= " WHERE doc_date >= '".$datestart."' and doc_date <= '".$dateend."'"; + $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql.= " WHERE entity IN (".getEntity('bookkeeping', 0).")"; + $sql.= " AND doc_date >= '".$this->db->idate($datestart)."' and doc_date <= '".$this->db->idate($dateend)."'"; $resql=$this->db->query($sql); if ($resql) @@ -407,13 +415,19 @@ class Fiscalyear extends CommonObject * @param int $dateend Date end to scan * @return string Number of movements */ - public function getAccountancyMovementsByFiscalYear($datestart, $dateend) + public function getAccountancyMovementsByFiscalYear($datestart = '', $dateend = '') { global $conf; + if(empty($datestart) ) + $datestart = $this->date_start; + if(empty($dateend) ) + $dateend = $this->date_end; + $sql = "SELECT count(rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping "; - $sql.= " WHERE doc_date >= '".$datestart."' AND doc_date <= '".$dateend."'"; + $sql.= " WHERE entity IN (".getEntity('bookkeeping', 0).")"; + $sql.= " AND doc_date >= '".$this->db->idate($datestart)."' and doc_date <= '".$this->db->idate($dateend)."'"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 39493825377..437ac507462 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -177,6 +177,7 @@ class HookManager 'getFormatedCustomerRef', 'getFormatedSupplierRef', 'getIdProfUrl', + 'getInputIdProf', 'moveUploadedFile', 'moreHtmlStatus', 'pdf_build_address', diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 4ab0bc44d9d..9f8e02e4948 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -202,7 +202,7 @@ class Form $ret .= ''; if (empty($notabletag)) $ret .= '
    '; - $html .= '' . $field->label . ' : '; + $html .= ''; + $html .= ''.$field->label.' : '; $html .= $field->content; $html .= "'; - $html .= '' . $field->label . ' :'; + $html .= ''.$field->label.' :'; $html .= "attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow); else $out .= $labeltoshow; if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' *'; } else { if ($mode != 'view' && !empty($extrafields->attributes[$this->table_element]['required'][$key])) $out .= ' fieldrequired'; $out .= '">'; - if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $extrafields->attributes[$this->table_element]['help'][$key]); + if (!empty($extrafields->attributes[$this->table_element]['help'][$key])) $out .= $form->textwithpicto($labeltoshow, $helptoshow); else $out .= $labeltoshow; } $out .= '
    '; if (empty($notabletag)) $ret .= ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } else // For external software { @@ -1299,6 +1333,19 @@ else print ''; print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''; + print ''; } print '
    '; - if (preg_match('/^(string|email)/', $typeofdata)) + if (preg_match('/^(string|safehtmlstring|email)/', $typeofdata)) { $tmp = explode(':', $typeofdata); $ret .= ''; @@ -276,6 +276,7 @@ class Form if (preg_match('/^(email)/', $typeofdata)) $ret .= dol_print_email($value, 0, 0, 0, 0, 1); elseif (preg_match('/^(amount|numeric)/', $typeofdata)) $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) $ret .= dol_htmlentitiesbr($value); + elseif (preg_match('/^safehtmlstring/', $typeofdata)) $ret .= dol_string_onlythesehtmltags($value); elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret .= dol_print_date($value, 'day'); elseif ($typeofdata == 'dayhour' || $typeofdata == 'datehourpicker') $ret .= dol_print_date($value, 'dayhour'); elseif (preg_match('/^select;/', $typeofdata)) @@ -315,6 +316,56 @@ class Form return $ret; } + /** + * Output edit in place form + * + * @param string $fieldname Name of the field + * @param object $object Object + * @param boolean $perm Permission to allow button to edit parameter. Set it to 0 to have a not edited field. + * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols', 'datepicker' ('day' do not work, don't know why), 'ckeditor:dolibarr_zzz:width:height:savemethod:1:rows:cols', 'select;xxx[:class]'...) + * @param string $check Same coe than $check parameter of GETPOST() + * @param string $morecss More CSS + * @return string HTML code for the edit of alternative language + */ + public function widgetForTranslation($fieldname, $object, $perm, $typeofdata = 'string', $check = '', $morecss = '') + { + global $conf, $langs; + + $result = ''; + + if (! empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) { + $langcode = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; + + $result .='
    '; + $s=img_picto($langs->trans("ShowOtherLanguages"), 'language', '', false, 0, 0, '', 'fa-15 editfieldlang'); + $result .= $s; + $result .= '
    '; + + $result .=''; + $result .= ''; + } + + return $result; + } + /** * Output edit in place form * @@ -641,12 +692,14 @@ class Form /* console.log( index + ": " + $( this ).text() ); */ if ($(this).is(\':checked\')) atleastoneselected++; }); + console.log("initCheckForSelect mode="+mode+" atleastoneselected="+atleastoneselected); + if (atleastoneselected || '.$alwaysvisible.') { jQuery(".massaction").show(); - '.($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'"); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').' - '.($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0"); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').' + '.($selected ? 'if (atleastoneselected) { jQuery(".massactionselect").val("'.$selected.'").trigger(\'change\'); jQuery(".massactionconfirmed").prop(\'disabled\', false); }' : '').' + '.($selected ? 'if (! atleastoneselected) { jQuery(".massactionselect").val("0").trigger(\'change\'); jQuery(".massactionconfirmed").prop(\'disabled\', true); } ' : '').' } else { @@ -1617,7 +1670,7 @@ class Form public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) { // phpcs:enable - global $conf, $user, $langs; + global $conf, $user, $langs, $hookmanager; // If no preselected user defined, we take current user if ((is_numeric($selected) && ($selected < -2 || empty($selected))) && empty($conf->global->SOCIETE_DISABLE_DEFAULT_SALESREPRESENTATIVE)) $selected = $user->id; @@ -1678,6 +1731,10 @@ class Form if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX) || $noactive) $sql .= " AND u.statut <> 0"; if (!empty($morefilter)) $sql .= " ".$morefilter; + //Add hook to filter on user (for exemple on usergroup define in custom modules) + $reshook = $hookmanager->executeHooks('addSQLWhereFilterOnSelectUsers', array(), $this, $action); + if (!empty($reshook)) $sql .= $hookmanager->resPrint; + if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname { $sql .= " ORDER BY u.firstname ASC"; @@ -2109,7 +2166,7 @@ class Form } } - $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; + $selectFields = " p.rowid, p.ref, p.label, p.description, p.barcode, p.fk_country, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; if (count($warehouseStatusArray)) { $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock @@ -2400,9 +2457,10 @@ class Form * @param string $selected Preselected value * @param int $hidepriceinlabel Hide price in label * @param string $filterkey Filter key to highlight + * @param int $novirtualstock Do not load virtual stock, even if slow option STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO is on. * @return void */ - protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '') + protected function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected, $hidepriceinlabel = 0, $filterkey = '', $novirtualstock = 0) { global $langs, $conf, $user, $db; @@ -2412,6 +2470,7 @@ class Form $outlabel = ''; $outdesc = ''; $outbarcode = ''; + $outorigin = ''; $outtype = ''; $outprice_ht = ''; $outprice_ttc = ''; @@ -2431,6 +2490,7 @@ class Form $outlabel = $objp->label; $outdesc = $objp->description; $outbarcode = $objp->barcode; + $outorigin = $objp->fk_country; $outpbq = empty($objp->price_by_qty_rowid) ? '' : $objp->price_by_qty_rowid; $outtype = $objp->fk_product_type; @@ -2492,12 +2552,15 @@ class Form $opt .= $objp->ref; if ($outbarcode) $opt .= ' ('.$outbarcode.')'; $opt .= ' - '.dol_trunc($label, $maxlengtharticle); + if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $opt .= ' ('.getCountry($outorigin, 1).')'; $objRef = $objp->ref; if (!empty($filterkey) && $filterkey != '') $objRef = preg_replace('/('.preg_quote($filterkey).')/i', '$1', $objRef, 1); $outval .= $objRef; if ($outbarcode) $outval .= ' ('.$outbarcode.')'; $outval .= ' - '.dol_trunc($label, $maxlengtharticle); + if ($outorigin && !empty($conf->global->PRODUCT_SHOW_ORIGIN_IN_COMBO)) $outval .= ' ('.getCountry($outorigin, 1).')'; + // Units $opt .= $outvalUnits; $outval .= $outvalUnits; @@ -2639,7 +2702,7 @@ class Form } $outval .= $langs->transnoentities("Stock").':'.$objp->stock; $outval .= ''; - if (!empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation + if (empty($novirtualstock) && !empty($conf->global->STOCK_SHOW_VIRTUAL_STOCK_IN_PRODUCTS_COMBO)) // Warning, this option may slow down combo list generation { $langs->load("stocks"); @@ -2905,7 +2968,7 @@ class Form $objp->fprice = $price_result; if ($objp->quantity >= 1) { - $objp->unitprice = $objp->fprice / $objp->quantity; + $objp->unitprice = $objp->fprice / $objp->quantity; // Replace dynamically unitprice } } } @@ -2972,7 +3035,7 @@ class Form if (empty($objp->idprodfournprice) && empty($alsoproductwithnosupplierprice)) $opt .= ' disabled'; if (!empty($objp->idprodfournprice) && $objp->idprodfournprice > 0) { - $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqpercent="'.$objp->remise_percent.'"'; + $opt .= ' pbq="'.$objp->idprodfournprice.'" data-pbq="'.$objp->idprodfournprice.'" data-pbqqty="'.$objp->quantity.'" data-pbqup="'.$objp->unitprice.'" data-pbqpercent="'.$objp->remise_percent.'"'; } $opt .= ' data-html="'.dol_escape_htmltag($optlabel).'"'; $opt .= '>'; @@ -2987,7 +3050,7 @@ class Form // "key" value of json key array is used by jQuery automatically as selected value // "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, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false))); + array_push($outarray, array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'qty'=>$outqty, 'up'=>$objp->unitprice, 'discount'=>$outdiscount, 'type'=>$outtype, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit, 'disabled'=>(empty($objp->idprodfournprice) ?true:false))); // 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é)" @@ -3506,13 +3569,13 @@ class Form // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods - * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. + * Constant MAIN_DEFAULT_PAYMENT_TYPE_ID can used to set default value but scope is all application, probably not what you want. * - * @param string $selected Id du mode de paiement pre-selectionne - * @param string $htmlname Nom de la zone select + * @param string $selected Id or code or preselected payment mode + * @param string $htmlname Name of select field * @param string $filtertype To filter on field type in llx_c_paiement ('CRDT' or 'DBIT' or array('code'=>xx,'label'=>zz)) - * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code - * @param int $empty 1=peut etre vide, 0 sinon + * @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code + * @param int $empty 1=can be empty, 0 otherwise * @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $maxlength Max length of label * @param int $active Active or not, -1 = all @@ -3553,9 +3616,12 @@ class Form elseif ($format == 1) print '
    '; print $formaccounting->select_account(GETPOST('accountancy_code_buy', 'alpha'), 'accountancy_code_buy', 1, null, 1, 1, ''); print '
    '.$langs->trans("ProductAccountancyBuyIntraCode").''; + if ($type == 0) { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT); + } else { + $accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, null, 1, 1, ''); + print '
    '.$langs->trans("ProductAccountancyBuyExportCode").''; + if ($type == 0) + { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT); + } else { + $accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT); + } + print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, null, 1, 1, ''); + print '
    '.$langs->trans("ProductAccountancyBuyCode").''; print '
    '.$langs->trans("ProductAccountancyBuyIntraCode").''; + print '
    '.$langs->trans("ProductAccountancyBuyExportCode").''; + print '
    '; @@ -1440,7 +1487,7 @@ else // Default warehouse print ''.$langs->trans("DefaultWarehouse").''; print $formproduct->selectWarehouses($object->fk_default_warehouse, 'fk_default_warehouse', 'warehouseopen', 1); - print ' '.$langs->trans("AddWarehouse").''; + print ' '; print ''; /* print "".''.$langs->trans("StockLimit").''; @@ -1554,8 +1601,10 @@ else $c = new Categorie($db); $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT); $arrayselected = array(); - foreach ($cats as $cat) { - $arrayselected[] = $cat->id; + if (is_array($cats)) { + foreach ($cats as $cat) { + $arrayselected[] = $cat->id; + } } print $form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, '', 0, '100%'); print ""; @@ -1606,6 +1655,21 @@ else print ''; print $formaccounting->select_account($object->accountancy_code_buy, 'accountancy_code_buy', 1, '', 1, 1); print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("ProductAccountancyBuyIntraCode").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, '', 1, 1); + print ''; + } + + // Accountancy_code_buy_export + print ''.$langs->trans("ProductAccountancyBuyExportCode").''; + print ''; + print $formaccounting->select_account($object->accountancy_code_buy_export, 'accountancy_code_buy_export', 1, '', 1, 1); + print ''; } else // For external software { @@ -1631,6 +1695,19 @@ else print ''.$langs->trans("ProductAccountancyBuyCode").''; print ''; print ''; + + // Accountancy_code_buy_intra + if ($mysoc->isInEEC()) + { + print ''.$langs->trans("ProductAccountancyBuyIntraCode").''; + print ''; + print ''; + } + + // Accountancy_code_buy_export + print ''.$langs->trans("ProductAccountancyBuyExportCode").''; + print ''; + print ''; } print ''; @@ -1812,6 +1889,45 @@ else } print ''; + // Accountancy buy code intra-community + if ($mysoc->isInEEC()) + { + print ''; + print $langs->trans("ProductAccountancyBuyIntraCode"); + print ''; + if (!empty($conf->accounting->enabled)) + { + if (!empty($object->accountancy_code_buy_intra)) + { + $accountingaccount5 = new AccountingAccount($db); + $accountingaccount5->fetch('', $object->accountancy_code_buy_intra, 1); + + print $accountingaccount5->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_buy_intra; + } + print ''; + } + + // Accountancy buy code export + print ''; + print $langs->trans("ProductAccountancyBuyExportCode"); + print ''; + if (!empty($conf->accounting->enabled)) + { + if (!empty($object->accountancy_code_buy_export)) + { + $accountingaccount6 = new AccountingAccount($db); + $accountingaccount6->fetch('', $object->accountancy_code_buy_export, 1); + + print $accountingaccount6->getNomUrl(0, 1, 1, '', 1); + } + } else { + print $object->accountancy_code_buy_export; + } + print ''; + // Batch number management (to batch) if (!empty($conf->productbatch->enabled)) { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index d7d72e28b7c..57964271e47 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -861,11 +861,11 @@ class Products extends DolibarrApi } if ($result) { - $this->productsupplier->fetch($id, $ref); - $this->productsupplier->list_product_fournisseur_price($id, '', '', 0, 0); + $product_fourn = new ProductFournisseur($this->db); + $product_fourn_list = $product_fourn->list_product_fournisseur_price($this->product->id, '', '', 0, 0); } - return $this->_cleanObjectDatas($this->productsupplier); + return $this->_cleanObjectDatas($product_fourn_list); } /** diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index af78ab5b59d..6443b0d03a3 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -254,6 +254,9 @@ class FormProduct $out.= $comboenhancement; } + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE)) $selected = $conf->global->MAIN_DEFAULT_WAREHOUSE; + if (empty($selected) && !empty($conf->global->MAIN_DEFAULT_WAREHOUSE_USER)) $selected = $user->fk_warehouse; + $out.=''; print ''; print ''; - print ''; + //print ''; print ''; if (empty($arrayfields['p.fk_product_type']['checked'])) print ''; - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit); + print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'products', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "product"; @@ -769,7 +783,9 @@ if ($resql) if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) print ''; if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) print ''; // Accountancy code buy - if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) print ''; + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) print ''; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook @@ -885,6 +901,12 @@ if ($resql) if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { print_liste_field_titre($arrayfields['p.accountancy_code_buy']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy", "", $param, '', $sortfield, $sortorder); } + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_buy_intra']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_intra", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { + print_liste_field_titre($arrayfields['p.accountancy_code_buy_export']['label'], $_SERVER["PHP_SELF"], "p.accountancy_code_buy_export", "", $param, '', $sortfield, $sortorder); + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -949,6 +971,8 @@ if ($resql) $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; $product_static->length = $obj->length; $product_static->length_units = $obj->length_units; $product_static->width = $obj->width; @@ -1305,6 +1329,16 @@ if ($resql) print ''.$obj->accountancy_code_buy.''; if (!$i) $totalarray['nbfield']++; } + if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) + { + print ''.$obj->accountancy_code_buy_intra.''; + if (!$i) $totalarray['nbfield']++; + } + if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) + { + print ''.$obj->accountancy_code_buy_export.''; + if (!$i) $totalarray['nbfield']++; + } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook diff --git a/htdocs/product/popucom.php b/htdocs/product/popucom.php index 41f14e25176..7b89e04bf61 100644 --- a/htdocs/product/popucom.php +++ b/htdocs/product/popucom.php @@ -42,7 +42,7 @@ $result=restrictedArea($user, 'produit|service'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index 4df11c7d755..e0fce722ee7 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -42,7 +42,7 @@ $result=restrictedArea($user, 'produit|service'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (! $sortfield) $sortfield="c"; if (! $sortorder) $sortorder="DESC"; @@ -61,15 +61,15 @@ $staticproduct=new Product($db); $helpurl=''; if ($type == '0') { - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } elseif ($type == '1') { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } else { - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } $title=$langs->trans("Statistics"); @@ -130,7 +130,7 @@ $sql.= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type"; $result=$db->query($sql); if ($result) { - $totalnboflines = $db->num_rows($result); + $totalnboflines = $db->num_rows($result); } $sql.= $db->order($sortfield, $sortorder); @@ -139,23 +139,23 @@ $sql.= $db->plimit($limit+1, $offset); $resql=$db->query($sql); if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $num = $db->num_rows($resql); + $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); + while ($i < $num) + { + $objp = $db->fetch_object($resql); - $infoprod[$objp->rowid]=array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label); - $infoprod[$objp->rowid]['nblineproposal']=$objp->c; + $infoprod[$objp->rowid]=array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label); + $infoprod[$objp->rowid]['nblineproposal']=$objp->c; - $i++; - } - $db->free($resql); + $i++; + } + $db->free($resql); } else { - dol_print_error($db); + dol_print_error($db); } //var_dump($infoprod); diff --git a/htdocs/product/price.php b/htdocs/product/price.php index a6697701a68..3f6a89cbddb 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1151,7 +1151,7 @@ if ($action == 'edit_vat' && ($user->rights->produit->creer || $user->rights->se print load_fiche_titre($langs->trans("UpdateVAT"), ''); print '
    '; - print ''; + print ''; print ''; print ''; @@ -1185,7 +1185,7 @@ if ($action == 'edit_price' && $object->getRights()->creer) { print ''."\n"; print ''; - print ''; + print ''; print ''; print ''; @@ -1660,7 +1660,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print load_fiche_titre($langs->trans('PriceByCustomer')); print ''; - print ''; + print ''; print ''; print ''; @@ -1747,7 +1747,7 @@ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) } print ''; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index 512d5ff2b89..1af1cebfbb5 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -54,7 +54,7 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) $page = 0; if (!$sortfield) $sortfield = "p.ref"; if (!$sortorder) $sortorder = "ASC"; diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index e07dcf0536d..cd65b2c09f7 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -58,7 +58,7 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0) $page = 0; if (!$sortfield) $sortfield = "p.ref"; if (!$sortorder) $sortorder = "ASC"; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index c35d8401a8a..e2a30b51a87 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -299,6 +299,12 @@ if ($result || empty($id)) 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsContracts") : $langs->transnoentitiesnoconv("NumberOfContracts"))); } + if ($conf->mrp->enabled) { + $graphfiles['mrp'] = array('modulepart'=>'productstats_mrp', + 'file' => $object->id.'/mos12m'.((string) $type != '' ? '_type'.$type : '').'_'.$mode.($search_year ? '_year'.$search_year : '').'.png', + 'label' => ($mode == 'byunit' ? $langs->transnoentitiesnoconv("NumberOfUnitsMos") : $langs->transnoentitiesnoconv("NumberOfMos"))); + } + $px = new DolGraph(); if (!$error && count($graphfiles) > 0) @@ -338,6 +344,7 @@ if ($result || empty($id)) if ($key == 'invoicessuppliers') $graph_data = $object->get_nb_achat($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); if ($key == 'orderssuppliers') $graph_data = $object->get_nb_ordersupplier($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); if ($key == 'contracts') $graph_data = $object->get_nb_contract($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); + if ($key == 'mrp') $graph_data = $object->get_nb_mos($socid, $mode, ((string) $type != '' ? $type : -1), $search_year, $morefilters); // TODO Save cachefile $graphfiles[$key]['file'] } @@ -348,6 +355,7 @@ if ($result || empty($id)) $px->SetYLabel($graphfiles[$key]['label']); $px->SetMaxValue($px->GetCeilMaxValue() < 0 ? 0 : $px->GetCeilMaxValue()); $px->SetMinValue($px->GetFloorMinValue() > 0 ? 0 : $px->GetFloorMinValue()); + $px->setShowLegend(0); $px->SetWidth($WIDTH); $px->SetHeight($HEIGHT); $px->SetHorizTickIncrement(1); @@ -384,6 +392,7 @@ if ($result || empty($id)) if ($graphfiles == 'proposals_suppliers' && !$user->rights->supplier_proposal->lire) continue; if ($graphfiles == 'invoices_suppliers' && !$user->rights->fournisseur->facture->lire) continue; if ($graphfiles == 'orders_suppliers' && !$user->rights->fournisseur->commande->lire) continue; + if ($graphfiles == 'mrp' && empty($user->rights->mrp->mo->read)) continue; if ($i % 2 == 0) @@ -412,7 +421,7 @@ if ($result || empty($id)) // Label print ''; print $graphfiles[$key]['label']; - print ' ('.$graphfiles[$key]['total'].')'; + print ' ('.$graphfiles[$key]['total'].')'; print ''.$linktoregenerate.''; print ''; // Image diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 4299a1db53b..71c1b0f1ef7 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -37,11 +37,11 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatsorder')); @@ -49,62 +49,62 @@ $hookmanager->initHooks(array('productstatsorder')); $mesg = ''; // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="c.date_commande"; -$search_month = GETPOST('search_month', 'aplha'); +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "c.date_commande"; +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_month=''; - $search_year=''; + $search_month = ''; + $search_year = ''; } /* * View */ -$orderstatic=new Commande($db); -$societestatic=new Societe($db); +$orderstatic = new Commande($db); +$societestatic = new Societe($db); $form = new Form($db); -$formother= new FormOther($db); +$formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters=array('id'=>$id); - $reshook=$hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); llxHeader("", "", $langs->trans("CardProduct".$product->type)); if ($result > 0) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($product); + $titre = $langs->trans("CardProduct".$product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -126,28 +126,28 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->commande->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,"; - $sql.= " c.ref_client,"; - $sql.= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."commande as c"; - $sql.= ", ".MAIN_DB_PREFIX."commandedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.fk_soc = s.rowid"; - $sql.= " AND c.entity IN (".getEntity('commande').")"; - $sql.= " AND d.fk_commande = c.rowid"; - $sql.= " AND d.fk_product =".$product->id; - if (! empty($search_month)) - $sql.= ' AND MONTH(c.date_commande) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " c.ref_client,"; + $sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= ", ".MAIN_DB_PREFIX."commandedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE c.fk_soc = s.rowid"; + $sql .= " AND c.entity IN (".getEntity('commande').")"; + $sql .= " AND d.fk_commande = c.rowid"; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(c.date_commande) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(c.date_commande) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND c.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); //Calcul total qty and amount for global if full scan list - $total_ht=0; - $total_qty=0; + $total_ht = 0; + $total_qty = 0; // Count total nb of records $totalofrecords = ''; @@ -164,30 +164,30 @@ if ($id > 0 || ! empty($ref)) { $num = $db->num_rows($result); - if (! empty($id)) + if (!empty($id)) $option .= '&id='.$product->id; - if (! empty($search_month)) + if (!empty($search_month)) $option .= '&search_month='.$search_month; - if (! empty($search_year)) + if (!empty($search_year)) $option .= '&search_year='.$search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; print ''; print ''; @@ -214,12 +214,12 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; - $orderstatic->id=$objp->commandeid; - $orderstatic->ref=$objp->ref; - $orderstatic->ref_client=$objp->ref_client; + $orderstatic->id = $objp->commandeid; + $orderstatic->ref = $objp->ref; + $orderstatic->ref_client = $objp->ref_client; $societestatic->fetch($objp->socid); print ''; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index df6abec3d22..7a5b88000e1 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -54,7 +54,7 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -63,7 +63,7 @@ if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "c.date_commande"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index e5e37e44242..8e61446a834 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -49,7 +49,7 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 7bb784f5031..e42afd9f28c 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -38,35 +38,35 @@ $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); // Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : '')); -$fieldtype = (! empty($ref) ? 'ref' : 'rowid'); -$socid=''; -if (! empty($user->socid)) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($ref) ? 'ref' : 'rowid'); +$socid = ''; +if (!empty($user->socid)) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productstatsinvoice')); -$showmessage=GETPOST('showmessage'); +$showmessage = GETPOST('showmessage'); // Load variable for pagination -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder="DESC"; -if (! $sortfield) $sortfield="f.datef"; +if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) $sortfield = "f.datef"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { - $search_month=''; - $search_year=''; + $search_month = ''; + $search_year = ''; } @@ -75,21 +75,21 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', * View */ -$invoicestatic=new Facture($db); -$societestatic=new Societe($db); +$invoicestatic = new Facture($db); +$societestatic = new Societe($db); $form = new Form($db); -$formother= new FormOther($db); +$formother = new FormOther($db); -if ($id > 0 || ! empty($ref)) +if ($id > 0 || !empty($ref)) { $product = new Product($db); $result = $product->fetch($id, $ref); $object = $product; - $parameters=array('id'=>$id); - $reshook=$hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks + $parameters = array('id'=>$id); + $reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $title = $langs->trans('ProductServiceCard'); @@ -97,32 +97,32 @@ if ($id > 0 || ! empty($ref)) $shortlabel = dol_trunc($object->label, 16); if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) { - $title = $langs->trans('Product')." ". $shortlabel ." - ".$langs->trans('Referers'); - $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; + $title = $langs->trans('Product')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; } if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) { - $title = $langs->trans('Service')." ". $shortlabel ." - ".$langs->trans('Referers'); - $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; + $title = $langs->trans('Service')." ".$shortlabel." - ".$langs->trans('Referers'); + $helpurl = 'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; } llxHeader('', $title, $helpurl); if ($result > 0) { - $head=product_prepare_head($product); - $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); + $head = product_prepare_head($product); + $titre = $langs->trans("CardProduct".$product->type); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, -1, $picto); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $linkback = ''.$langs->trans("BackToList").''; $shownav = 1; - if ($user->socid && ! in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref'); @@ -147,28 +147,28 @@ if ($id > 0 || ! empty($ref)) elseif ($user->rights->facture->lire) { $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,"; - $sql.= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; - $sql.= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql.= ", ".MAIN_DB_PREFIX."facture as f"; - $sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; - if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE f.fk_soc = s.rowid"; - $sql.= " AND f.entity IN (".getEntity('invoice').")"; - $sql.= " AND d.fk_facture = f.rowid"; - $sql.= " AND d.fk_product =".$product->id; - if (! empty($search_month)) - $sql.= ' AND MONTH(f.datef) IN (' . $search_month . ')'; - if (! empty($search_year)) - $sql.= ' AND YEAR(f.datef) IN (' . $search_year . ')'; - if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($socid) $sql.= " AND f.fk_soc = ".$socid; - $sql.= $db->order($sortfield, $sortorder); + $sql .= " f.ref, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,"; + $sql .= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; + $sql .= ", ".MAIN_DB_PREFIX."facture as f"; + $sql .= ", ".MAIN_DB_PREFIX."facturedet as d"; + if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE f.fk_soc = s.rowid"; + $sql .= " AND f.entity IN (".getEntity('invoice').")"; + $sql .= " AND d.fk_facture = f.rowid"; + $sql .= " AND d.fk_product =".$product->id; + if (!empty($search_month)) + $sql .= ' AND MONTH(f.datef) IN ('.$search_month.')'; + if (!empty($search_year)) + $sql .= ' AND YEAR(f.datef) IN ('.$search_year.')'; + if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; + if ($socid) $sql .= " AND f.fk_soc = ".$socid; + $sql .= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list - $total_ht=0; - $total_qty=0; + $total_ht = 0; + $total_qty = 0; // Count total nb of records $totalofrecords = ''; @@ -178,37 +178,37 @@ if ($id > 0 || ! empty($ref)) $totalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - if (! empty($id)) + if (!empty($id)) $option .= '&id='.$product->id; - if (! empty($search_month)) + if (!empty($search_month)) $option .= '&search_month='.$search_month; - if (! empty($search_year)) + if (!empty($search_year)) $option .= '&search_year='.$search_year; - if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit); - print '' . "\n"; - if (! empty($sortfield)) - print ''; - if (! empty($sortorder)) - print ''; - if (! empty($page)) { - print ''; - $option .= '&page=' . $page; + print ''."\n"; + if (!empty($sortfield)) + print ''; + if (!empty($sortorder)) + print ''; + if (!empty($page)) { + print ''; + $option .= '&page='.$page; } print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
    '; print '
    '; - print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; - print $langs->trans('Month') . ': '; - print $langs->trans('Year') . ':' . $formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Period').' ('.$langs->trans("DateInvoice").') - '; + print $langs->trans('Month').': '; + print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); print '
    '; print ''; print ''; @@ -235,13 +235,13 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty=-($objp->qty); + if ($objp->type == Facture::TYPE_CREDIT_NOTE) $objp->qty = -($objp->qty); - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; + $total_ht += $objp->total_ht; + $total_qty += $objp->qty; - $invoicestatic->id=$objp->facid; - $invoicestatic->ref=$objp->ref; + $invoicestatic->id = $objp->facid; + $invoicestatic->ref = $objp->ref; $societestatic->fetch($objp->socid); $paiement = $invoicestatic->getSommePaiement(); diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 34247393106..29774709e5e 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -53,14 +53,14 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "f.datef"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/mo.php b/htdocs/product/stats/mo.php index 8c7eb34e7e1..0a148ad2c8a 100644 --- a/htdocs/product/stats/mo.php +++ b/htdocs/product/stats/mo.php @@ -49,7 +49,7 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 17e9c37158c..d65b88ccabc 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -52,7 +52,7 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.datep"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index c344170e674..a7fede51aa1 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -52,7 +52,7 @@ $mesg = ''; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; @@ -60,7 +60,7 @@ $pagenext = $page + 1; if (!$sortorder) $sortorder = "DESC"; if (!$sortfield) $sortfield = "p.date_valid"; -$search_month = GETPOST('search_month', 'aplha'); +$search_month = GETPOST('search_month', 'alpha'); $search_year = GETPOST('search_year', 'int'); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index d0a1fc5db76..c268eaa1f15 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -105,6 +105,8 @@ if (empty($reshook)) $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); if (!empty($object->libelle)) { @@ -174,6 +176,8 @@ if (empty($reshook)) $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -292,6 +296,11 @@ if ($action == 'create') print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id'); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); print ''; + + // Phone / Fax + print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('Phone', 'phone', '', $object, 0).''; + print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + // Status print ''.$langs->trans("Status").''; print ''; + print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; + // Status print ''.$langs->trans("Status").''; print ''; print "

    "; } +$max = 15; -$sql = "SELECT e.ref as label, e.rowid, e.statut"; +$sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut as status"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " WHERE e.statut in (0,1)"; $sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= $db->order('e.statut', 'DESC'); -$sql.= $db->plimit(15, 0); +$sql.= $db->plimit($max + 1, 0); $result = $db->query($sql); @@ -92,20 +94,31 @@ if ($result) if ($num) { - $entrepot=new Entrepot($db); - - while ($i < $num) + while ($i < min($max, $num)) { $objp = $db->fetch_object($result); + $warehouse->id = $objp->rowid; + $warehouse->statut = $objp->status; + $warehouse->label = $objp->label; + $warehouse->lieu = $objp->lieu; + print ''; - print "rowid\">".img_object($langs->trans("ShowStock"), "stock")." ".$objp->label."\n"; - print ''.$entrepot->LibStatut($objp->statut, 5).''; + print ''; + print $warehouse->getNomUrl(1); + print ''."\n"; + print ''; + print $warehouse->getLibStatut(5); + print ''; print "\n"; $i++; } $db->free($result); } + if ($num > $max) { + print ''.$langs->trans("More").'...'; + } + print ""; print '
    '; } @@ -119,10 +132,10 @@ else print '
    '; -// Last movements +// Latest movements $max=10; $sql = "SELECT p.rowid, p.label as produit, p.tobatch, p.tosell, p.tobuy,"; -$sql.= " e.ref as stock, e.rowid as entrepot_id,"; +$sql.= " e.ref as warehouse_ref, e.rowid as warehouse_id, e.ref as warehouse_label, e.lieu, e.statut as warehouse_status,"; $sql.= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; @@ -166,8 +179,14 @@ if ($resql) $producttmp->status_sell = $objp->tosell; $producttmp->status_buy = $objp->tobuy; + $warehouse->id = $objp->warehouse_id; + $warehouse->ref = $objp->warehouse_ref; + $warehouse->statut = $objp->warehouse_status; + $warehouse->label = $objp->warehouse_label; + $warehouse->lieu = $objp->lieu; + print ''; - print ''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; + print ''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; print ''; print $producttmp->getNomUrl(1); print "\n"; @@ -177,9 +196,9 @@ if ($resql) print ''.dol_print_date($db->jdate($objp->sellby), 'day').''; print ''.dol_print_date($db->jdate($objp->eatby), 'day').''; } - print ''; - print img_object($langs->trans("ShowWarehouse"), "stock").' '.$objp->stock; - print "\n"; + print ''; + print $warehouse->getNomUrl(1); + print "\n"; print ''; if ($objp->qty > 0) print '+'; print $objp->qty.''; @@ -190,6 +209,8 @@ if ($resql) print ""; print '
    '; +} else { + dol_print_error($db); } //print ''; diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index a23b99b9293..798f21004c7 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -32,45 +32,45 @@ require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; */ function dolDispatchToDo($order_id) { - global $db; + global $db; - $dispatched = array(); - $ordered = array(); + $dispatched = array(); + $ordered = array(); - // Count nb of quantity dispatched per product - $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch'; - $sql.= ' WHERE fk_commande = ' . $order_id; - $sql.= ' GROUP BY fk_product'; - $sql.= ' ORDER by fk_product'; - $resql = $db->query($sql); - if ($resql && $db->num_rows($resql)) - { - while ($obj = $db->fetch_object($resql)) - $dispatched[$obj->fk_product] = $obj; - } + // Count nb of quantity dispatched per product + $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch'; + $sql.= ' WHERE fk_commande = ' . $order_id; + $sql.= ' GROUP BY fk_product'; + $sql.= ' ORDER by fk_product'; + $resql = $db->query($sql); + if ($resql && $db->num_rows($resql)) + { + while ($obj = $db->fetch_object($resql)) + $dispatched[$obj->fk_product] = $obj; + } - // Count nb of quantity to dispatch per product - $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet'; - $sql.= ' WHERE fk_commande = ' . $order_id; - $sql.= ' AND fk_product > 0'; - if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= ' AND product_type = 0'; - $sql.= ' GROUP BY fk_product'; - $sql.= ' ORDER by fk_product'; - $resql = $db->query($sql); - if ($resql && $db->num_rows($resql)) - { - while ($obj = $db->fetch_object($resql)) - $ordered[$obj->fk_product] = $obj; - } + // Count nb of quantity to dispatch per product + $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet'; + $sql.= ' WHERE fk_commande = ' . $order_id; + $sql.= ' AND fk_product > 0'; + if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql.= ' AND product_type = 0'; + $sql.= ' GROUP BY fk_product'; + $sql.= ' ORDER by fk_product'; + $resql = $db->query($sql); + if ($resql && $db->num_rows($resql)) + { + while ($obj = $db->fetch_object($resql)) + $ordered[$obj->fk_product] = $obj; + } - $todispatch=0; - foreach ($ordered as $key => $val) - { + $todispatch=0; + foreach ($ordered as $key => $val) + { if ($ordered[$key] > $dispatched[$key]) $todispatch++; - } + } - return ($todispatch ? true : false); - //return true; + return ($todispatch ? true : false); + //return true; } /** @@ -80,30 +80,30 @@ function dolDispatchToDo($order_id) */ function dispatchedOrders() { - global $db; + global $db; - $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur'; - $resql = $db->query($sql); - $resarray = array(); - if ($resql && $db->num_rows($resql) > 0) - { - while ($obj = $db->fetch_object($resql)) - { - if (! dolDispatchToDo($obj->rowid)) - { - $resarray[] = $obj->rowid; - } - } - } + $sql = 'SELECT rowid FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur'; + $resql = $db->query($sql); + $resarray = array(); + if ($resql && $db->num_rows($resql) > 0) + { + while ($obj = $db->fetch_object($resql)) + { + if (! dolDispatchToDo($obj->rowid)) + { + $resarray[] = $obj->rowid; + } + } + } - if (count($resarray)) - { - $res = '(' . implode(',', $resarray) . ')'; - } else { - //hack to make sure ordered SQL request won't syntax error - $res = '(0)'; - } - return $res; + if (count($resarray)) + { + $res = '(' . implode(',', $resarray) . ')'; + } else { + //hack to make sure ordered SQL request won't syntax error + $res = '(0)'; + } + return $res; } /** @@ -159,16 +159,16 @@ function ordered($product_id) */ function getProducts($order_id) { - global $db; - $order = new CommandeFournisseur($db); - $f = $order->fetch($order_id); - $products = array(); - if($f) { - foreach($order->lines as $line) { - if (!in_array($line->fk_product, $products)) { - $products[] = $line->fk_product; - } - } - } - return $products; + global $db; + $order = new CommandeFournisseur($db); + $f = $order->fetch($order_id); + $products = array(); + if($f) { + foreach($order->lines as $line) { + if (!in_array($line->fk_product, $products)) { + $products[] = $line->fk_product; + } + } + } + return $products; } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 22f86df95a8..39f42575e25 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2015 Juanjo Menent + * Copyright (C) 2020 Tobias Sekan * * 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 @@ -26,6 +27,12 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcategory.class.php'; + +if (!empty($conf->categorie->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("stocks", "other")); @@ -45,11 +52,16 @@ $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("sear $search_label = GETPOST("snom", "alpha") ?GETPOST("snom", "alpha") : GETPOST("search_label", "alpha"); $search_status = GETPOST("search_status", "int"); +if (!empty($conf->categorie->enabled)) +{ + $search_category_list = GETPOST("search_category_".Categorie::TYPE_WAREHOUSE."_list", "array"); +} + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; @@ -83,19 +95,26 @@ $fieldstosearchall = array( 'e.address'=>"Address", 'e.zip'=>'Zip', 'e.town'=>'Town', + 'e.phone'=>'Phone', + 'e.fax'=>'Fax', ); // Definition of fields for list $arrayfields = array( - 'stockqty'=>array('type'=>'float', 'label'=>'PhysicalStock', 'enabled'=>1, 'visible'=>-2, 'position'=>70), - 'estimatedvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValue', 'enabled'=>1, 'visible'=>-2, 'position'=>71), - 'sellvalue'=>array('type'=>'float', 'label'=>'EstimatedStockValueSell', 'enabled'=>1, 'visible'=>-2, 'position'=>72), + 'e.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), + 'e.lieu'=>array('label'=>$langs->trans("LocationSummary"), 'checked'=>1), + 'e.description'=>array('label'=>$langs->trans("Description"), 'checked'=>0), + 'e.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0), + 'e.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), + 'e.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0), + 'e.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0), + 'e.fax'=>array('label'=>$langs->trans("Fax"), 'checked'=>0), + 'stockqty'=>array('type'=>'float', 'label'=>$langs->trans("PhysicalStock"), 'enabled'=>1, 'visible'=>-2, 'position'=>70), + 'estimatedvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValue"), 'enabled'=>1, 'visible'=>-2, 'position'=>71), + 'sellvalue'=>array('type'=>'float', 'label'=>$langs->trans("EstimatedStockValueSell"), 'enabled'=>1, 'visible'=>-2, 'position'=>72), + 'e.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>100), ); -foreach ($object->fields as $key => $val) -{ - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']); -} + // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { @@ -134,6 +153,7 @@ if (empty($reshook)) $search_status = ""; $toselect = ''; $search_array_options = array(); + $search_category_list = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) @@ -155,7 +175,7 @@ if (empty($reshook)) * View */ -$form = new Form($db); +$form = new FormCategory($db); $warehouse = new Entrepot($db); $now = dol_now(); @@ -166,7 +186,7 @@ $title = $langs->trans("ListOfWarehouses"); // Build and execute select // -------------------------------------------------------------------- -$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; +$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.phone, e.fax, e.fk_pays, e.fk_parent,"; $sql .= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -180,10 +200,22 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as e"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "e.rowid"); +} + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql .= " WHERE e.entity IN (".getEntity('stock').")"; + +if (!empty($conf->categorie->enabled)) +{ + $sql .= Categorie::getFilterSelectQuery(Categorie::TYPE_WAREHOUSE, "e.rowid", $search_category_list); +} + if ($search_ref) $sql .= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql .= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql .= " AND e.statut = ".$search_status; @@ -194,7 +226,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; +$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.phone, e.fax, e.fk_parent"; $totalnboflines = 0; $result = $db->query($sql); if ($result) @@ -310,6 +342,12 @@ if ($search_all) } $moreforfilter = ''; + +if (!empty($conf->categorie->enabled)) +{ + $moreforfilter .= $form->getFilterBox(Categorie::TYPE_WAREHOUSE, $search_category_list); +} + /*$moreforfilter.='
    '; $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
    ';*/ @@ -331,23 +369,60 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
    '; // You can use div-table-responsive-no-min if you dont need reserved height for your table -print ''."\n"; +print '
    '."\n"; // Fields title search // -------------------------------------------------------------------- print ''; -print ''; - -print ''; - -print ''; -print ''; -print ''; +if (!empty($arrayfields['e.ref']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.lieu']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.description']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.address']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.zip']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.town']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.phone']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['e.fax']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['stockqty']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['estimatedvalue']['checked'])) +{ + print ''; +} +if (!empty($arrayfields['sellvalue']['checked'])) +{ + print ''; +} // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -357,9 +432,12 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $obje print $hookmanager->resPrint; // Status -print ''; +if (!empty($arrayfields['e.statut']['checked'])) +{ + print ''; +} // Action column print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); -print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); -print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'right '); + +if (!empty($arrayfields['e.ref']['checked'])) +{ + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.lieu']['checked'])) +{ + print_liste_field_titre($arrayfields['e.lieu']['label'], $_SERVER["PHP_SELF"], "e.lieu", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.description']['checked'])) +{ + print_liste_field_titre($arrayfields['e.description']['label'], $_SERVER["PHP_SELF"], "e.description", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.address']['checked'])) +{ + print_liste_field_titre($arrayfields['e.address']['label'], $_SERVER["PHP_SELF"], "e.address", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.zip']['checked'])) +{ + print_liste_field_titre($arrayfields['e.zip']['label'], $_SERVER["PHP_SELF"], "e.zip", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.town']['checked'])) +{ + print_liste_field_titre($arrayfields['e.town']['label'], $_SERVER["PHP_SELF"], "e.town", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.phone']['checked'])) +{ + print_liste_field_titre($arrayfields['e.phone']['label'], $_SERVER["PHP_SELF"], "e.phone", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['e.fax']['checked'])) +{ + print_liste_field_titre($arrayfields['e.fax']['label'], $_SERVER["PHP_SELF"], "e.fax", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['stockqty']['checked'])) +{ + print_liste_field_titre($arrayfields['stockqty']['label'], $_SERVER["PHP_SELF"], "stockqty", '', $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['estimatedvalue']['checked'])) +{ + print_liste_field_titre($arrayfields['estimatedvalue']['label'], $_SERVER["PHP_SELF"], "estimatedvalue", '', $param, '', $sortfield, $sortorder, 'right '); +} +if (!empty($arrayfields['sellvalue']['checked'])) +{ + print_liste_field_titre($arrayfields['sellvalue']['label'], $_SERVER["PHP_SELF"], "sellvalue", '', $param, '', $sortfield, $sortorder, 'right '); +} + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; + // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; -print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); + +if (!empty($arrayfields['e.statut']['checked'])) +{ + print_liste_field_titre($arrayfields['e.statut']['label'], $_SERVER["PHP_SELF"], "e.statut", '', $param, '', $sortfield, $sortorder, 'right '); +} + // Action column print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print ''."\n"; @@ -410,33 +535,96 @@ if ($num) // Show here line of result print ''; - print ''; - if (!$i) $totalarray['nbfield']++; + + //print_r($arrayfields[]); + + // Label (ref) + if (!empty($arrayfields['e.ref']['checked'])) + { + print ''; + } + // Location - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['e.lieu']['checked'])) + { + print ''; + } + + // Description + if (!empty($arrayfields['e.description']['checked'])) + { + print ''; + } + + // Address + if (!empty($arrayfields['e.address']['checked'])) + { + print ''; + } + + // Zip + if (!empty($arrayfields['e.zip']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['e.town']['checked'])) + { + print ''; + } + + // Phone + if (!empty($arrayfields['e.phone']['checked'])) + { + print ''; + } + + //Fax + if (!empty($arrayfields['e.fax']['checked'])) + { + print ''; + } // Stock qty - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['stockqty']['checked'])) + { + print ''; + } // PMP value - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['estimatedvalue']['checked'])) + { + print ''; + } // Selling value - print ''; } - print ''; - if (!$i) $totalarray['nbfield']++; // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; @@ -446,8 +634,10 @@ if ($num) print $hookmanager->resPrint; // Status - print ''; - if (!$i) $totalarray['nbfield']++; + if (!empty($arrayfields['e.statut']['checked'])) + { + print ''; + } // Action column print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + if (!empty($arrayfields['e.lieu']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.description']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.address']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.zip']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.town']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.phone']['checked'])) + { + $emptyColumn++; + } + if (!empty($arrayfields['e.fax']['checked'])) + { + $emptyColumn++; + } + + for ($i=0; $i < $emptyColumn; $i++) + { + print ''; + } + + print ''; + + if (!empty($arrayfields['stockqty']['checked'])) + { + print ''; + } + if (!empty($arrayfields['estimatedvalue']['checked'])) + { + print ''; + } + + if (!empty($arrayfields['sellvalue']['checked'])) + { + print ''; + } + + if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey = $object->table_element; + if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label'])) + { + if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.'; + + foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) + { + if (!empty($arrayfields[$extrafieldsobjectprefix.$key]['checked'])) + { + print ''; + } + } + } + + if (!empty($arrayfields['e.statut']['checked'])) + { + print ''; + } + print ''; print "\n"; } diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index 8d98f028d23..36db491629f 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -52,7 +52,7 @@ $idline = GETPOST('idline'); $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (!$sortfield) { diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index b7746e81e66..c8567108d2d 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -72,7 +72,7 @@ $search_qty = trim(GETPOST("search_qty", 'alpha')); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index dea7580aeb7..f89788167b9 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -54,8 +54,11 @@ $ref = GETPOST('ref', 'alpha'); $msid = GETPOST('msid', 'int'); $product_id = GETPOST("product_id", 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist'; +$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list // Security check //$result=restrictedArea($user, 'stock', $id, 'entrepot&stock'); @@ -76,7 +79,7 @@ $search_qty = trim(GETPOST("search_qty")); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -123,15 +126,19 @@ if (!$user->rights->stock->mouvement->lire) { accessforbidden(); } +$permissiontoread = $user->rights->stock->mouvement->lire; +$permissiontoadd = $user->rights->stock->mouvement->creer; +$permissiontodelete = $user->rights->stock->mouvement->creer; // There is no deletion permission for stock movement as we shoul dnever delete + +$usercanread = $user->rights->stock->mouvement->lire; +$usercancreate = $user->rights->stock->mouvement->creer; +$usercandelete = $user->rights->stock->mouvement->creer; + /* * Actions */ -$usercanread = (($user->rights->stock->mouvement->lire)); -$usercancreate = (($user->rights->stock->mouvement->creer)); -$usercandelete = (($user->rights->stock->mouvement->supprimer)); - if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } @@ -139,26 +146,35 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - -// Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers +if (empty($reshook)) { - $year = ''; - $month = ''; - $search_ref = ''; - $search_movement = ""; - $search_type_mouvement = ""; - $search_inventorycode = ""; - $search_product_ref = ""; - $search_product = ""; - $search_warehouse = ""; - $search_user = ""; - $search_batch = ""; - $search_qty = ''; - $sall = ""; - $toselect = ''; - $search_array_options = array(); + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Do we click on purge search criteria ? + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers + { + $year = ''; + $month = ''; + $search_ref = ''; + $search_movement = ""; + $search_type_mouvement = ""; + $search_inventorycode = ""; + $search_product_ref = ""; + $search_product = ""; + $search_warehouse = ""; + $search_user = ""; + $search_batch = ""; + $search_qty = ''; + $sall = ""; + $toselect = ''; + $search_array_options = array(); + } + + // Mass actions + $objectclass = 'MouvementStock'; + $objectlabel = 'MouvementStock'; + $uploaddir = $conf->stock->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } // Correct stock @@ -600,8 +616,8 @@ if ($resql) $resqlbis = $db->query($sql); if ($resqlbis) { - $obj = $db->fetch_object($resqlbis); - $lastmovementdate = $db->jdate($obj->datem); + $objbis = $db->fetch_object($resqlbis); + $lastmovementdate = $db->jdate($objbis->datem); } else { @@ -694,8 +710,9 @@ if ($resql) // 'presend'=>$langs->trans("SendByMail"), // 'builddoc'=>$langs->trans("PDFMerge"), ); - //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + // By default, we should never accept deletion of stock movement. + if (! empty($conf->global->STOCK_ALLOW_DELETE_OF_MOVEMENT) && $permissiontodelete) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); + if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; @@ -713,6 +730,13 @@ if ($resql) if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit); + // Add code for pre mass action (confirmation or email presend form) + $topicmail = "SendStockMovement"; + $modelmail = "movementstock"; + $objecttmp = new MouvementStock($db); + $trackid = 'mov'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + if ($sall) { foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -961,6 +985,8 @@ if ($resql) $arrayofuniqueproduct = array(); + $i = 0; + $totalarray = array(); while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -1126,8 +1152,8 @@ if ($resql) if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print ''; + if (in_array($objp->mid, $arrayofselected)) $selected = 1; + print ''; } print ''; if (!$i) $totalarray['nbfield']++; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index af12804aac5..3feeb16cecb 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -917,7 +917,7 @@ if (!$variants) { print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); print ''; print ''; - print ''; print '
    '; -print ''; -print ''; -print ''; -print ''; + print ''; + print ''; + print ''; + print ''; -print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); -print ''; + print $form->selectarray('search_status', $warehouse->statuts, $search_status, 1, 0, 0, '', 1); + print ''; @@ -371,18 +449,65 @@ print '
    '.$warehouse->getNomUrl(1).''.$warehouse->getNomUrl(1).''.$obj->lieu.''.$obj->lieu.''.$obj->description.''.$obj->address.''.$obj->zip.''.$obj->town.''.$obj->phone.''.$obj->fax.''.price2num($obj->stockqty, 5).''.price2num($obj->stockqty, 5).''; - if (price2num($obj->estimatedvalue, 'MT')) print price(price2num($obj->estimatedvalue, 'MT'), 1); - else print ''; - print ''; + + if (price2num($obj->estimatedvalue, 'MT')) + { + print price(price2num($obj->estimatedvalue, 'MT'), 1); + } + else + { + print ''; + } + + print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($obj->sellvalue, 'MT'), 1); - else + if (!empty($arrayfields['sellvalue']['checked'])) { - $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + print ''; + + if (empty($conf->global->PRODUIT_MULTIPRICES)) + { + print price(price2num($obj->sellvalue, 'MT'), 1); + } + else + { + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + + print ''.$warehouse->LibStatut($obj->statut, 5).''.$warehouse->LibStatut($obj->statut, 5).''; @@ -469,18 +659,89 @@ if ($num) if ($totalnboflines - $offset <= $limit) { print '
    '.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); - else + + $emptyColumn = -1; + + if (!empty($arrayfields['e.ref']['checked'])) { - $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); - print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + $emptyColumn++; } - print ''.$langs->trans("Total").''.price2num($totalStock, 5).''.price(price2num($total, 'MT'), 1, $langs, 0, 0, -1, $conf->currency).''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) print price(price2num($totalsell, 'MT'), 1, $langs, 0, 0, -1, $conf->currency); + else + { + $htmltext = $langs->trans("OptionMULTIPRICESIsOn"); + print $form->textwithtooltip($langs->trans("Variable"), $htmltext); + } + print '
    '.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print ''; print '
    '; print ''; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index c3eb7523e7d..17004a39a71 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; // Load translation files required by the page -$langs->loadLangs(array('stock', 'other', 'productbatch')); +$langs->loadLangs(array('stocks', 'other', 'productbatch')); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 5fb9cc23bca..95bf0b7f5c4 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -57,7 +57,7 @@ $hookmanager->initHooks(array('productlotdocuments')); // Get parameters $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -$page = GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 4b36fda5ccb..5eedc40f40c 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -57,7 +57,7 @@ $optioncss = GETPOST('optioncss', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index bd7941e1448..0338a63745c 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -66,7 +66,7 @@ $texte = ''; $sortfield = GETPOST('sortfield', 'alpha'); $sortorder = GETPOST('sortorder', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; @@ -702,7 +702,10 @@ while ($i < ($limit ? min($num, $limit) : $num)) //depending on conf, use either physical stock or //virtual stock to compute the stock to buy value - $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); + + if(empty($usevirtualstock)) $stocktobuy = max(max($desiredstock, $alertstock) - $stock - $ordered, 0); + else $stocktobuy = max(max($desiredstock, $alertstock) - $stock, 0); //ordered is already in $stock in virtual mode + $disabled = ''; if ($ordered > 0) { diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index 5ca7debbef6..c1e1e157f79 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -46,7 +46,7 @@ $sref = GETPOST('search_ref', 'alpha'); $snom = GETPOST('search_nom', 'alpha'); $suser = GETPOST('search_user', 'alpha'); $sttc = GETPOST('search_ttc', 'alpha'); -$page = GETPOST('page', 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $sproduct = GETPOST('sproduct', 'int'); $search_dateyear = GETPOST('search_dateyear', 'int'); $search_datemonth = GETPOST('search_datemonth', 'int'); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 7f61b9d49ab..63115350bbc 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -85,16 +85,14 @@ $morehtml .= '