diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 00000000000..e5351acaf78 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,25 @@ +name: Qodana +on: + schedule: + - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop +# push: +# branches: +# - develop + +jobs: + qodana: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + #php-version: '7.1' + - name: 'Qodana Scan' + uses: JetBrains/qodana-action@v2022.3.2 + #with: + # php-version: '7.1' + env: + QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/doxygen-gh-pages.yml.disabled b/.github/workflows/doxygen-gh-pages.yml.disabled new file mode 100644 index 00000000000..33dd47aa6e6 --- /dev/null +++ b/.github/workflows/doxygen-gh-pages.yml.disabled @@ -0,0 +1,38 @@ +# See syntax file on https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions +name: Doxygen +on: + schedule: + - cron: "0 15 * * *" + workflow_dispatch: + branches: + - develop +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Build + uses: DenverCoder1/doxygen-github-pages-action@v1.2.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: build/html + config_file: build/doxygen/dolibarr-doxygen.doxyfile + +# - name: Deploy +# uses: JamesIves/github-pages-deploy-action@v4 +# with: +# branch: gh-pages +# folder: build/html # The folder the action should deploy. +# target-folder: docs/html2 + +#jobs: +# doxygen: +# runs-on: ubuntu-latest +# steps: +# - name: 'Doxygen' +# uses: mattnotmitt/doxygen-action@1.9.5 +# with: +# doxyfile-path: build/doxygen diff --git a/.github/workflows/exakat.yml b/.github/workflows/exakat.yml.disabled similarity index 93% rename from .github/workflows/exakat.yml rename to .github/workflows/exakat.yml.disabled index 528626e0308..1e9121a0e00 100644 --- a/.github/workflows/exakat.yml +++ b/.github/workflows/exakat.yml.disabled @@ -4,6 +4,9 @@ name: "Exakat analysis" on: schedule: - cron: "0 20 * * *" + workflow_dispatch: + branches: + - develop permissions: contents: read @@ -13,6 +16,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + fetch-depth: 1 - name: Exakat uses: docker://exakat/exakat-ga with: diff --git a/.github/workflows/stale-issues-safe.yml b/.github/workflows/stale-issues-safe.yml index 4ac9fa8f5b9..af04675d48d 100644 --- a/.github/workflows/stale-issues-safe.yml +++ b/.github/workflows/stale-issues-safe.yml @@ -6,7 +6,8 @@ on: - cron: "0 21 * * *" issue_comment: types: [created] - + workflow_dispatch: + permissions: {} # none jobs: diff --git a/.gitignore b/.gitignore index 55a4c417ce7..e9603bd2d8f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,6 @@ default.properties /.pydevproject /.vscode .DS_Store -.idea *.iml *.orig Thumbs.db diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000000..52e0bf0ae03 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.scrutinizer.yml b/.scrutinizer.yml index c1cb2e853f1..058a0ba8b48 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -8,21 +8,24 @@ build: override: - command: php-scrutinizer-run idle_timeout: 8000 + #- php-scrutinizer-run --sub-project-dir=htdocs/admin imports: - - javascript - php filter: excluded_paths: - - build/* - - dev/* - - doc/* - - documents/* - - node_modules/* - - test/* - dependency_paths: - - htdocs/includes/* + - build/ + - dev/ + - doc/ + - documents/ + - node_modules/ + - test/ + - htdocs/custom/ + - htdocs/includes/ + - htdocs/install/doctemplates/ + #dependency_paths: + # - htdocs/includes/ paths: - htdocs/* - scripts/* @@ -33,21 +36,23 @@ tools: enabled: true extensions: - php - dependency_paths: - - htdocs/includes/ + #dependency_paths: + # - htdocs/includes/ filter: excluded_paths: - - build/* - - dev/* - - doc/* - - documents/* - - htdocs/includes/* + - build/ + - dev/ + - doc/ + - documents/ + - htdocs/custom/ + - htdocs/includes/ + - htdocs/install/doctemplates/ - htdocs/core/class/lessc.class.php - - node_modules/* - - test/* + - node_modules/ + - test/ paths: - - htdocs/ - - scripts/ + - htdocs/* + - scripts/* config: parameter_reference_check: enabled: true @@ -156,73 +161,73 @@ tools: # To use specific config for a specific path, use path_configs: (see example on page https://scrutinizer-ci.com/docs/configuration/tool_config_structure) # php_depend - php_pdepend: - enabled: false - configuration_file: null - suffixes: - - php - excluded_dirs: { } - filter: - excluded_paths: - - 'build/*' - - 'dev/*' - - 'doc/*' - - 'test/*' - - 'htdocs/includes/*' - paths: { } + #php_pdepend: + # enabled: false + # configuration_file: null + # suffixes: + # - php + # excluded_dirs: { } + # filter: + # excluded_paths: + # - 'build/*' + # - 'dev/*' + # - 'doc/*' + # - 'test/*' + # - 'htdocs/includes/*' + # paths: { } # change tracking - php_changetracking: - enabled: false - bug_patterns: - - '\bfix(?:es|ed)?\b' - feature_patterns: - - '\badd(?:s|ed)?\b' - - '\bimplement(?:s|ed)?\b' - filter: - excluded_paths: - - 'build/*' - - 'dev/*' - - 'doc/*' - - 'documents/*' - - 'htdocs/includes/*' - - 'node_modules/*' - - 'test/*' - paths: { } + #php_changetracking: + # enabled: false + # bug_patterns: + # - '\bfix(?:es|ed)?\b' + # feature_patterns: + # - '\badd(?:s|ed)?\b' + # - '\bimplement(?:s|ed)?\b' + # filter: + # excluded_paths: + # - 'build/*' + # - 'dev/*' + # - 'doc/*' + # - 'documents/*' + # - 'htdocs/includes/*' + # - 'node_modules/*' + # - 'test/*' + # paths: { } # Similar code detection - php_sim: - enabled: false - min_mass: 30 - filter: - excluded_paths: - - 'build/*' - - 'dev/*' - - 'doc/*' - - 'documents/*' - - 'htdocs/includes/*' - - 'node_modules/*' - - 'test/*' - paths: { } + #php_sim: + # enabled: false + # min_mass: 30 + # filter: + # excluded_paths: + # - 'build/*' + # - 'dev/*' + # - 'doc/*' + # - 'documents/*' + # - 'htdocs/includes/*' + # - 'node_modules/*' + # - 'test/*' + # paths: { } # Coding-Style / Bug Detection - js_hint: - enabled: false - use_native_config: true - extensions: - - js - filter: - excluded_paths: - - 'build/*' - - 'dev/*' - - 'doc/*' - - 'documents/*' - - 'htdocs/includes/*' - - 'node_modules/*' - - 'test/*' - paths: { } - config: { } - path_configs: { } + #js_hint: + # enabled: false + # use_native_config: true + # extensions: + # - js + # filter: + # excluded_paths: + # - 'build/*' + # - 'dev/*' + # - 'doc/*' + # - 'documents/*' + # - 'htdocs/includes/*' + # - 'node_modules/*' + # - 'test/*' + # paths: { } + # config: { } + # path_configs: { } before_commands: { } diff --git a/.travis.yml b/.travis.yml index 6422e33a7e9..5380ef54d3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -95,19 +95,20 @@ notifications: install: - | - echo "Updating Composer" - rm $TRAVIS_BUILD_DIR/composer.json - rm $TRAVIS_BUILD_DIR/composer.lock + echo "Updating Composer config" composer -V - composer self-update - composer -n init - composer -n config vendor-dir htdocs/includes + #rm $TRAVIS_BUILD_DIR/composer.json + #rm $TRAVIS_BUILD_DIR/composer.lock + #composer -n init + #composer -n config vendor-dir htdocs/includes composer -n config -g vendor-dir htdocs/includes echo - | - echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" + echo "Update Composer version and Install tools - PHP Unit, Parallel Lint, PHP CodeSniffer, PHP Vardump check - for $TRAVIS_PHP_VERSION" + echo "(version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)" if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then + composer self-update 2.2.18 composer -n require phpunit/phpunit ^6 \ php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -115,6 +116,7 @@ install: squizlabs/php_codesniffer ^3 fi if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + composer self-update 2.2.18 composer -n require phpunit/phpunit ^7 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ @@ -123,12 +125,15 @@ install: fi # phpunit 9 is required for php 8 if [ "$TRAVIS_PHP_VERSION" = '8.0' ] || [ "$TRAVIS_PHP_VERSION" = '8.1' ] || [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer self-update 2.4.4 composer -n require --ignore-platform-reqs phpunit/phpunit ^8 \ php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-var-dump-check ~0.4 \ squizlabs/php_codesniffer ^3 fi + # Remove non expected files + rm -fr /home/travis/build/Dolibarr/dolibarr/htdocs/includes/phpunit/php-code-coverage/src/Report/Html/Renderer/Template/js echo - | @@ -450,6 +455,9 @@ script: php upgrade.php 16.0.0 17.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade16001700.log php upgrade2.php 16.0.0 17.0.0 > $TRAVIS_BUILD_DIR/upgrade16001700-2.log php step5.php 16.0.0 17.0.0 > $TRAVIS_BUILD_DIR/upgrade16001700-3.log + php upgrade.php 17.0.0 18.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade17001800.log + php upgrade2.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-2.log + php step5.php 17.0.0 18.0.0 > $TRAVIS_BUILD_DIR/upgrade17001800-3.log ls -alrt $TRAVIS_BUILD_DIR/ - | diff --git a/ChangeLog b/ChangeLog index 3d9b0b04e5a..00fbde60b91 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,11 +5,16 @@ English Dolibarr ChangeLog ***** ChangeLog for 18.0.0 compared to 17.0.0 ***** +NEW: PHP 8.2 compatibility: + + WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: -* The deprecated method escapeunderscore() of database handlers has been removed. You must use escapeforlike instead. - +* The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead. +* The method "nb_expedition()" has been renamed into "countNbOfShipments()" +* Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated). +* Deprecated property libelle removed from entrepot class. @@ -19,10 +24,10 @@ For users: --------------- NEW: Minimal PHP version is now PHP 7.0 instead of PHP 5.6 -NEW: #21780 Add pid field to Cronjob class and store PID on job execution NEW: #19680 Add option PRODUCT_ALLOW_EXTERNAL_DOWNLOAD to automatically have uploaded files shared publicly by a link -NEW: #20650 can move the checkbox column on left (experimental option) +NEW: #20650 can move the checkbox column on left (experimental option MAIN_CHECKBOX_LEFT_COLUMN) NEW: #21000 Added columns 'alias_name' on project, supplier invoice, supplier order, supplier proposals and task list +NEW: #21780 Add pid field to Cronjob class and store PID on job execution NEW: #21395 Added option for dark theme mode in display - color and theme NEW: #21397 added option to auto define barcode numbers for third-parties in barcode module setup NEW: #21399 @@ -41,166 +46,180 @@ NEW: #22676 massaction for updating product prices NEW: #22735 Massaction to affect users on projects NEW: #25594 can chose if VAT ID is unique or not for third parties NEW: #4482 adding js to hide/show advanced option on the export data page -NEW: Accountancy - Add a graphic option to enable lettering function - FPC21 -NEW: Accountancy - Add a way to clean some words when you generate thirdparty accounting account -NEW: Accountancy - Added an option during export to export or not the lettering FPC21 -NEW: Accountancy - Manage supplier deposit with specific account -NEW: Accountancy - Model Digitaria - Add a way to clean some words when you generate thirdparty accounting account FPC22 -NEW: Add a button "Test collect" in email collector + NEW: Add a constant to disallow modification of the product reference. -NEW: Add a method doAutoRenewContracts that can be used as a cron task. -NEW: Add " as enclosure by default for CSV export. Keep removing CR/LF. NEW: add attached file in presend email form of thirdparty card NEW: Add a way to enter LICENSE file content in property of website -NEW: Add badge in admin extrafields setup -NEW: add constant PROPAL_BYPASS_VALIDATED_STATUS -NEW: Add date event (!= date project) and location on event organization NEW: Add employment anniversary in birthday box -NEW: Add extrafield type "IP" to store IP addresses -NEW: Add fail2ban rules examples to limit access to /public pages -NEW: Add filter "Product subject to lot/Serial" in stock per lot/serial NEW: Add hidden option MAIN_EMAIL_SUPPORT_ACK to restore Email ack checkbox (feature abandonned by mailers) -NEW: Add IMAP port setting on email collector module -NEW: Adding JAPAN Chart-of-Account and regions/departments -NEW: Adding NIF verification for Algeria NEW: Add link to create an element from the category page -NEW: add margin infos to takepos invoice lines NEW: Add max size send for "backup and link to mail" option NEW: Add method httponly_accessforbidden() NEW: Add more advices into the Setup security page NEW: Add new global variable for keeping the previous signature information on proposale (case of reopen a proposale) NEW: Add objectLink on expedition NEW: Add oldcopy to Ticket so triggers intercepting TICKET_MODIFY have access to old values of the updated properties -NEW: Add option FICHINTER_ALLOW_EXTERNAL_DOWNLOAD NEW: Add option --force on CLI cron_run_jobs.php NEW: Add option "Show price on the generated documents for receptions" -NEW: Add performance index (name for company and contact) and llx_bank_url(url_id) -NEW: Add picto property on sub-module for password generation -NEW: add redirect on action confirm addconsumedline and addproduceline -NEW: Add a new advanced permission "read price" -NEW: Add substitution key __SENDEREMAIL_SIGNATURE__ -NEW: Add the referrer-policy to "same-origin" by default on all public pages. -NEW: Add the SMTP header References on ticket email created by email -NEW: Add the thirdparty column to the time list (projet/tasks/time.php) -NEW: Add trigger to record the event of sending an email from a project #20912 -NEW: Allow download link option in module configuration (propal,invoice,supplier proposal, order) -NEW: Bank - Add salaries & vat in tab planned entries -NEW: Bulk action to remove a category in list/search website pages -NEW: Can copy/paste images into emails sent. -NEW: Can edit label of an emailing even once sent -NEW: Can edit property css, cssview, csslist on extrafields -NEW: Can enter the unit price including the vat -NEW: Can invoice task time per different services -NEW: Can join several files by default on email form -NEW: Can send an email on scheduled job error -NEW: Can set a commercial discount by entering amount including VAT -NEW: Can set a monthly frequency (or multiple) in cron tasks. -NEW: Can set start and end dates and comment on button "Activate all services" -NEW: can sort and preselected best supplier price -NEW: Can use products categories to make inventory -NEW: Change filter type on tickets list into a multiselect combo -NEW: conf TIMESPENT_ALWAYS_UPDATE_THM, when it's on we always check current thm of user to update it in task time line -NEW: constant PROPAL_NEW_AS_SIGNED -NEW: show date delivery planned on orders linked to company and product -NEW: Default template of contract is not mandatory -NEW: Default values in extrafields are not more limited to 255 char. -NEW: display currency in takepos menu -NEW: Enable online signature for interventions -NEW: Encrypt all sensitive constants in llx_const -NEW: extrafield price with currency -NEW: filter on reception dates (from / to) in cheque paiement card -NEW: Members: default_lang for members -NEW: Members: Table of membership types -NEW: Members: add free membership amounts at the membership type level -NEW: TakePOS: Header Scroll in TakePOS -NEW: TakePOS: add price to product box in TakePOS -NEW: TakePOS: add setup parameters, can setup terminal name -NEW: TakePOS: support of Stripe Terminal with TakePOS -NEW: TakePOS: Receipt preview in TakePOS setup -NEW: TakePOS: different product list on smartphone -NEW: Website: can delete a whole website if disabled -NEW: Website: can remove a website template -NEW: Website: can set header "Strict-Transport-Security" in web sites. -NEW: Website: can switch status of website and page from the website toolbar -NEW: Website: Templates of websites are now directories and not zip into core repo -NEW: Website: add 4 other templates in website module -NEW: If we select another view list mode, we keep it -NEW: Init module bookcal -NEW: Introduce dolEncrypt and dolDecrypt to be able to encrypt data in db -NEW: Invoice - Add french mention on pdf when vat debit option is on NEW: invoice export : add accounting affectation NEW: label on products categories filter -NEW: The link "add to bookmark" is always on top in the bookmark popup -NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS const to show category customer filter -NEW: Make module WebservicesClient deprecated. Use module WebHook instead. NEW: manage no email with thirdparties (better for GDPR) -NEW: Manage Position (Rank) on Contract Lines NEW: Manage VAT on all lines on purchases cycle -NEW: manage virtual stock at a future date NEW: On a bank reconciled line, we can modify the bank receipt -NEW: On a form to send an email, we show all emails of all contacts of object -NEW: Option PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT showing wh on PDF -NEW: Option PRODUIT_DESC_IN_FORM accept (desktop only or +smartphone) -NEW: Page for mass stock transfer can be used with no source stock NEW: parent company column and filter in invoice and order list -NEW: Add show "Sales rep" option for PDF -NEW: Picto for shared link is clickable NEW: possibility to select scopes with checkbox for Oauth tokens NEW: private and public note on user, thirdparty and contact list -NEW: product categories filter on inventory list -NEW: Product supplier price: autofill default supplier VAT -NEW: Project - Add author on list NEW: Public counters feature -NEW: Reception - Add a from/to on search on date field -NEW: Start a simple support of recurrent events on agenda -NEW: Resize parent company column in order list NEW: Saved token of OAUTH module are now encrypted into llx_oauth_token NEW: Save one click to select on delivery ack, on emails. NEW: scheduled job to send unpaid invoice reminder can now use the cc and bcc from email template -NEW: set thirdparty type with company modify trigger -NEW: Show also scheduled task never finished in scheduled task widget -NEW: show badge with number of extrafields in setup -NEW: show category tree in sellist and chkbxlst for common object -NEW: Show picto and color into combo for selection of tags -NEW: show product label on inventory -NEW: show sell-by and eat-by dates only if not empty -NEW: show SellBy/EatBy dates for each batch product in shipment card -NEW: skip accept/refuse process for proposals (option PROPAL_SKIP_ACCEPT_REFUSE) -NEW: SMTP using oauth2 authentication +NEW: experimental SMTP using PhpImap allowing OAuth2 authentication (need to add option MAIN_IMAP_USE_PHPIMAP) NEW: can substitue project title in mail template -NEW: Supplier order list - Add column private and public note -NEW: Support IP type in extrafields NEW: The purge of files can purge only if older than a number of seconds NEW: Update ActionComm type_code on email message ticket -NEW: VAT - Admin - Add information on deadline day for submission of VAT declaration -NEW: expand/collapse permissions on user permission page -NEW: Show delivery mode on PDF for proposals +NEW: Finance - VAT - Admin - Add information on deadline day for submission of VAT declaration NEW: Add the target to select attendees of event for emailings +NEW: add redirect on action confirm addconsumedline and addproduceline +NEW: Add the referrer-policy to "same-origin" by default on all public pages. +NEW: Add trigger to record the event of sending an email from a project #20912 +NEW: Allow download link option in module configuration (propal, order, invoice, supplier proposal) +NEW: Can enter the unit price including the VAT +NEW: Can invoice task time per different services +NEW: Can set a commercial discount by entering amount including VAT +NEW: Can set start and end dates and comment on button "Activate all services" +NEW: can sort and preselected best supplier price +NEW: show date delivery planned on orders linked to company and product +NEW: filter on reception dates (from / to) in cheque paiement card + +NEW: Accountancy - Add a graphic option to enable lettering function - FPC21 +NEW: Accountancy - Add a way to clean some words when you generate thirdparty accounting account +NEW: Accountancy - Added an option during export to export or not the lettering FPC21 +NEW: Accountancy - Manage supplier deposit with specific account +NEW: Accountancy - Model Digitaria - Add a way to clean some words when you generate thirdparty accounting account FPC22 +NEW: Agenda - start a simple support of recurrent events on agenda +NEW: Bank - add salaries & VAT in tab planned entries +NEW: Contracts - add a method doAutoRenewContracts that can be used as a cron task +NEW: Contracts - default template of contract is not mandatory +NEW: Contracts - Manage Position (Rank) on Contract Lines +NEW: EMail - can copy/paste images into emails sent +NEW: EMail - can edit label of an emailing even once sent +NEW: EMail - can join several files by default on email form +NEW: EMail - can send an email on scheduled job error +NEW: EMail - on a form to send an email, we show all emails of all contacts of object +NEW: EMail - add the SMTP header References on ticket email created by email +NEW: EMail - add substitution key __SENDEREMAIL_SIGNATURE__ +NEW: EMail-Collector - add IMAP port setting +NEW: EMail-Collector - add a button "Test collect" +NEW: Export - Add " as enclosure by default for CSV export. Keep removing CR/LF. +NEW: Event-Organization - add date event (!= date project) and location on event organization +NEW: Extrafields - add badge in admin extrafields setup +NEW: Extrafields - can edit property css, cssview, csslist on extrafields +NEW: Extrafields - default values in extrafields are not more limited to 255 char. +NEW: Extrafields - field price with currency +NEW: Extrafields - support IP type to store IP addresses +NEW: Interventions - enable online signature for interventions +NEW: Invoice - Add french mention on pdf when vat debit option is on +NEW: Members - default_lang for members +NEW: Members - Table of membership types +NEW: Members - add free membership amounts at the membership type level +NEW: Orders - resize parent company column in order list +NEW: Products supplier price - autofill default supplier VAT +NEW: Projects - add author on list +NEW: Projects - add thirdparty column to the time list (projet/tasks/time.php) +NEW: Proposals - show delivery mode on PDF for proposals +NEW: Proposals - skip accept/refuse process for proposals (option PROPAL_SKIP_ACCEPT_REFUSE) +NEW: Reception - add a from/to on search on date field +NEW: Stock - page for mass stock transfer can be used with no source stock +NEW: Stock - product categories filter on inventory list +NEW: Stock - show product label on inventory +NEW: Stock - manage virtual stock at a future date +NEW: Stock Inventory - add filter "Product subject to lot/Serial" in stock per lot/serial +NEW: Stock Inventory - can use products categories to make inventory +NEW: Supplier Order List - add column private and public note +NEW: TakePOS - add margin infos to TakePOS invoice lines +NEW: TakePOS - add price to product box in TakePOS +NEW: TakePOS - add setup parameters, can setup terminal name +NEW: TakePOS - different product list on smartphone +NEW: TakePOS - display currency in TakePOS menu +NEW: TakePOS - Header Scroll in TakePOS +NEW: TakePOS - Receipt preview in TakePOS setup +NEW: TakePOS - support of Stripe Terminal with TakePOS +NEW: Thirdparty - set thirdparty type with company modify trigger +NEW: Tickets - change filter type on tickets list into a multiselect combo +NEW: Website - can delete a whole website if disabled +NEW: Website - can remove a website template +NEW: Website - can set header "Strict-Transport-Security" in web sites. +NEW: Website - can switch status of website and page from the website toolbar +NEW: Website - Templates of websites are now directories and not zip into core repo +NEW: Website - add 4 other templates in website module + +General: +NEW: Actions: Bulk action to remove a category in list/search website pages +NEW: Cronjobs: can set a monthly frequency (or multiple) in cron tasks +NEW: Database: Encrypt all sensitive constants in llx_const +NEW: Database: Add performance index (name for company and contact) and llx_bank_url(url_id) +NEW: Database: Introduce dolEncrypt and dolDecrypt to be able to encrypt data in db +NEW: GUI: If we select another view list mode, we keep it +NEW: GUI: the link "add to bookmark" is always on top in the bookmark popup +NEW: GUI: Picto for shared link is clickable +NEW: GUI: add picto property on sub-module for password generation +NEW: GUI: show also scheduled task never finished in scheduled task widget +NEW: GUI: show badge with number of extrafields in setup +NEW: GUI: show category tree in sellist and chkbxlst for common object +NEW: GUI: show picto and color into combo for selection of tags +NEW: GUI: show sell-by and eat-by dates only if not empty +NEW: GUI: show SellBy/EatBy dates for each batch product in shipment card +NEW: GUI/Permissions: expand/collapse permissions on user permission page +NEW: Permissions: add a new advanced permission "read price" +NEW: Print: add show "Sales rep" option for PDF +NEW: Security: add fail2ban rules examples to limit access to /public pages + + Option / Const for System: +NEW: FICHINTER_ALLOW_EXTERNAL_DOWNLOAD +NEW: MAIN_SEARCH_CATEGORY_PRODUCT_ON_LISTS - const to show category customer filter +NEW: PRODUCTBATCH_SHOW_WAREHOUSE_ON_SHIPMENT - showing warehouse on PDF +NEW: PRODUIT_DESC_IN_FORM accept - desktop only or +smartphone +NEW: PROPAL_BYPASS_VALIDATED_STATUS +NEW: PROPAL_NEW_AS_SIGNED +NEW: TIMESPENT_ALWAYS_UPDATE_THM - when it's on we always check current thm of user to update it in task time line + + Localisation: +NEW: adding JAPAN Chart-of-Account and regions/departments +NEW: adding NIF verification for Algeria Modules NEW: Experimental module Asset +NEW: Init module bookcal +NEW: Make module WebservicesClient deprecated. Use module WebHook instead. + For developers or integrators: ------------------------------ NEW: ModuleBuilder can generate code of class from an existing SQL table -NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields) NEW: #20912 Add trigger to record the event of sending an email from a project NEW: #21750 Added "Get lines and Post lines from BOM" at the REST Service -NEW: Removed completely the need for the library adodbtime -NEW: hook on agenda pages -NEW: hook to complete payment in TakePOS -NEW: hook "changeHelpURL" to modify target of the help button -NEW: hook formConfirm on action comm card -NEW: hook to modify supplier product html select -NEW: Add new hook for show virtual stock details on product stock card -NEW: Add new hooks for actioncomm +NEW: #22370 Modulebuilder supports 'alwayseditable' (like extrafields) NEW: conf->global->SYSLOG_FILE_ONEPERSESSION accept a string -NEW: translate for contact type API, setup/ticket API, shipping method API NEW: All ajax pages have now a top_httphead() -NEW: support multilang in Civilities API + + API: NEW: Add API for the partnership module NEW: Add "Get lines and Post lines from BOM" in the API +NEW: translate for contact type API, setup/ticket API, shipping method API +NEW: support multilang in Civilities API + + Hooks: +NEW: Actioncomm - add new hooks for actioncomm +NEW: Actioncomm - hook formConfirm on actioncomm card +NEW: Agenda - hook on agenda pages +NEW: Help - hook "changeHelpURL" to modify target of the help button +NEW: Product - add hook to show virtual stock details on product stock card +NEW: Product - add hook to modify supplier product html select +NEW: TakePOS - add hook to complete payment in TakePOS + + +NEW: Removed completely the need for the library adodbtime NEW: Replace fk_categories_product with categories_product in inventory NEW: Rewrite of SQL request. Removed the join on category (for filter on categ), replaced with a EXISTS/NOT @@ -219,6 +238,39 @@ Following changes may create regressions for some external modules, but were nec * Rename the substitution for project label instead of project title in substitution variables +***** ChangeLog for 16.0.4 compared to 16.0.2 ***** + +FIX: Amount of localtax1 and 2 not correctly save on purchase order (the rate was saved instead) +FIX: #20415 +FIX: #21280 +FIX: #23008 +FIX: #22271 +FIX: #22837 +FIX: #23019 Impossible to add task times to an existing draft invoice +FIX: #23072 +FIX: #23087 +FIX: #23115 +FIX: #23116 +FIX: #23281 +FIX: bad selection of barcode numbering module +FIX: Can't see all time spent by all user +FIX: CI +FIX: CommonObject - showOptionals - Display blank td when MAIN_VIEW_LINE_NUMBER is enabled and action is confirm_valid +FIX: Documents API inconsistency +FIX: #23075 +FIX: #23117 +FIX: get multicurrency infos of propal when create order from propal with "WORKFLOW_PROPAL_AUTOCREATE_ORDER" conf +FIX: Give predictable order to inventory lines +FIX: include class multicurrency +FIX: methods declaration (backport fix 67b9a7dc07d708231d12b5e58800334d4a01ef98) +FIX: multicurrency_tx and not currency_tx +FIX: PGSQL Integer type does not have a free length +FIX: Product list in setup.php in new Module +FIX: propal and order stats broken on Tag+User(retricted customer list) +FIX: saving of numbering module for jobs +FIX: Stickler +FIX: travis + ***** ChangeLog for 16.0.3 compared to 16.0.2 ***** FIX: $sign is useless diff --git a/SECURITY.md b/SECURITY.md index b121b606180..e095b64fdff 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -53,16 +53,17 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us * $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value) * $dolibarr_main_force_https must be set to something else than 0. * The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 3 into backoffice menu Home - Setup - Other (this protection should be set to 3 soon by default) -* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities). * The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer). * The web server setup must be done so that only the documents directory is in write mode. The root directory called htdocs must be read-only. * CSRF attacks are accepted but double check that you have set MAIN_SECURITY_CSRF_WITH_TOKEN to value 3. +* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools) * Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user. +* Fail2ban rules for rate limit on the login page,password forgotten page and all public pages (/public/*) must be installed as recommendend into the section "About - Admin tools - Section Access limits and mitigation". Scope is the web application (back office) and the APIs. -## Qualifying vulnerabilities for reporting +## Example of vulnerabilities Qualified for reporting. * Remote code execution (RCE) * Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA) @@ -78,7 +79,7 @@ Scope is the web application (back office) and the APIs. * Software version disclosure (for non admin users only) * Stack traces or path disclosure (for non admin users only) -## Non-qualifying vulnerabilities for reporting +## Example of vulnerabilities non Non-qualified for reporting. * "Self" XSS * SSL/TLS best practices @@ -95,3 +96,4 @@ Scope is the web application (back office) and the APIs. * Software version or private IP disclosure when logged user is admin * Stack traces or path disclosure when logged user is admin * Any vulnerabilities due to a configuration different than the one defined into chapter "Scope for qualified vulnerabilities". +* Brute force attacks on login page, password forgotten page or any public pages (/public/*) are not qualified if the fail2ban recommended fail2ban rules were not installed. diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index ead2a8af1c5..69f4d27b26f 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.3-apache +FROM php:8.1-apache-bullseye ENV PHP_INI_DATE_TIMEZONE 'UTC' ENV PHP_INI_MEMORY_LIMIT 256M @@ -25,7 +25,7 @@ RUN apt-get update -y \ mailutils \ && apt-get autoremove -y \ && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ + && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) calendar intl mysqli pdo_mysql gd soap zip \ && docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \ && docker-php-ext-install -j$(nproc) ldap && \ diff --git a/build/docker/README.md b/build/docker/README.md index d469c7c7aae..007b5db6ace 100644 --- a/build/docker/README.md +++ b/build/docker/README.md @@ -25,7 +25,7 @@ The URL to go to the Dolibarr is : The URL to go to PhpMyAdmin is (login/password is root/root) : http://0.0.0.0:8080 - + In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev http://0.0.0.0:8081 diff --git a/build/docker/docker-compose.yml b/build/docker/docker-compose.yml index 8994043cd8a..e197d5dd06e 100644 --- a/build/docker/docker-compose.yml +++ b/build/docker/docker-compose.yml @@ -34,6 +34,8 @@ services: build: . environment: HOST_USER_ID: $HOST_USER_ID + PHP_INI_DATE_TIMEZONE: $PHP_INI_DATE_TIMEZONE + PHP_INI_MEMORY_LIMIT: $PHP_INI_MEMORY_LIMIT volumes: - ../../htdocs:/var/www/html/ - ../../documents:/var/documents diff --git a/build/docker/docker-run.sh b/build/docker/docker-run.sh index 4e69ea4a3a2..fbd256ab625 100644 --- a/build/docker/docker-run.sh +++ b/build/docker/docker-run.sh @@ -15,10 +15,10 @@ fi echo "[docker-run] => Set Permission to www-data for /var/documents" chown -R www-data:www-data /var/documents -if [ ! -f /usr/local/etc/php/php.ini ]; then - cat < /usr/local/etc/php/php.ini -date.timezone = $PHP_INI_DATE_TIMEZONE +echo "[docker-run] => update ${PHP_INI_DIR}/conf.d/dolibarr-php.ini" +cat < ${PHP_INI_DIR}/conf.d/dolibarr-php.ini +date.timezone = ${PHP_INI_DATE_TIMEZONE:-UTC} +memory_limit = ${PHP_INI_MEMORY_LIMIT:-256M} EOF -fi exec apache2-foreground diff --git a/build/doxygen/dolibarr-doxygen-build.pl b/build/doxygen/dolibarr-doxygen-build.pl index 75a5cceddbe..5a4849a3a5b 100755 --- a/build/doxygen/dolibarr-doxygen-build.pl +++ b/build/doxygen/dolibarr-doxygen-build.pl @@ -17,9 +17,9 @@ use Cwd; my $dir = getcwd; print "Current dir is: $dir\n"; -print "Running dir for doxygen must be: $DIR\n"; +#print "Running dir for doxygen must be: $DIR\n"; -if (! -s $CONFFILE) +if (! -s "build/doxygen/$CONFFILE") { print "Error: current directory for building Dolibarr doxygen documentation is not correct.\n"; print "\n"; @@ -30,7 +30,7 @@ if (! -s $CONFFILE) exit 1; } -$SOURCE="../.."; +$SOURCE="."; # Get version $MAJOR, $MINOR and $BUILD $result = open( IN, "< " . $SOURCE . "/htdocs/filefunc.inc.php" ); @@ -47,8 +47,8 @@ $version=$MAJOR.".".$MINOR.".".$BUILD; print "Running doxygen for version ".$version.", please wait...\n"; -print "cat $CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; -$result=`cat $CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; +print "cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/".$version."/' | doxygen $OPTIONS - 2>&1\n"; +$result=`cat build/doxygen/$CONFFILE | sed -e 's/x\.y\.z/$version/' | doxygen $OPTIONS - 2>&1`; print $result; diff --git a/build/doxygen/dolibarr-doxygen.doxyfile b/build/doxygen/dolibarr-doxygen.doxyfile index 31400661ecc..6f668ebad7e 100644 --- a/build/doxygen/dolibarr-doxygen.doxyfile +++ b/build/doxygen/dolibarr-doxygen.doxyfile @@ -1,14 +1,17 @@ -# Doxyfile 1.7.3 +# Doxyfile 1.8.16 # This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project +# doxygen (www.doxygen.org) for a project. # -# All text after a hash (#) is considered a comment and will be ignored +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. # The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). #--------------------------------------------------------------------------- # Project related configuration options @@ -38,7 +41,7 @@ PROJECT_NUMBER = x.y.z # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = ../../build +OUTPUT_DIRECTORY = build # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -114,7 +117,7 @@ FULL_PATH_NAMES = YES # If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = "../.." +STRIP_FROM_PATH = "/home/dolibarr/doxygen.dolibarr.org/" # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells @@ -287,7 +290,7 @@ TYPEDEF_HIDES_STRUCT = NO # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols -SYMBOL_CACHE_SIZE = 0 +#SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options @@ -448,7 +451,7 @@ GENERATE_TODOLIST = NO # disable (NO) the test list. This list is created by putting \test # commands in the documentation. -GENERATE_TESTLIST = YES +GENERATE_TESTLIST = NO # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug @@ -487,7 +490,7 @@ SHOW_USED_FILES = YES # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = YES +#SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the @@ -571,7 +574,7 @@ WARN_FORMAT = "$file:$line: $text" # and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = doxygen_warnings.log +WARN_LOGFILE = build/html/doxygen_warnings.log #--------------------------------------------------------------------------- # configuration options related to the input files @@ -582,7 +585,7 @@ WARN_LOGFILE = doxygen_warnings.log # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = ../../htdocs ../../scripts +INPUT = htdocs scripts # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -611,7 +614,7 @@ RECURSIVE = YES # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = ../../build ../../dev ../../doc ../../document ../../documents ../../htdocs/conf/conf.php ../../htdocs/custom ../../htdocs/document ../../htdocs/documents ../../htdocs/includes +EXCLUDE = build dev doc document documents htdocs/conf/conf.php htdocs/custom htdocs/document htdocs/documents htdocs/includes htdocs/install/doctemplates # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -625,7 +628,7 @@ EXCLUDE_SYMLINKS = YES # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = */CVS/* *google* *pibarcode* +EXCLUDE_PATTERNS = */CVS/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -639,27 +642,27 @@ EXCLUDE_SYMBOLS = # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = ../../htdocs/modulebuilder/template +#EXAMPLE_PATH = htdocs/modulebuilder/template # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = *.php +#EXAMPLE_PATTERNS = *.php # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = NO +#EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = ../../doc/images +IMAGE_PATH = doc/images # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -762,7 +765,7 @@ ALPHABETICAL_INDEX = YES # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 5 +#COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. @@ -775,14 +778,16 @@ IGNORE_PREFIX = # configuration options related to the HTML output #--------------------------------------------------------------------------- -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. +# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output +# The default value is: YES. GENERATE_HTML = YES -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a +# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of +# it. +# The default directory is: html. +# This tag requires that the tag GENERATE_HTML is set to YES. HTML_OUTPUT = html @@ -797,14 +802,14 @@ HTML_FILE_EXTENSION = .html # standard header. # Does not work with 1.7.3 -#HTML_HEADER = doxygen_header.html +#HTML_HEADER = build/doxygen/doxygen_header.html # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. # Does not work with 1.7.3 -HTML_FOOTER = doxygen_footer.html +HTML_FOOTER = build/doxygen/doxygen_footer.html # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to @@ -850,7 +855,18 @@ HTML_TIMESTAMP = YES # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. -HTML_ALIGN_MEMBERS = YES +#HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML +# documentation will contain a main index with vertical navigation menus that +# are dynamically created via Javascript. If disabled, the navigation index will +# consists of multiple levels of tabs that are statically embedded in every HTML +# page. Disable this option to support browsers that do not have Javascript, +# like the Qt help browser. +# The default value is: YES. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_DYNAMIC_MENUS = NO # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the @@ -858,7 +874,7 @@ HTML_ALIGN_MEMBERS = YES # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). -HTML_DYNAMIC_SECTIONS = YES +HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 @@ -1003,7 +1019,7 @@ QHG_LOCATION = # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. -GENERATE_ECLIPSEHELP = YES +GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have @@ -1035,7 +1051,7 @@ GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. -USE_INLINE_TREES = NO +#USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree @@ -1072,7 +1088,7 @@ FORMULA_TRANSPARENT = YES # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. -SEARCHENGINE = NO +SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client @@ -1082,7 +1098,7 @@ SEARCHENGINE = NO # full text search. The disadvances is that it is more difficult to setup # and does not have live searching capabilities. -SERVER_BASED_SEARCH = NO +SERVER_BASED_SEARCH = YES #--------------------------------------------------------------------------- # configuration options related to the LaTeX output @@ -1260,13 +1276,13 @@ XML_OUTPUT = xml # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_SCHEMA = +#XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. -XML_DTD = +#XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting @@ -1431,7 +1447,7 @@ EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +#PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool @@ -1453,7 +1469,7 @@ CLASS_DIAGRAMS = NO # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. -MSCGEN_PATH = +#MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented @@ -1485,7 +1501,7 @@ DOT_NUM_THREADS = 0 # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. -DOT_FONTNAME = FreeSans.ttf +#DOT_FONTNAME = FreeSans.ttf # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. @@ -1634,3 +1650,7 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES + + +FULL_SIDEBAR = NO +HTML_EXTRA_STYLESHEET = build/doxygen/doxygen-awesome.css diff --git a/build/doxygen/doxygen-awesome.css b/build/doxygen/doxygen-awesome.css new file mode 100644 index 00000000000..0b1c8c20892 --- /dev/null +++ b/build/doxygen/doxygen-awesome.css @@ -0,0 +1,2413 @@ +/** + +Doxygen Awesome +https://github.com/jothepro/doxygen-awesome-css + +MIT License + +Copyright (c) 2021 - 2022 jothepro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +*/ + +html { + /* primary theme color. This will affect the entire websites color scheme: links, arrows, labels, ... */ + --primary-color: #1779c4; + --primary-dark-color: #335c80; + --primary-light-color: #70b1e9; + + /* page base colors */ + --page-background-color: #ffffff; + --page-foreground-color: #2f4153; + --page-secondary-foreground-color: #6f7e8e; + + /* color for all separators on the website: hr, borders, ... */ + --separator-color: #dedede; + + /* border radius for all rounded components. Will affect many components, like dropdowns, memitems, codeblocks, ... */ + --border-radius-large: 8px; + --border-radius-small: 4px; + --border-radius-medium: 6px; + + /* default spacings. Most components reference these values for spacing, to provide uniform spacing on the page. */ + --spacing-small: 5px; + --spacing-medium: 10px; + --spacing-large: 16px; + + /* default box shadow used for raising an element above the normal content. Used in dropdowns, search result, ... */ + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.075); + + --odd-color: rgba(0,0,0,.028); + + /* font-families. will affect all text on the website + * font-family: the normal font for text, headlines, menus + * font-family-monospace: used for preformatted text in memtitle, code, fragments + */ + --font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif; + --font-family-monospace: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + + /* font sizes */ + --page-font-size: 15.6px; + --navigation-font-size: 14.4px; + --toc-font-size: 13.4px; + --code-font-size: 14px; /* affects code, fragment */ + --title-font-size: 22px; + + /* content text properties. These only affect the page content, not the navigation or any other ui elements */ + --content-line-height: 27px; + /* The content is centered and constraint in it's width. To make the content fill the whole page, set the variable to auto.*/ + --content-maxwidth: 1050px; + --table-line-height: 24px; + --toc-sticky-top: var(--spacing-medium); + --toc-width: 200px; + --toc-max-height: calc(100vh - 2 * var(--spacing-medium) - 85px); + + /* colors for various content boxes: @warning, @note, @deprecated @bug */ + --warning-color: #f8d1cc; + --warning-color-dark: #b61825; + --warning-color-darker: #75070f; + --note-color: #faf3d8; + --note-color-dark: #f3a600; + --note-color-darker: #5f4204; + --todo-color: #e4f3ff; + --todo-color-dark: #1879C4; + --todo-color-darker: #274a5c; + --deprecated-color: #ecf0f3; + --deprecated-color-dark: #5b6269; + --deprecated-color-darker: #43454a; + --bug-color: #e4dafd; + --bug-color-dark: #5b2bdd; + --bug-color-darker: #2a0d72; + --invariant-color: #d8f1e3; + --invariant-color-dark: #44b86f; + --invariant-color-darker: #265532; + + /* blockquote colors */ + --blockquote-background: #f8f9fa; + --blockquote-foreground: #636568; + + /* table colors */ + --tablehead-background: #f1f1f1; + --tablehead-foreground: var(--page-foreground-color); + + /* menu-display: block | none + * Visibility of the top navigation on screens >= 768px. On smaller screen the menu is always visible. + * `GENERATE_TREEVIEW` MUST be enabled! + */ + --menu-display: block; + + --menu-focus-foreground: var(--page-background-color); + --menu-focus-background: var(--primary-color); + --menu-selected-background: rgba(0,0,0,.05); + + + --header-background: var(--page-background-color); + --header-foreground: var(--page-foreground-color); + + /* searchbar colors */ + --searchbar-background: var(--side-nav-background); + --searchbar-foreground: var(--page-foreground-color); + + /* searchbar size + * (`searchbar-width` is only applied on screens >= 768px. + * on smaller screens the searchbar will always fill the entire screen width) */ + --searchbar-height: 33px; + --searchbar-width: 210px; + --searchbar-border-radius: var(--searchbar-height); + + /* code block colors */ + --code-background: #f5f5f5; + --code-foreground: var(--page-foreground-color); + + /* fragment colors */ + --fragment-background: #F8F9FA; + --fragment-foreground: #37474F; + --fragment-keyword: #bb6bb2; + --fragment-keywordtype: #8258b3; + --fragment-keywordflow: #d67c3b; + --fragment-token: #438a59; + --fragment-comment: #969696; + --fragment-link: #5383d6; + --fragment-preprocessor: #46aaa5; + --fragment-linenumber-color: #797979; + --fragment-linenumber-background: #f4f4f5; + --fragment-linenumber-border: #e3e5e7; + --fragment-lineheight: 20px; + + /* sidebar navigation (treeview) colors */ + --side-nav-background: #fbfbfb; + --side-nav-foreground: var(--page-foreground-color); + --side-nav-arrow-opacity: 0; + --side-nav-arrow-hover-opacity: 0.9; + + --toc-background: var(--side-nav-background); + --toc-foreground: var(--side-nav-foreground); + + /* height of an item in any tree / collapsable table */ + --tree-item-height: 30px; + + --memname-font-size: var(--code-font-size); + --memtitle-font-size: 18px; + + --webkit-scrollbar-size: 7px; + --webkit-scrollbar-padding: 4px; + --webkit-scrollbar-color: var(--separator-color); +} + +@media screen and (max-width: 767px) { + html { + --page-font-size: 16px; + --navigation-font-size: 16px; + --toc-font-size: 15px; + --code-font-size: 15px; /* affects code, fragment */ + --title-font-size: 22px; + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.35); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; + } +} + +/* dark mode variables are defined twice, to support both the dark-mode without and with doxygen-awesome-darkmode-toggle.js */ +html.dark-mode { + color-scheme: dark; + + --primary-color: #1982d2; + --primary-dark-color: #86a9c4; + --primary-light-color: #4779ac; + + --box-shadow: 0 2px 8px 0 rgba(0,0,0,.30); + + --odd-color: rgba(100,100,100,.06); + + --menu-selected-background: rgba(0,0,0,.4); + + --page-background-color: #1C1D1F; + --page-foreground-color: #d2dbde; + --page-secondary-foreground-color: #859399; + --separator-color: #38393b; + --side-nav-background: #252628; + + --code-background: #2a2c2f; + + --tablehead-background: #2a2c2f; + + --blockquote-background: #222325; + --blockquote-foreground: #7e8c92; + + --warning-color: #2e1917; + --warning-color-dark: #ad2617; + --warning-color-darker: #f5b1aa; + --note-color: #3b2e04; + --note-color-dark: #f1b602; + --note-color-darker: #ceb670; + --todo-color: #163750; + --todo-color-dark: #1982D2; + --todo-color-darker: #dcf0fa; + --deprecated-color: #2e323b; + --deprecated-color-dark: #738396; + --deprecated-color-darker: #abb0bd; + --bug-color: #2a2536; + --bug-color-dark: #7661b3; + --bug-color-darker: #ae9ed6; + --invariant-color: #303a35; + --invariant-color-dark: #76ce96; + --invariant-color-darker: #cceed5; + + --fragment-background: #282c34; + --fragment-foreground: #dbe4eb; + --fragment-keyword: #cc99cd; + --fragment-keywordtype: #ab99cd; + --fragment-keywordflow: #e08000; + --fragment-token: #7ec699; + --fragment-comment: #999999; + --fragment-link: #98c0e3; + --fragment-preprocessor: #65cabe; + --fragment-linenumber-color: #cccccc; + --fragment-linenumber-background: #35393c; + --fragment-linenumber-border: #1f1f1f; +} + +body { + color: var(--page-foreground-color); + background-color: var(--page-background-color); + font-size: var(--page-font-size); +} + +body, table, div, p, dl, #nav-tree .label, .title, +.sm-dox a, .sm-dox a:hover, .sm-dox a:focus, #projectname, +.SelectItem, #MSearchField, .navpath li.navelem a, +.navpath li.navelem a:hover, p.reference, p.definition { + font-family: var(--font-family); +} + +h1, h2, h3, h4, h5 { + margin-top: .9em; + font-weight: 600; + line-height: initial; +} + +p, div, table, dl, p.reference, p.definition { + font-size: var(--page-font-size); +} + +p.reference, p.definition { + color: var(--page-secondary-foreground-color); +} + +a:link, a:visited, a:hover, a:focus, a:active { + color: var(--primary-color) !important; + font-weight: 500; +} + +a.anchor { + scroll-margin-top: var(--spacing-large); + display: block; +} + +/* + Title and top navigation + */ + +#top { + background: var(--header-background); + border-bottom: 1px solid var(--separator-color); +} + +@media screen and (min-width: 768px) { + #top { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + align-items: center; + } +} + +#main-nav { + flex-grow: 5; + padding: var(--spacing-small) var(--spacing-medium); +} + +#titlearea { + width: auto; + padding: var(--spacing-medium) var(--spacing-large); + background: none; + color: var(--header-foreground); + border-bottom: none; +} + +@media screen and (max-width: 767px) { + #titlearea { + padding-bottom: var(--spacing-small); + } +} + +#titlearea table tbody tr { + height: auto !important; +} + +#projectname { + font-size: var(--title-font-size); + font-weight: 600; +} + +#projectnumber { + font-family: inherit; + font-size: 60%; +} + +#projectbrief { + font-family: inherit; + font-size: 80%; +} + +#projectlogo { + vertical-align: middle; +} + +#projectlogo img { + max-height: calc(var(--title-font-size) * 2); + margin-right: var(--spacing-small); +} + +.sm-dox, .tabs, .tabs2, .tabs3 { + background: none; + padding: 0; +} + +.tabs, .tabs2, .tabs3 { + border-bottom: 1px solid var(--separator-color); + margin-bottom: -1px; +} + +.main-menu-btn-icon, .main-menu-btn-icon:before, .main-menu-btn-icon:after { + background: var(--page-secondary-foreground-color); +} + +@media screen and (max-width: 767px) { + .sm-dox a span.sub-arrow { + background: var(--code-background); + } + + #main-menu a.has-submenu span.sub-arrow { + color: var(--page-secondary-foreground-color); + border-radius: var(--border-radius-medium); + } + + #main-menu a.has-submenu:hover span.sub-arrow { + color: var(--page-foreground-color); + } +} + +@media screen and (min-width: 768px) { + .sm-dox li, .tablist li { + display: var(--menu-display); + } + + .sm-dox a span.sub-arrow { + border-color: var(--header-foreground) transparent transparent transparent; + } + + .sm-dox a:hover span.sub-arrow { + border-color: var(--menu-focus-foreground) transparent transparent transparent; + } + + .sm-dox ul a span.sub-arrow { + border-color: transparent transparent transparent var(--page-foreground-color); + } + + .sm-dox ul a:hover span.sub-arrow { + border-color: transparent transparent transparent var(--menu-focus-foreground); + } +} + +.sm-dox ul { + background: var(--page-background-color); + box-shadow: var(--box-shadow); + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium) !important; + padding: var(--spacing-small); + animation: ease-out 150ms slideInMenu; +} + +@keyframes slideInMenu { + from { + opacity: 0; + transform: translate(0px, -2px); + } + + to { + opacity: 1; + transform: translate(0px, 0px); + } +} + +.sm-dox ul a { + color: var(--page-foreground-color) !important; + background: var(--page-background-color); + font-size: var(--navigation-font-size); +} + +.sm-dox>li>ul:after { + border-bottom-color: var(--page-background-color) !important; +} + +.sm-dox>li>ul:before { + border-bottom-color: var(--separator-color) !important; +} + +.sm-dox ul a:hover, .sm-dox ul a:active, .sm-dox ul a:focus { + font-size: var(--navigation-font-size) !important; + color: var(--menu-focus-foreground) !important; + text-shadow: none; + background-color: var(--menu-focus-background); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a, .sm-dox a:focus, .tablist li, .tablist li a, .tablist li.current a { + text-shadow: none; + background: transparent; + background-image: none !important; + color: var(--header-foreground) !important; + font-weight: normal; + font-size: var(--navigation-font-size); + border-radius: var(--border-radius-small) !important; +} + +.sm-dox a:focus { + outline: auto; +} + +.sm-dox a:hover, .sm-dox a:active, .tablist li a:hover { + text-shadow: none; + font-weight: normal; + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; + border-radius: var(--border-radius-small) !important; + font-size: var(--navigation-font-size); +} + +.tablist li.current { + border-radius: var(--border-radius-small); + background: var(--menu-selected-background); +} + +.tablist li { + margin: var(--spacing-small) 0 var(--spacing-small) var(--spacing-small); +} + +.tablist a { + padding: 0 var(--spacing-large); +} + + +/* + Search box + */ + +#MSearchBox { + height: var(--searchbar-height); + background: var(--searchbar-background); + border-radius: var(--searchbar-border-radius); + border: 1px solid var(--separator-color); + overflow: hidden; + width: var(--searchbar-width); + position: relative; + box-shadow: none; + display: block; + margin-top: 0; +} + +/* until Doxygen 1.9.4 */ +.left img#MSearchSelect { + left: 0; + user-select: none; + padding-left: 8px; +} + +/* Doxygen 1.9.5 */ +.left span#MSearchSelect { + left: 0; + user-select: none; + margin-left: 8px; + padding: 0; +} + +.left #MSearchSelect[src$=".png"] { + padding-left: 0 +} + +.SelectionMark { + user-select: none; +} + +.tabs .left #MSearchSelect { + padding-left: 0; +} + +.tabs #MSearchBox { + position: absolute; + right: var(--spacing-medium); +} + +@media screen and (max-width: 767px) { + .tabs #MSearchBox { + position: relative; + right: 0; + margin-left: var(--spacing-medium); + margin-top: 0; + } +} + +#MSearchSelectWindow, #MSearchResultsWindow { + z-index: 9999; +} + +#MSearchBox.MSearchBoxActive { + border-color: var(--primary-color); + box-shadow: inset 0 0 0 1px var(--primary-color); +} + +#main-menu > li:last-child { + margin-right: 0; +} + +@media screen and (max-width: 767px) { + #main-menu > li:last-child { + height: 50px; + } +} + +#MSearchField { + font-size: var(--navigation-font-size); + height: calc(var(--searchbar-height) - 2px); + background: transparent; + width: calc(var(--searchbar-width) - 64px); +} + +.MSearchBoxActive #MSearchField { + color: var(--searchbar-foreground); +} + +#MSearchSelect { + top: calc(calc(var(--searchbar-height) / 2) - 11px); +} + +#MSearchBox span.left, #MSearchBox span.right { + background: none; + background-image: none; +} + +#MSearchBox span.right { + padding-top: calc(calc(var(--searchbar-height) / 2) - 12px); + position: absolute; + right: var(--spacing-small); +} + +.tabs #MSearchBox span.right { + top: calc(calc(var(--searchbar-height) / 2) - 12px); +} + +@keyframes slideInSearchResults { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } +} + +#MSearchResultsWindow { + left: auto !important; + right: var(--spacing-medium); + border-radius: var(--border-radius-large); + border: 1px solid var(--separator-color); + transform: translate(0, 20px); + box-shadow: var(--box-shadow); + animation: ease-out 280ms slideInSearchResults; + background: var(--page-background-color); +} + +iframe#MSearchResults { + margin: 4px; +} + +iframe { + color-scheme: normal; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) iframe#MSearchResults { + filter: invert() hue-rotate(180deg); + } +} + +html.dark-mode iframe#MSearchResults { + filter: invert() hue-rotate(180deg); +} + +#MSearchResults .SRPage { + background-color: transparent; +} + +#MSearchResults .SRPage .SREntry { + font-size: 10pt; + padding: var(--spacing-small) var(--spacing-medium); +} + +#MSearchSelectWindow { + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + box-shadow: var(--box-shadow); + background: var(--page-background-color); + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); +} + +#MSearchSelectWindow a.SelectItem { + font-size: var(--navigation-font-size); + line-height: var(--content-line-height); + margin: 0 var(--spacing-small); + border-radius: var(--border-radius-small); + color: var(--page-foreground-color) !important; + font-weight: normal; +} + +#MSearchSelectWindow a.SelectItem:hover { + background: var(--menu-focus-background); + color: var(--menu-focus-foreground) !important; +} + +@media screen and (max-width: 767px) { + #MSearchBox { + margin-top: var(--spacing-medium); + margin-bottom: var(--spacing-medium); + width: calc(100vw - 30px); + } + + #main-menu > li:last-child { + float: none !important; + } + + #MSearchField { + width: calc(100vw - 110px); + } + + @keyframes slideInSearchResultsMobile { + from { + opacity: 0; + transform: translate(0, 15px); + } + + to { + opacity: 1; + transform: translate(0, 20px); + } + } + + #MSearchResultsWindow { + left: var(--spacing-medium) !important; + right: var(--spacing-medium); + overflow: auto; + transform: translate(0, 20px); + animation: ease-out 280ms slideInSearchResultsMobile; + width: auto !important; + } + + /* + * Overwrites for fixing the searchbox on mobile in doxygen 1.9.2 + */ + label.main-menu-btn ~ #searchBoxPos1 { + top: 3px !important; + right: 6px !important; + left: 45px; + display: flex; + } + + label.main-menu-btn ~ #searchBoxPos1 > #MSearchBox { + margin-top: 0; + margin-bottom: 0; + flex-grow: 2; + float: left; + } +} + +/* + Tree view + */ + +#side-nav { + padding: 0 !important; + background: var(--side-nav-background); +} + +@media screen and (max-width: 767px) { + #side-nav { + display: none; + } + + #doc-content { + margin-left: 0 !important; + } +} + +#nav-tree { + background: transparent; +} + +#nav-tree .label { + font-size: var(--navigation-font-size); +} + +#nav-tree .item { + height: var(--tree-item-height); + line-height: var(--tree-item-height); +} + +#nav-sync { + bottom: 12px; + right: 12px; + top: auto !important; + user-select: none; +} + +#nav-tree .selected { + text-shadow: none; + background-image: none; + background-color: transparent; + position: relative; +} + +#nav-tree .selected::after { + content: ""; + position: absolute; + top: 1px; + bottom: 1px; + left: 0; + width: 4px; + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + background: var(--primary-color); +} + + +#nav-tree a { + color: var(--side-nav-foreground) !important; + font-weight: normal; +} + +#nav-tree a:focus { + outline-style: auto; +} + +#nav-tree .arrow { + opacity: var(--side-nav-arrow-opacity); +} + +.arrow { + color: inherit; + cursor: pointer; + font-size: 45%; + vertical-align: middle; + margin-right: 2px; + font-family: serif; + height: auto; + text-align: right; +} + +#nav-tree div.item:hover .arrow, #nav-tree a:focus .arrow { + opacity: var(--side-nav-arrow-hover-opacity); +} + +#nav-tree .selected a { + color: var(--primary-color) !important; + font-weight: bolder; + font-weight: 600; +} + +.ui-resizable-e { + background: var(--separator-color); + width: 1px; +} + +/* + Contents + */ + +div.header { + border-bottom: 1px solid var(--separator-color); + background-color: var(--page-background-color); + background-image: none; +} + +@media screen and (min-width: 1000px) { + #doc-content > div > div.contents, + .PageDoc > div.contents { + display: flex; + flex-direction: row-reverse; + flex-wrap: nowrap; + align-items: flex-start; + } + + div.contents .textblock { + min-width: 200px; + flex-grow: 1; + } +} + +div.contents, div.header .title, div.header .summary { + max-width: var(--content-maxwidth); +} + +div.contents, div.header .title { + line-height: initial; + margin: calc(var(--spacing-medium) + .2em) auto var(--spacing-medium) auto; +} + +div.header .summary { + margin: var(--spacing-medium) auto 0 auto; +} + +div.headertitle { + padding: 0; +} + +div.header .title { + font-weight: 600; + font-size: 225%; + padding: var(--spacing-medium) var(--spacing-large); + word-break: break-word; +} + +div.header .summary { + width: auto; + display: block; + float: none; + padding: 0 var(--spacing-large); +} + +td.memSeparator { + border-color: var(--separator-color); +} + +span.mlabel { + background: var(--primary-color); + border: none; + padding: 4px 9px; + border-radius: 12px; + margin-right: var(--spacing-medium); +} + +span.mlabel:last-of-type { + margin-right: 2px; +} + +div.contents { + padding: 0 var(--spacing-large); +} + +div.contents p, div.contents li { + line-height: var(--content-line-height); +} + +div.contents div.dyncontent { + margin: var(--spacing-medium) 0; +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) div.contents div.dyncontent img, + html:not(.light-mode) div.contents center img, + html:not(.light-mode) div.contents > table img, + html:not(.light-mode) div.contents div.dyncontent iframe, + html:not(.light-mode) div.contents center iframe, + html:not(.light-mode) div.contents table iframe { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode div.contents div.dyncontent img, +html.dark-mode div.contents center img, +html.dark-mode div.contents > table img, +html.dark-mode div.contents div.dyncontent iframe, +html.dark-mode div.contents center iframe, +html.dark-mode div.contents table iframe { + filter: hue-rotate(180deg) invert(); +} + +h2.groupheader { + border-bottom: 0px; + color: var(--page-foreground-color); + box-shadow: + 100px 0 var(--page-background-color), + -100px 0 var(--page-background-color), + 100px 0.75px var(--separator-color), + -100px 0.75px var(--separator-color), + 500px 0 var(--page-background-color), + -500px 0 var(--page-background-color), + 500px 0.75px var(--separator-color), + -500px 0.75px var(--separator-color), + 900px 0 var(--page-background-color), + -900px 0 var(--page-background-color), + 900px 0.75px var(--separator-color), + -900px 0.75px var(--separator-color), + 1400px 0 var(--page-background-color), + -1400px 0 var(--page-background-color), + 1400px 0.75px var(--separator-color), + -1400px 0.75px var(--separator-color), + 1900px 0 var(--page-background-color), + -1900px 0 var(--page-background-color), + 1900px 0.75px var(--separator-color), + -1900px 0.75px var(--separator-color); +} + +blockquote { + margin: 0 var(--spacing-medium) 0 var(--spacing-medium); + padding: var(--spacing-small) var(--spacing-large); + background: var(--blockquote-background); + color: var(--blockquote-foreground); + border-left: 0; + overflow: visible; + border-radius: var(--border-radius-medium); + overflow: visible; + position: relative; +} + +blockquote::before, blockquote::after { + font-weight: bold; + font-family: serif; + font-size: 360%; + opacity: .15; + position: absolute; +} + +blockquote::before { + content: "“"; + left: -10px; + top: 4px; +} + +blockquote::after { + content: "”"; + right: -8px; + bottom: -25px; +} + +blockquote p { + margin: var(--spacing-small) 0 var(--spacing-medium) 0; +} +.paramname { + font-weight: 600; + color: var(--primary-dark-color); +} + +.paramname > code { + border: 0; +} + +table.params .paramname { + font-weight: 600; + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + padding-right: var(--spacing-small); + line-height: var(--table-line-height); +} + +h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { + text-shadow: 0 0 15px var(--primary-light-color); +} + +.alphachar a { + color: var(--page-foreground-color); +} + +/* + Table of Contents + */ + +div.contents .toc { + max-height: var(--toc-max-height); + min-width: var(--toc-width); + border: 0; + border-left: 1px solid var(--separator-color); + border-radius: 0; + background-color: transparent; + box-shadow: none; + position: sticky; + top: var(--toc-sticky-top); + padding: 0 var(--spacing-large); + margin: var(--spacing-small) 0 var(--spacing-large) var(--spacing-large); +} + +div.toc h3 { + color: var(--toc-foreground); + font-size: var(--navigation-font-size); + margin: var(--spacing-large) 0 var(--spacing-medium) 0; +} + +div.toc li { + padding: 0; + background: none; + line-height: var(--toc-font-size); + margin: var(--toc-font-size) 0 0 0; +} + +div.toc li::before { + display: none; +} + +div.toc ul { + margin-top: 0 +} + +div.toc li a { + font-size: var(--toc-font-size); + color: var(--page-foreground-color) !important; + text-decoration: none; +} + +div.toc li a:hover, div.toc li a.active { + color: var(--primary-color) !important; +} + +div.toc li a.aboveActive { + color: var(--page-secondary-foreground-color) !important; +} + + +@media screen and (max-width: 999px) { + div.contents .toc { + max-height: 45vh; + float: none; + width: auto; + margin: 0 0 var(--spacing-medium) 0; + position: relative; + top: 0; + position: relative; + border: 1px solid var(--separator-color); + border-radius: var(--border-radius-medium); + background-color: var(--toc-background); + box-shadow: var(--box-shadow); + } + + div.contents .toc.interactive { + max-height: calc(var(--navigation-font-size) + 2 * var(--spacing-large)); + overflow: hidden; + } + + div.contents .toc > h3 { + -webkit-tap-highlight-color: transparent; + cursor: pointer; + position: sticky; + top: 0; + background-color: var(--toc-background); + margin: 0; + padding: var(--spacing-large) 0; + display: block; + } + + div.contents .toc.interactive > h3::before { + content: ""; + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + display: inline-block; + margin-right: var(--spacing-small); + margin-bottom: calc(var(--navigation-font-size) / 4); + transform: rotate(-90deg); + transition: transform 0.25s ease-out; + } + + div.contents .toc.interactive.open > h3::before { + transform: rotate(0deg); + } + + div.contents .toc.interactive.open { + max-height: 45vh; + overflow: auto; + transition: max-height 0.2s ease-in-out; + } + + div.contents .toc a, div.contents .toc a.active { + color: var(--primary-color) !important; + } + + div.contents .toc a:hover { + text-decoration: underline; + } +} + +/* + Code & Fragments + */ + +code, div.fragment, pre.fragment { + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + overflow: hidden; +} + +code { + display: inline; + background: var(--code-background); + color: var(--code-foreground); + padding: 2px 6px; +} + +div.fragment, pre.fragment { + margin: var(--spacing-medium) 0; + padding: calc(var(--spacing-large) - (var(--spacing-large) / 6)) var(--spacing-large); + background: var(--fragment-background); + color: var(--fragment-foreground); + overflow-x: auto; +} + +@media screen and (max-width: 767px) { + div.fragment, pre.fragment { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-right: 0; + } + + .contents > div.fragment, + .textblock > div.fragment, + .textblock > pre.fragment, + .contents > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > div.fragment, + .textblock > .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + border-radius: 0; + border-left: 0; + } + + .textblock li > .fragment, + .textblock li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-large)); + } + + .memdoc li > .fragment, + .memdoc li > .doxygen-awesome-fragment-wrapper > .fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + } + + .textblock ul, .memdoc ul { + overflow: initial; + } + + .memdoc > div.fragment, + .memdoc > pre.fragment, + dl dd > div.fragment, + dl dd pre.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > div.fragment, + .memdoc > .doxygen-awesome-fragment-wrapper > pre.fragment, + dl dd > .doxygen-awesome-fragment-wrapper > div.fragment, + dl dd .doxygen-awesome-fragment-wrapper > pre.fragment { + margin: var(--spacing-medium) calc(0px - var(--spacing-medium)); + border-radius: 0; + border-left: 0; + } +} + +code, code a, pre.fragment, div.fragment, div.fragment .line, div.fragment span, div.fragment .line a, div.fragment .line span { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size) !important; +} + +div.line:after { + margin-right: var(--spacing-medium); +} + +div.fragment .line, pre.fragment { + white-space: pre; + word-wrap: initial; + line-height: var(--fragment-lineheight); +} + +div.fragment span.keyword { + color: var(--fragment-keyword); +} + +div.fragment span.keywordtype { + color: var(--fragment-keywordtype); +} + +div.fragment span.keywordflow { + color: var(--fragment-keywordflow); +} + +div.fragment span.stringliteral { + color: var(--fragment-token) +} + +div.fragment span.comment { + color: var(--fragment-comment); +} + +div.fragment a.code { + color: var(--fragment-link) !important; +} + +div.fragment span.preprocessor { + color: var(--fragment-preprocessor); +} + +div.fragment span.lineno { + display: inline-block; + width: 27px; + border-right: none; + background: var(--fragment-linenumber-background); + color: var(--fragment-linenumber-color); +} + +div.fragment span.lineno a { + background: none; + color: var(--fragment-link) !important; +} + +div.fragment .line:first-child .lineno { + box-shadow: -999999px 0px 0 999999px var(--fragment-linenumber-background), -999998px 0px 0 999999px var(--fragment-linenumber-border); +} + +div.line { + border-radius: var(--border-radius-small); +} + +div.line.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +/* + dl warning, attention, note, deprecated, bug, ... + */ + +dl.bug dt a, dl.deprecated dt a, dl.todo dt a { + font-weight: bold !important; +} + +dl.warning, dl.attention, dl.note, dl.deprecated, dl.bug, dl.invariant, dl.pre, dl.todo, dl.remark { + padding: var(--spacing-medium); + margin: var(--spacing-medium) 0; + color: var(--page-background-color); + overflow: hidden; + margin-left: 0; + border-radius: var(--border-radius-small); +} + +dl.section dd { + margin-bottom: 2px; +} + +dl.warning, dl.attention { + background: var(--warning-color); + border-left: 8px solid var(--warning-color-dark); + color: var(--warning-color-darker); +} + +dl.warning dt, dl.attention dt { + color: var(--warning-color-dark); +} + +dl.note, dl.remark { + background: var(--note-color); + border-left: 8px solid var(--note-color-dark); + color: var(--note-color-darker); +} + +dl.note dt, dl.remark dt { + color: var(--note-color-dark); +} + +dl.todo { + background: var(--todo-color); + border-left: 8px solid var(--todo-color-dark); + color: var(--todo-color-darker); +} + +dl.todo dt { + color: var(--todo-color-dark); +} + +dl.bug dt a { + color: var(--todo-color-dark) !important; +} + +dl.bug { + background: var(--bug-color); + border-left: 8px solid var(--bug-color-dark); + color: var(--bug-color-darker); +} + +dl.bug dt a { + color: var(--bug-color-dark) !important; +} + +dl.deprecated { + background: var(--deprecated-color); + border-left: 8px solid var(--deprecated-color-dark); + color: var(--deprecated-color-darker); +} + +dl.deprecated dt a { + color: var(--deprecated-color-dark) !important; +} + +dl.section dd, dl.bug dd, dl.deprecated dd, dl.todo dd { + margin-inline-start: 0px; +} + +dl.invariant, dl.pre { + background: var(--invariant-color); + border-left: 8px solid var(--invariant-color-dark); + color: var(--invariant-color-darker); +} + +dl.invariant dt, dl.pre dt { + color: var(--invariant-color-dark); +} + +/* + memitem + */ + +div.memdoc, div.memproto, h2.memtitle { + box-shadow: none; + background-image: none; + border: none; +} + +div.memdoc { + padding: 0 var(--spacing-medium); + background: var(--page-background-color); +} + +h2.memtitle, div.memitem { + border: 1px solid var(--separator-color); + box-shadow: var(--box-shadow); +} + +h2.memtitle { + box-shadow: 0px var(--spacing-medium) 0 -1px var(--fragment-background), var(--box-shadow); +} + +div.memitem { + transition: none; +} + +div.memproto, h2.memtitle { + background: var(--fragment-background); +} + +h2.memtitle { + font-weight: 500; + font-size: var(--memtitle-font-size); + font-family: var(--font-family-monospace); + border-bottom: none; + border-top-left-radius: var(--border-radius-medium); + border-top-right-radius: var(--border-radius-medium); + word-break: break-all; + position: relative; +} + +h2.memtitle:after { + content: ""; + display: block; + background: var(--fragment-background); + height: var(--spacing-medium); + bottom: calc(0px - var(--spacing-medium)); + left: 0; + right: -14px; + position: absolute; + border-top-right-radius: var(--border-radius-medium); +} + +h2.memtitle > span.permalink { + font-size: inherit; +} + +h2.memtitle > span.permalink > a { + text-decoration: none; + padding-left: 3px; + margin-right: -4px; + user-select: none; + display: inline-block; + margin-top: -6px; +} + +h2.memtitle > span.permalink > a:hover { + color: var(--primary-dark-color) !important; +} + +a:target + h2.memtitle, a:target + h2.memtitle + div.memitem { + border-color: var(--primary-light-color); +} + +div.memitem { + border-top-right-radius: var(--border-radius-medium); + border-bottom-right-radius: var(--border-radius-medium); + border-bottom-left-radius: var(--border-radius-medium); + overflow: hidden; + display: block !important; +} + +div.memdoc { + border-radius: 0; +} + +div.memproto { + border-radius: 0 var(--border-radius-small) 0 0; + overflow: auto; + border-bottom: 1px solid var(--separator-color); + padding: var(--spacing-medium); + margin-bottom: -1px; +} + +div.memtitle { + border-top-right-radius: var(--border-radius-medium); + border-top-left-radius: var(--border-radius-medium); +} + +div.memproto table.memname { + font-family: var(--font-family-monospace); + color: var(--page-foreground-color); + font-size: var(--memname-font-size); + text-shadow: none; +} + +div.memproto div.memtemplate { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--memname-font-size); + margin-left: 2px; + text-shadow: none; +} + +table.mlabels, table.mlabels > tbody { + display: block; +} + +td.mlabels-left { + width: auto; +} + +td.mlabels-right { + margin-top: 3px; + position: sticky; + left: 0; +} + +table.mlabels > tbody > tr:first-child { + display: flex; + justify-content: space-between; + flex-wrap: wrap; +} + +.memname, .memitem span.mlabels { + margin: 0 +} + +/* + reflist + */ + +dl.reflist { + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-medium); + border: 1px solid var(--separator-color); + overflow: hidden; + padding: 0; +} + + +dl.reflist dt, dl.reflist dd { + box-shadow: none; + text-shadow: none; + background-image: none; + border: none; + padding: 12px; +} + + +dl.reflist dt { + font-weight: 500; + border-radius: 0; + background: var(--code-background); + border-bottom: 1px solid var(--separator-color); + color: var(--page-foreground-color) +} + + +dl.reflist dd { + background: none; +} + +/* + Table + */ + +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname), +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody { + display: inline-block; + max-width: 100%; +} + +.contents > table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname):not(.classindex) { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); +} + +table.fieldtable, +table.markdownTable tbody, +table.doxtable tbody { + border: none; + margin: var(--spacing-medium) 0; + box-shadow: 0 0 0 1px var(--separator-color); + border-radius: var(--border-radius-small); +} + +table.doxtable caption { + display: block; +} + +table.fieldtable { + border-collapse: collapse; + width: 100%; +} + +th.markdownTableHeadLeft, +th.markdownTableHeadRight, +th.markdownTableHeadCenter, +th.markdownTableHeadNone, +table.doxtable th { + background: var(--tablehead-background); + color: var(--tablehead-foreground); + font-weight: 600; + font-size: var(--page-font-size); +} + +th.markdownTableHeadLeft:first-child, +th.markdownTableHeadRight:first-child, +th.markdownTableHeadCenter:first-child, +th.markdownTableHeadNone:first-child, +table.doxtable tr th:first-child { + border-top-left-radius: var(--border-radius-small); +} + +th.markdownTableHeadLeft:last-child, +th.markdownTableHeadRight:last-child, +th.markdownTableHeadCenter:last-child, +th.markdownTableHeadNone:last-child, +table.doxtable tr th:last-child { + border-top-right-radius: var(--border-radius-small); +} + +table.markdownTable td, +table.markdownTable th, +table.fieldtable td, +table.fieldtable th, +table.doxtable td, +table.doxtable th { + border: 1px solid var(--separator-color); + padding: var(--spacing-small) var(--spacing-medium); +} + +table.markdownTable td:last-child, +table.markdownTable th:last-child, +table.fieldtable td:last-child, +table.fieldtable th:last-child, +table.doxtable td:last-child, +table.doxtable th:last-child { + border-right: none; +} + +table.markdownTable td:first-child, +table.markdownTable th:first-child, +table.fieldtable td:first-child, +table.fieldtable th:first-child, +table.doxtable td:first-child, +table.doxtable th:first-child { + border-left: none; +} + +table.markdownTable tr:first-child td, +table.markdownTable tr:first-child th, +table.fieldtable tr:first-child td, +table.fieldtable tr:first-child th, +table.doxtable tr:first-child td, +table.doxtable tr:first-child th { + border-top: none; +} + +table.markdownTable tr:last-child td, +table.markdownTable tr:last-child th, +table.fieldtable tr:last-child td, +table.fieldtable tr:last-child th, +table.doxtable tr:last-child td, +table.doxtable tr:last-child th { + border-bottom: none; +} + +table.markdownTable tr, table.doxtable tr { + border-bottom: 1px solid var(--separator-color); +} + +table.markdownTable tr:last-child, table.doxtable tr:last-child { + border-bottom: none; +} + +table.fieldtable th { + font-size: var(--page-font-size); + font-weight: 600; + background-image: none; + background-color: var(--tablehead-background); + color: var(--tablehead-foreground); +} + +table.fieldtable td.fieldtype, .fieldtable td.fieldname, .fieldtable td.fielddoc, .fieldtable th { + border-bottom: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); +} + +table.fieldtable tr:last-child td:first-child { + border-bottom-left-radius: var(--border-radius-small); +} + +table.fieldtable tr:last-child td:last-child { + border-bottom-right-radius: var(--border-radius-small); +} + +.memberdecls td.glow, .fieldtable tr.glow { + background-color: var(--primary-light-color); + box-shadow: none; +} + +table.memberdecls { + display: block; + -webkit-tap-highlight-color: transparent; +} + +table.memberdecls tr[class^='memitem'] { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); +} + +table.memberdecls tr[class^='memitem'] .memTemplParams { + font-family: var(--font-family-monospace); + font-size: var(--code-font-size); + color: var(--primary-dark-color); + white-space: normal; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memItemRight, +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight, +table.memberdecls .memTemplParams { + transition: none; + padding-top: var(--spacing-small); + padding-bottom: var(--spacing-small); + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + background-color: var(--fragment-background); +} + +table.memberdecls .memTemplItemLeft, +table.memberdecls .memTemplItemRight { + padding-top: 2px; +} + +table.memberdecls .memTemplParams { + border-bottom: 0; + border-left: 1px solid var(--separator-color); + border-right: 1px solid var(--separator-color); + border-radius: var(--border-radius-small) var(--border-radius-small) 0 0; + padding-bottom: var(--spacing-small); +} + +table.memberdecls .memTemplItemLeft { + border-radius: 0 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + border-top: 0; +} + +table.memberdecls .memTemplItemRight { + border-radius: 0 0 var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-left: 0; + border-top: 0; +} + +table.memberdecls .memItemLeft { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); + border-left: 1px solid var(--separator-color); + padding-left: var(--spacing-medium); + padding-right: 0; +} + +table.memberdecls .memItemRight { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; + border-right: 1px solid var(--separator-color); + padding-right: var(--spacing-medium); + padding-left: 0; + +} + +table.memberdecls .mdescLeft, table.memberdecls .mdescRight { + background: none; + color: var(--page-foreground-color); + padding: var(--spacing-small) 0; +} + +table.memberdecls .memItemLeft, +table.memberdecls .memTemplItemLeft { + padding-right: var(--spacing-medium); +} + +table.memberdecls .memSeparator { + background: var(--page-background-color); + height: var(--spacing-large); + border: 0; + transition: none; +} + +table.memberdecls .groupheader { + margin-bottom: var(--spacing-large); +} + +table.memberdecls .inherit_header td { + padding: 0 0 var(--spacing-medium) 0; + text-indent: -12px; + color: var(--page-secondary-foreground-color); +} + +table.memberdecls img[src="closed.png"], +table.memberdecls img[src="open.png"], +div.dynheader img[src="open.png"], +div.dynheader img[src="closed.png"] { + width: 0; + height: 0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + border-top: 5px solid var(--primary-color); + margin-top: 8px; + display: block; + float: left; + margin-left: -10px; + transition: transform 0.25s ease-out; +} + +table.memberdecls img { + margin-right: 10px; +} + +table.memberdecls img[src="closed.png"], +div.dynheader img[src="closed.png"] { + transform: rotate(-90deg); + +} + +.compoundTemplParams { + font-family: var(--font-family-monospace); + color: var(--primary-dark-color); + font-size: var(--code-font-size); +} + +@media screen and (max-width: 767px) { + + table.memberdecls .memItemLeft, + table.memberdecls .memItemRight, + table.memberdecls .mdescLeft, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemLeft, + table.memberdecls .memTemplItemRight, + table.memberdecls .memTemplParams { + display: block; + text-align: left; + padding-left: var(--spacing-large); + margin: 0 calc(0px - var(--spacing-large)) 0 calc(0px - var(--spacing-large)); + border-right: none; + border-left: none; + border-radius: 0; + white-space: normal; + } + + table.memberdecls .memItemLeft, + table.memberdecls .mdescLeft, + table.memberdecls .memTemplItemLeft { + border-bottom: 0; + padding-bottom: 0; + } + + table.memberdecls .memTemplItemLeft { + padding-top: 0; + } + + table.memberdecls .mdescLeft { + margin-bottom: calc(0px - var(--page-font-size)); + } + + table.memberdecls .memItemRight, + table.memberdecls .mdescRight, + table.memberdecls .memTemplItemRight { + border-top: 0; + padding-top: 0; + padding-right: var(--spacing-large); + overflow-x: auto; + } + + table.memberdecls tr[class^='memitem']:not(.inherit) { + display: block; + width: calc(100vw - 2 * var(--spacing-large)); + } + + table.memberdecls .mdescRight { + color: var(--page-foreground-color); + } + + table.memberdecls tr.inherit { + visibility: hidden; + } + + table.memberdecls tr[style="display: table-row;"] { + display: block !important; + visibility: visible; + width: calc(100vw - 2 * var(--spacing-large)); + animation: fade .5s; + } + + @keyframes fade { + 0% { + opacity: 0; + max-height: 0; + } + + 100% { + opacity: 1; + max-height: 200px; + } + } +} + + +/* + Horizontal Rule + */ + +hr { + margin-top: var(--spacing-large); + margin-bottom: var(--spacing-large); + height: 1px; + background-color: var(--separator-color); + border: 0; +} + +.contents hr { + box-shadow: 100px 0 0 var(--separator-color), + -100px 0 0 var(--separator-color), + 500px 0 0 var(--separator-color), + -500px 0 0 var(--separator-color), + 1500px 0 0 var(--separator-color), + -1500px 0 0 var(--separator-color), + 2000px 0 0 var(--separator-color), + -2000px 0 0 var(--separator-color); +} + +.contents img, .contents .center, .contents center, .contents div.image object { + max-width: 100%; + overflow: auto; +} + +@media screen and (max-width: 767px) { + .contents .dyncontent > .center, .contents > center { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + max-width: calc(100% + 2 * var(--spacing-large)); + } +} + +/* + Directories + */ +div.directory { + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + width: auto; +} + +table.directory { + font-family: var(--font-family); + font-size: var(--page-font-size); + font-weight: normal; + width: 100%; +} + +table.directory td.entry, table.directory td.desc { + padding: calc(var(--spacing-small) / 2) var(--spacing-small); + line-height: var(--table-line-height); +} + +table.directory tr.even td:last-child { + border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0; +} + +table.directory tr.even td:first-child { + border-radius: var(--border-radius-small) 0 0 var(--border-radius-small); +} + +table.directory tr.even:last-child td:last-child { + border-radius: 0 var(--border-radius-small) 0 0; +} + +table.directory tr.even:last-child td:first-child { + border-radius: var(--border-radius-small) 0 0 0; +} + +table.directory td.desc { + min-width: 250px; +} + +table.directory tr.even { + background-color: var(--odd-color); +} + +table.directory tr.odd { + background-color: transparent; +} + +.icona { + width: auto; + height: auto; + margin: 0 var(--spacing-small); +} + +.icon { + background: var(--primary-color); + border-radius: var(--border-radius-small); + font-size: var(--page-font-size); + padding: calc(var(--page-font-size) / 5); + line-height: var(--page-font-size); + transform: scale(0.8); + height: auto; + width: var(--page-font-size); + user-select: none; +} + +.iconfopen, .icondoc, .iconfclosed { + background-position: center; + margin-bottom: 0; + height: var(--table-line-height); +} + +.icondoc { + filter: saturate(0.2); +} + +@media screen and (max-width: 767px) { + div.directory { + margin-left: calc(0px - var(--spacing-large)); + margin-right: calc(0px - var(--spacing-large)); + } +} + +@media (prefers-color-scheme: dark) { + html:not(.light-mode) .iconfopen, html:not(.light-mode) .iconfclosed { + filter: hue-rotate(180deg) invert(); + } +} + +html.dark-mode .iconfopen, html.dark-mode .iconfclosed { + filter: hue-rotate(180deg) invert(); +} + +/* + Class list + */ + +.classindex dl.odd { + background: var(--odd-color); + border-radius: var(--border-radius-small); +} + +.classindex dl.even { + background-color: transparent; +} + +/* + Class Index Doxygen 1.8 +*/ + +table.classindex { + margin-left: 0; + margin-right: 0; + width: 100%; +} + +table.classindex table div.ah { + background-image: none; + background-color: initial; + border-color: var(--separator-color); + color: var(--page-foreground-color); + box-shadow: var(--box-shadow); + border-radius: var(--border-radius-large); + padding: var(--spacing-small); +} + +div.qindex { + background-color: var(--odd-color); + border-radius: var(--border-radius-small); + border: 1px solid var(--separator-color); + padding: var(--spacing-small) 0; +} + +/* + Footer and nav-path + */ + +#nav-path { + width: 100%; +} + +#nav-path ul { + background-image: none; + background: var(--page-background-color); + border: none; + border-top: 1px solid var(--separator-color); + border-bottom: 1px solid var(--separator-color); + border-bottom: 0; + box-shadow: 0 0.75px 0 var(--separator-color); + font-size: var(--navigation-font-size); +} + +img.footer { + width: 60px; +} + +.navpath li.footer { + color: var(--page-secondary-foreground-color); +} + +address.footer { + color: var(--page-secondary-foreground-color); + margin-bottom: var(--spacing-large); +} + +#nav-path li.navelem { + background-image: none; + display: flex; + align-items: center; +} + +.navpath li.navelem a { + text-shadow: none; + display: inline-block; + color: var(--primary-color) !important; +} + +.navpath li.navelem b { + color: var(--primary-dark-color); + font-weight: 500; +} + +li.navelem { + padding: 0; + margin-left: -8px; +} + +li.navelem:first-child { + margin-left: var(--spacing-large); +} + +li.navelem:first-child:before { + display: none; +} + +#nav-path li.navelem:after { + content: ''; + border: 5px solid var(--page-background-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(4.2); + z-index: 10; + margin-left: 6px; +} + +#nav-path li.navelem:before { + content: ''; + border: 5px solid var(--separator-color); + border-bottom-color: transparent; + border-right-color: transparent; + border-top-color: transparent; + transform: translateY(-1px) scaleY(3.2); + margin-right: var(--spacing-small); +} + +.navpath li.navelem a:hover { + color: var(--primary-color); +} + +/* + Scrollbars for Webkit +*/ + +#nav-tree::-webkit-scrollbar, +div.fragment::-webkit-scrollbar, +pre.fragment::-webkit-scrollbar, +div.memproto::-webkit-scrollbar, +.contents center::-webkit-scrollbar, +.contents .center::-webkit-scrollbar, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar, +div.contents .toc::-webkit-scrollbar { + background: transparent; + width: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + height: calc(var(--webkit-scrollbar-size) + var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); +} + +#nav-tree::-webkit-scrollbar-thumb, +div.fragment::-webkit-scrollbar-thumb, +pre.fragment::-webkit-scrollbar-thumb, +div.memproto::-webkit-scrollbar-thumb, +.contents center::-webkit-scrollbar-thumb, +.contents .center::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-thumb, +div.contents .toc::-webkit-scrollbar-thumb { + background-color: transparent; + border: var(--webkit-scrollbar-padding) solid transparent; + border-radius: calc(var(--webkit-scrollbar-padding) + var(--webkit-scrollbar-padding)); + background-clip: padding-box; +} + +#nav-tree:hover::-webkit-scrollbar-thumb, +div.fragment:hover::-webkit-scrollbar-thumb, +pre.fragment:hover::-webkit-scrollbar-thumb, +div.memproto:hover::-webkit-scrollbar-thumb, +.contents center:hover::-webkit-scrollbar-thumb, +.contents .center:hover::-webkit-scrollbar-thumb, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody:hover::-webkit-scrollbar-thumb, +div.contents .toc:hover::-webkit-scrollbar-thumb { + background-color: var(--webkit-scrollbar-color); +} + +#nav-tree::-webkit-scrollbar-track, +div.fragment::-webkit-scrollbar-track, +pre.fragment::-webkit-scrollbar-track, +div.memproto::-webkit-scrollbar-track, +.contents center::-webkit-scrollbar-track, +.contents .center::-webkit-scrollbar-track, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody::-webkit-scrollbar-track, +div.contents .toc::-webkit-scrollbar-track { + background: transparent; +} + +#nav-tree::-webkit-scrollbar-corner { + background-color: var(--side-nav-background); +} + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + overflow-x: auto; + overflow-x: overlay; +} + +#nav-tree { + overflow-x: auto; + overflow-y: auto; + overflow-y: overlay; +} + +/* + Scrollbars for Firefox +*/ + +#nav-tree, +div.fragment, +pre.fragment, +div.memproto, +.contents center, +.contents .center, +.contents table:not(.memberdecls):not(.mlabels):not(.fieldtable):not(.memname) tbody, +div.contents .toc { + scrollbar-width: thin; +} + +/* + Optional Dark mode toggle button +*/ + +doxygen-awesome-dark-mode-toggle { + display: inline-block; + margin: 0 0 0 var(--spacing-small); + padding: 0; + width: var(--searchbar-height); + height: var(--searchbar-height); + background: none; + border: none; + border-radius: var(--searchbar-height); + vertical-align: middle; + text-align: center; + line-height: var(--searchbar-height); + font-size: 22px; + display: flex; + align-items: center; + justify-content: center; + user-select: none; + cursor: pointer; +} + +doxygen-awesome-dark-mode-toggle > svg { + transition: transform .1s ease-in-out; +} + +doxygen-awesome-dark-mode-toggle:active > svg { + transform: scale(.5); +} + +doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.03); +} + +html.dark-mode doxygen-awesome-dark-mode-toggle:hover { + background-color: rgba(0,0,0,.18); +} + +/* + Optional fragment copy button +*/ +.doxygen-awesome-fragment-wrapper { + position: relative; +} + +doxygen-awesome-fragment-copy-button { + opacity: 0; + background: var(--fragment-background); + width: 28px; + height: 28px; + position: absolute; + right: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + top: calc(var(--spacing-large) - (var(--spacing-large) / 2.5)); + border: 1px solid var(--fragment-foreground); + cursor: pointer; + border-radius: var(--border-radius-small); + display: flex; + justify-content: center; + align-items: center; +} + +.doxygen-awesome-fragment-wrapper:hover doxygen-awesome-fragment-copy-button, doxygen-awesome-fragment-copy-button.success { + opacity: .28; +} + +doxygen-awesome-fragment-copy-button:hover, doxygen-awesome-fragment-copy-button.success { + opacity: 1 !important; +} + +doxygen-awesome-fragment-copy-button:active:not([class~=success]) svg { + transform: scale(.91); +} + +doxygen-awesome-fragment-copy-button svg { + fill: var(--fragment-foreground); + width: 18px; + height: 18px; +} + +doxygen-awesome-fragment-copy-button.success svg { + fill: rgb(14, 168, 14); +} + +doxygen-awesome-fragment-copy-button.success { + border-color: rgb(14, 168, 14); +} + +@media screen and (max-width: 767px) { + .textblock > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .textblock li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc li > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + .memdoc > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button, + dl dd > .doxygen-awesome-fragment-wrapper > doxygen-awesome-fragment-copy-button { + right: 0; + } +} + +/* + Optional paragraph link button +*/ + +a.anchorlink { + font-size: 90%; + margin-left: var(--spacing-small); + color: var(--page-foreground-color) !important; + text-decoration: none; + opacity: .15; + display: none; + transition: opacity .1s ease-in-out, color .1s ease-in-out; +} + +a.anchorlink svg { + fill: var(--page-foreground-color); +} + +h3 a.anchorlink svg, h4 a.anchorlink svg { + margin-bottom: -3px; + margin-top: -4px; +} + +a.anchorlink:hover { + opacity: .45; +} + +h2:hover a.anchorlink, h1:hover a.anchorlink, h3:hover a.anchorlink, h4:hover a.anchorlink { + display: inline-block; +} + + +#MSearchBox .left { + background: none !important; +} +#MSearchBox .right { + background: none !important; +} diff --git a/dev/dolibarr_changes.txt b/dev/dolibarr_changes.txt index 461db52f959..e12c237e28e 100644 --- a/dev/dolibarr_changes.txt +++ b/dev/dolibarr_changes.txt @@ -209,6 +209,11 @@ with with foreach ($value[1] as $k => $v) { +* Fix by replacing + if ($res[0] == PDF_TYPE_OBJECT) +with + if ($res && $res[0] == PDF_TYPE_OBJECT) + JSGANTT: diff --git a/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt b/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt index e8000035788..549c6e29a1d 100644 --- a/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt +++ b/dev/resources/iso-normes/qr-bar-codes/barcode_EAN13.txt @@ -10,8 +10,7 @@ Signification des chiffres. - 1 chiffre pour la somme de controle Cette regle subit de nombreuses entorses pour ameliorer l'usage des chiffres disponibles. -Voici la liste des codes pays ou systeme : - +Voici la liste des codes pays ou systeme, les préfixes qui ne sont pas explicitement mentionnés sont réservés par GS1 : EN @@ -25,105 +24,139 @@ Meaning of the numbers: This rule has been twisted many times to improve the use of the available numbers. -Here is the list of country codes or system: +Here is the list of country codes or system, prefixes not explicitly listed are reserved by GS1: -List -==== +List (https://www.gs1.org/prefixes) +=================================== -00 - 13 UCC (U.S.A / États-Unis & Canada) -20 - 29 Flag for internal numbering / Codification interne en magasin -30 - 37 GENCOD-EAN France -380 BCCI (Bulgaria) -383 SANA (Slovenia) -385 CRO-EAN (Croatia) -387 EAN-BIH (Bosnia-Herzegovina) -400-440 CCG (DE/Germany/Allemagne) -45 + 49 Distribution Code Center - DCC (Japan) -460-469 UNISCAN - EAN Russia (Federation de Russie) -471 CAN Taiwan -474 EAN Estonia -475 EAN Latvia -476 EAN Azerbaijan -477 EAN Lithuania -478 EAN Uzbekistan -479 EAN Sri Lanka -480 PANC Philippines -481 EAN Belarus -482 EAN Ukraine -484 EAN Moldova -485 EAN Armenia -486 EAN Georgia -487 EAN Kazakhstan -489 HKANA Hong Kong -50 E Centre UK - United Kingdom -520 HELLCAN-EAN HELLAS - Greece -528 EAN Lebanon -529 EAN Cyprus -531 EAN-MAC (FYR Macedonia) -535 EAN Malta -539 EAN Ireland -54 ICODIF/EAN Belgium & Luxembourg -560 CODIPOR (Portugal) -569 EAN Iceland/Islande -57 EAN Denmark -590 EAN Poland -594 EAN Romania -599 H.A.P.M.H. (Hungary) -600-601 EAN South Africa -609 EAN Mauritius Island -611 EAN Morocco -613 EAN Algeria -619 Tunicode (Tunisia) -621 EAN Syria -622 EAN Egypt -625 EAN Jordan/Jordanie -626 EAN Iran -628 EAN Saudi Arabia -64 EAN Finland -690-693 ANCC - Article Numbering Centre of China -70 EAN Norge (Norvege) -729 Israeli Bar Code Association - EAN Israel -73 EAN Suede -740 EAN Guatemala -741 EAN El Salvador -742 ICCC (Honduras) -743 EAN Nicaragua -744 EAN Costa Rica Panama -746 746 EAN Republique Dominicaine -750 AMECE (Mexique) -759 EAN Venezuela -76 EAN (Schweiz, Suisse, Svizzera) -770 IAC (Colombie) -773 EAN Uruguay -775 APC - EAN Peru (Perou) -777 EAN Bolivie -779 CODIGO - EAN Argentine -780 EAN Chili -784 EAN Paraguay -786 ECOP (Equateur) -789 EAN Bresil -80 - 83 INDICOD (Italy) -84 AECOC (Espagne) -850 Camera de Comercio de la Republica de Cuba (Cuba) -858 EAN Slovaquie -859 EAN Republique Tcheque -860 EAN YU (Yougoslavie) -867 EAN DPR Korea (Coree du Nord) -869 Union of Chambers of Commerce of Turkey (Turquie) -87 EAN Nederland (Hollande) -880 EAN Korea (Coree du Sud) -885 EAN Thailande -888 SANC (Singapour) -890 EAN Inde -893 EAN Vietnam -899 EAN Indonesie -90 - 91 EAN Autriche -93 EAN Australie -94 EAN Nouvelle Zelande -955 Malaysian Article Numbering Council (MANC) - Malaisie -977 Publications sirielles (ISSN) -978 - 979 Livres (ISBN) -980 Refus de remboursement -981 - 982 Coupons (monnaie courante) -99 Coupons +0000000 Flag for internal numbering / Codification interne en magasin +00001–01999 GS1 US (U.S.A / États-Unis & Canada) +020-029 Restricted / Restreint +030-039 GS1 US (U.S.A / États-Unis & Canada) +040-049 Flag for internal numbering / Codification interne en magasin +050-059 GS1 US (U.S.A / États-Unis & Canada) +060-139 GS1 US (U.S.A / États-Unis & Canada) +300-379 GS1 France +380 GS1 Bulgaria +383 GS1 Slovenija +385 GS1 Croatia +387 GS1 BIH (Bosnia-Herzegovina) +389 GS1 Montenegro +400-440 GS1 Germany +450-459 GS1 Japan +460-469 GS1 Russia +470 GS1 Kyrgyzstan +471 GS1 Chinese Taipei +474 GS1 Estonia +475 GS1 Latvia +476 GS1 Azerbaijan +477 GS1 Lithuania +478 GS1 Uzbekistan +479 GS1 Sri Lanka +480 GS1 Philippines +481 GS1 Belarus +482 GS1 Ukraine +483 GS1 Turkmenistan +484 GS1 Moldova +485 GS1 Armenia +486 GS1 Georgia +487 GS1 Kazakstan +488 GS1 Tajikistan +489 GS1 Hong Kong, China +490-499 GS1 Japan +500-509 GS1 UK +520-521 GS1 Association Greece +528 GS1 Lebanon +529 GS1 Cyprus +530 GS1 Albania +531 GS1 Macedonia +535 GS1 Malta +539 GS1 Ireland +540-549 GS1 Belgium & Luxembourg +560 GS1 Portugal +569 GS1 Iceland +570-579 GS1 Denmark +590 GS1 Poland +594 GS1 Romania +599 GS1 Hungary +600-601 GS1 South Africa +603 GS1 Ghana +604 GS1 Senegal +607 GS1 Oman +608 GS1 Bahrain +609 GS1 Mauritius +611 GS1 Morocco +613 GS1 Algeria +615 GS1 Nigeria +616 GS1 Kenya +617 GS1 Cameroon +618 GS1 Côte d'Ivoire +619 GS1 Tunisia +620 GS1 Tanzania +621 GS1 Syria +622 GS1 Egypt +624 GS1 Libya +625 GS1 Jordan +626 GS1 Iran +627 GS1 Kuwait +628 GS1 Saudi Arabia +629 GS1 Emirates +630 GS1 Qatar +631 GS1 Namibia +640-649 GS1 Finland +690-699 GS1 China +700-709 GS1 Norway +729 GS1 Israel +730-739 GS1 Sweden +740 GS1 Guatemala +741 GS1 El Salvador +742 GS1 Honduras +743 GS1 Nicaragua +744 GS1 Costa Rica +745 GS1 Panama +746 GS1 Republica Dominicana +750 GS1 Mexico +754-755 GS1 Canada +759 GS1 Venezuela +760-769 GS1 Schweiz, Suisse, Svizzera +770-771 GS1 Colombia +773 GS1 Uruguay +775 GS1 Peru +777 GS1 Bolivia +778-779 GS1 Argentina +780 GS1 Chile +784 GS1 Paraguay +786 GS1 Ecuador +789-790 GS1 Brasil +800-839 GS1 Italy +840-849 GS1 Spain +850 GS1 Cuba +858 GS1 Slovakia +859 GS1 Czech +860 GS1 Serbia +865 GS1 Mongolia +867 GS1 North Korea +868-869 GS1 Türkiye +870-879 GS1 Netherlands +880 GS1 South Korea +883 GS1 Myanmar +884 GS1 Cambodia +885 GS1 Thailand +888 GS1 Singapore +890 GS1 India +893 GS1 Vietnam +896 GS1 Pakistan +899 GS1 Indonesia +900-919 GS1 Austria +930-939 GS1 Australia +940-949 GS1 New Zealand +950 GS1 Global Office +955 GS1 Malaysia +958 GS1 Macao, China +960-969 Global Office - GTIN-8 +977 Serial publications / Publications en série (ISSN) +978-979 Bookland / Livres (ISBN) +980 Refund receipts / Remboursements +981-983 GS1 Coupons +99 GS1 Coupons diff --git a/dev/setup/qodana/README.md b/dev/setup/qodana/README.md new file mode 100644 index 00000000000..37b465cabc9 --- /dev/null +++ b/dev/setup/qodana/README.md @@ -0,0 +1,14 @@ +QODANA TUTO +----------- +This README explains how to use qodana to generate static analytics reports on the code + +Install docker + + +Install qodana + + +To run inspection on CLI + cd ~/git/dirtoscan + sudo qodana scan --show-report + diff --git a/doc/images/dolibarr_screenshot12_1280x800.jpg b/doc/images/dolibarr_screenshot12_1280x800.jpg new file mode 100644 index 00000000000..bdc3a137228 Binary files /dev/null and b/doc/images/dolibarr_screenshot12_1280x800.jpg differ diff --git a/doc/images/dolibarr_screenshot1_1280x800.jpg b/doc/images/dolibarr_screenshot1_1280x800.jpg index ac238d39c1f..6d2c4312394 100644 Binary files a/doc/images/dolibarr_screenshot1_1280x800.jpg and b/doc/images/dolibarr_screenshot1_1280x800.jpg differ diff --git a/doc/images/dolibarr_screenshot2_1280x800.jpg b/doc/images/dolibarr_screenshot2_1280x800.jpg index 2956a55d36a..7f5319942c2 100644 Binary files a/doc/images/dolibarr_screenshot2_1280x800.jpg and b/doc/images/dolibarr_screenshot2_1280x800.jpg differ diff --git a/doc/images/dolibarr_screenshot4_1280x800.jpg b/doc/images/dolibarr_screenshot4_1280x800.jpg new file mode 100644 index 00000000000..d6705363129 Binary files /dev/null and b/doc/images/dolibarr_screenshot4_1280x800.jpg differ diff --git a/doc/images/dolibarr_screenshot5_1280x800.jpg b/doc/images/dolibarr_screenshot5_1280x800.jpg index 6eea0a2f029..f9ddd1d1f77 100644 Binary files a/doc/images/dolibarr_screenshot5_1280x800.jpg and b/doc/images/dolibarr_screenshot5_1280x800.jpg differ diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 2a23ee5eb85..91b7673ab81 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -47,6 +47,7 @@ $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_import_key = GETPOST('search_import_key', 'alpha'); $toselect = GETPOST('toselect', 'array'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $confirm = GETPOST('confirm', 'alpha'); @@ -83,16 +84,19 @@ if (!$sortorder) { } $arrayfields = array( - 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), - 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), - '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.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), - 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) + 'aa.account_number'=>array('label'=>"AccountNumber", 'checked'=>1), + 'aa.label'=>array('label'=>"Label", 'checked'=>1), + 'aa.labelshort'=>array('label'=>"LabelToShow", 'checked'=>1), + 'aa.account_parent'=>array('label'=>"Accountparent", 'checked'=>1), + 'aa.pcg_type'=>array('label'=>"Pcgtype", 'checked'=>1, 'help'=>'PcgtypeDesc'), + 'categories'=>array('label'=>"AccountingCategories", 'checked'=>-1, 'help'=>'AccountingCategoriesDesc'), + 'aa.reconcilable'=>array('label'=>"Reconcilable", 'checked'=>1), + 'aa.active'=>array('label'=>"Activated", 'checked'=>1), + 'aa.import_key'=>array('label'=>"ImportId", 'checked'=>-1) ); if ($conf->global->MAIN_FEATURES_LEVEL < 2) { + unset($arrayfields['categories']); unset($arrayfields['aa.reconcilable']); } @@ -226,15 +230,12 @@ if ($action == 'delete') { $pcgver = $conf->global->CHARTOFACCOUNTS; -$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 = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,"; +$sql .= " aa.reconcilable, aa.active, aa.import_key,"; $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; -if ($db->type == 'pgsql') { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} else { - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; -} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity); +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity); $sql .= " WHERE asy.rowid = ".((int) $pcgver); //print $sql; if (strlen(trim($search_account))) { @@ -337,6 +338,9 @@ if ($resql) { if ($search_pcgtype) { $param .= '&search_pcgtype='.urlencode($search_pcgtype); } + if ($optioncss != '') { + $param .= '&search_import_key='.urlencode($search_import_key); + } if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } @@ -399,7 +403,7 @@ if ($resql) { } print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; print '
'; @@ -436,11 +440,20 @@ if ($resql) { } if (!empty($arrayfields['aa.account_parent']['checked'])) { print ''; - print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); + print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2, array(), 0, 0, 'maxwidth150'); print ''; } + // Predefined group if (!empty($arrayfields['aa.pcg_type']['checked'])) { - print ''; + print ''; + } + // Custom groups + if (!empty($arrayfields['categories']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ''; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) { @@ -471,6 +484,12 @@ if ($resql) { if (!empty($arrayfields['aa.pcg_type']['checked'])) { print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1); } + if (!empty($arrayfields['categories']['checked'])) { + print_liste_field_titre($arrayfields['categories']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '', $arrayfields['categories']['help'], 1); + } + if (!empty($arrayfields['aa.import_key']['checked'])) { + print_liste_field_titre($arrayfields['aa.import_key']['label'], $_SERVER["PHP_SELF"], 'aa.import_key', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.import_key']['help'], 1); + } 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); @@ -505,7 +524,7 @@ if ($resql) { // Account label if (!empty($arrayfields['aa.label']['checked'])) { print ""; - print $obj->label; + print dol_escape_htmltag($obj->label); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -515,7 +534,7 @@ if ($resql) { // Account label to show (label short) if (!empty($arrayfields['aa.labelshort']['checked'])) { print ""; - print $obj->labelshort; + print dol_escape_htmltag($obj->labelshort); print "\n"; if (!$i) { $totalarray['nbfield']++; @@ -549,10 +568,30 @@ if ($resql) { } } - // Chart of accounts type + // Predefined group (deprecated) if (!empty($arrayfields['aa.pcg_type']['checked'])) { print ""; - print $obj->pcg_type; + print dol_escape_htmltag($obj->pcg_type); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Custom accounts + if (!empty($arrayfields['categories']['checked'])) { + print ""; + // TODO Get all custom groups labels the account is in + print dol_escape_htmltag($obj->fk_accounting_category); + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Import id + if (!empty($arrayfields['aa.import_key']['checked'])) { + print ""; + print dol_escape_htmltag($obj->import_key); print "\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/accountancy/admin/accountmodel.php b/htdocs/accountancy/admin/accountmodel.php index 02921a78cb2..c5b8fd20045 100644 --- a/htdocs/accountancy/admin/accountmodel.php +++ b/htdocs/accountancy/admin/accountmodel.php @@ -640,7 +640,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'type_template') { $valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow; } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 9eabd378e11..43d1852c720 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -282,7 +282,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1); print ''; print ''; @@ -329,7 +329,8 @@ if ($action == 'create') { // Account parent print ''.$langs->trans("Accountparent").''; print ''; - print $formaccounting->select_account($object->account_parent, 'account_parent', 1); + // Note: We accept disabled account as parent account so we can build a hierarchy and use only childs + print $formaccounting->select_account($object->account_parent, 'account_parent', 1, array(), 0, 0, 'minwidth100 maxwidth300 maxwidthonsmartphone', 1, ''); print ''; // Chart of accounts type @@ -358,7 +359,7 @@ if ($action == 'create') { print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc")); print ''; print ''; - $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); + print $formaccounting->select_accounting_category($object->account_category, 'account_category', 1); print ''; print ''; diff --git a/htdocs/accountancy/admin/categories.php b/htdocs/accountancy/admin/categories.php index 7b86902e009..7b660419daf 100644 --- a/htdocs/accountancy/admin/categories.php +++ b/htdocs/accountancy/admin/categories.php @@ -1,6 +1,7 @@ * Copyright (C) 2017-2022 Alexandre Spangaro + * Copyright (C) 2022 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 @@ -31,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; $error = 0; // Load translation files required by the page -$langs->loadLangs(array("bills", "accountancy")); +$langs->loadLangs(array("bills", "accountancy", "compta")); $id = GETPOST('id', 'int'); $cancel = GETPOST('cancel', 'alpha'); @@ -44,6 +45,26 @@ if ($cat_id == 0) { $cat_id = null; } +// Load variable for pagination +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters + $page = 0; +} +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; + +if (empty($sortfield)) { + $sortfield = 'account_number'; +} +if (empty($sortorder)) { + $sortorder = 'ASC'; +} + // Security check if (!$user->hasRight('accounting', 'chartofaccount')) { accessforbidden(); @@ -110,18 +131,22 @@ print ''; // Select the category print ''; print ''; +print '
'.$langs->trans("AccountingCategory").''; -$formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 1); -print ''; +print $formaccounting->select_accounting_category($cat_id, 'account_category', 1, 0, 0, 0); +print ''; print '
'; + +print dol_get_fiche_end(); + + // Select the accounts if (!empty($cat_id)) { $return = $accountingcategory->getAccountsWithNoCategory($cat_id); if ($return < 0) { setEventMessages(null, $accountingcategory->errors, 'errors'); } - print ''.$langs->trans("AddAccountFromBookKeepingWithNoCategories").''; - print ''; + print '
'; $arraykeyvalue = array(); foreach ($accountingcategory->lines_cptbk as $key => $val) { @@ -130,33 +155,25 @@ if (!empty($cat_id)) { } if (is_array($accountingcategory->lines_cptbk) && count($accountingcategory->lines_cptbk) > 0) { - print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, null, null, "90%"); - print '
'; - /*print '
'; - print ajax_combobox('cpt_bk'); - */ - print ' '; + print img_picto($langs->trans("AccountingAccount"), 'accounting_account', 'class="pictofixedwith"'); + print $form->multiselectarray('cpt_bk', $arraykeyvalue, GETPOST('cpt_bk', 'array'), null, null, '', 0, "80%", '', '', $langs->transnoentitiesnoconv("AddAccountFromBookKeepingWithNoCategories")); + print ' '; } - print ''; } -print ''; - -print dol_get_fiche_end(); - print ''; -if ($action == 'display' || $action == 'delete') { - print "\n"; +if ((empty($action) || $action == 'display' || $action == 'delete') && $cat_id > 0) { + $param = 'account_category='.((int) $cat_id); + + print '
'; + print '
'."\n"; print ''; - print '"; - print '"; - print "\n"; + print getTitleFieldOfList('AccountAccounting', 0, $_SERVER['PHP_SELF'], 'account_number', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('Label', 0, $_SERVER['PHP_SELF'], 'label', '', $param, '', $sortfield, $sortorder, '')."\n"; + print getTitleFieldOfList('', 0, $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder, '')."\n"; + print ''."\n"; if (!empty($cat_id)) { $return = $accountingcategory->display($cat_id); // This load ->lines_display @@ -165,6 +182,8 @@ if ($action == 'display' || $action == 'delete') { } if (is_array($accountingcategory->lines_display) && count($accountingcategory->lines_display) > 0) { + $accountingcategory->lines_display = dol_sort_array($accountingcategory->lines_display, $sortfield, $sortorder, -1, 0, 1); + foreach ($accountingcategory->lines_display as $cpt) { print ''; print ''; @@ -177,6 +196,8 @@ if ($action == 'display' || $action == 'delete') { print ""; print "\n"; } + } else { + print ''; } } diff --git a/htdocs/accountancy/admin/categories_list.php b/htdocs/accountancy/admin/categories_list.php index 3a6664b8b44..0fd7b9012eb 100644 --- a/htdocs/accountancy/admin/categories_list.php +++ b/htdocs/accountancy/admin/categories_list.php @@ -190,7 +190,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors'); } } - if (!is_numeric(GETPOST('position', 'alpha'))) { + if (GETPOST('position') && !is_numeric(GETPOST('position', 'alpha'))) { $langs->loadLangs(array("errors")); $ok = 0; setEventMessages($langs->transnoentities('ErrorFieldMustBeANumeric', $langs->transnoentities("Position")), null, 'errors'); @@ -444,15 +444,37 @@ if ($search_country_id > 0) { if ($sortfield == 'country') { $sortfield = 'country_code'; } +if (empty($sortfield)) { + $sortfield = 'position'; +} + $sql .= $db->order($sortfield, $sortorder); $sql .= $db->plimit($listlimit + 1, $offset); //print $sql; $fieldlist = explode(',', $tabfield[$id]); +$param = '&id='.$id; +if ($search_country_id > 0) { + $param .= '&search_country_id='.urlencode($search_country_id); +} +$paramwithsearch = $param; +if ($sortorder) { + $paramwithsearch .= '&sortorder='.urlencode($sortorder); +} +if ($sortfield) { + $paramwithsearch .= '&sortfield='.urlencode($sortfield); +} +if (GETPOST('from', 'alpha')) { + $paramwithsearch .= '&from='.urlencode(GETPOST('from', 'alpha')); +} + print ''; print ''; print ''; +print ''; +print ''; + print '
'; print '
'.$langs->trans("AccountAccounting")."'.$langs->trans("Label")."
'.length_accountg($cpt->account_number).'
'.$langs->trans("NoRecordFound").'
'; @@ -571,20 +593,6 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; - $param = '&id='.$id; - if ($search_country_id > 0) { - $param .= '&search_country_id='.urlencode($search_country_id); - } - $paramwithsearch = $param; - if ($sortorder) { - $paramwithsearch .= '&sortorder='.$sortorder; - } - if ($sortfield) { - $paramwithsearch .= '&sortfield='.$sortfield; - } - if (GETPOST('from', 'alpha')) { - $paramwithsearch .= '&from='.GETPOST('from', 'alpha'); - } // There is several pages if ($num > $listlimit) { print ''; $filterfound++; } else { @@ -725,11 +733,11 @@ if ($resql) { print ''; print ''; print ''; print ''; } else { @@ -743,7 +751,8 @@ if ($resql) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'category_type') { $valuetoshow = yn($valuetoshow); } elseif ($valuetoshow == 'all') { @@ -822,7 +831,7 @@ if ($resql) { } // Link to setup the group - print ''; } elseif ($fieldlist[$field] == 'country_id') { diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 9a3b63adcc3..2bd1037db39 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -84,6 +84,9 @@ $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; if (isModEnabled('banque')) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } +if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY)) { + $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'; +} if (isModEnabled('don')) { $list_account[] = 'DONATION_ACCOUNTINGACCOUNT'; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 385c105451e..3a7be3e073e 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -261,6 +261,20 @@ if ($action == 'setenablelettering') { } } +if ($action == 'setenableautolettering') { + $setenableautolettering = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_AUTOLETTERING", $setenableautolettering, 'yesno', 0, '', $conf->entity); + if (!($res > 0)) { + $error++; + } + + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View @@ -430,7 +444,7 @@ foreach ($list_binding as $key) { print $form->selectDate((!empty($conf->global->$key) ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } elseif ($key == 'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER') { $array = array(0=>$langs->trans("PreviousMonth"), 1=>$langs->trans("CurrentMonth"), 2=>$langs->trans("Fiscalyear")); - print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0)); + print $form->selectarray($key, $array, (isset($conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER) ? $conf->global->ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER : 0), 0, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); } else { print ''; } @@ -479,6 +493,7 @@ if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { print ''; print '
'; @@ -605,7 +613,7 @@ if ($resql) { if ($showfield) { if ($value == 'country') { print ''; - print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth150 maxwidthonsmartphone'); print ''; + print '
'; print ''; print ''; - print ''; - print '
'; - print ''; + print ''; + print ''; print '
'; + print ''; if (empty($obj->formula)) { print ''; print $langs->trans("ListOfAccounts"); @@ -887,10 +896,10 @@ function fieldListAccountingCategories($fieldlist, $obj = '', $tabname = '', $co if ($context == 'add') { $fieldname = 'country_id'; $preselectcountrycode = GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : $mysoc->country_code; - print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); } else { $preselectcountrycode = (empty($obj->country_code) ? (empty($obj->country) ? $mysoc->country_code : $obj->country) : $obj->country_code); - print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone'); + print $form->select_country($preselectcountrycode, $fieldname, '', 28, 'maxwidth150 maxwidthonsmartphone'); } print '
'; +print '
'; // Lettering params print ''; @@ -499,6 +514,21 @@ if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { } print ''; +if (!empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) { + print ''; + print ''; + if (!empty($conf->global->ACCOUNTING_ENABLE_AUTOLETTERING)) { + print ''; + } else { + print ''; + } + print ''; +} + print '
' . $langs->trans("ACCOUNTING_ENABLE_AUTOLETTERING") . ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print '
'; print '
'; diff --git a/htdocs/accountancy/admin/journals_list.php b/htdocs/accountancy/admin/journals_list.php index e1a07fef5fc..ba2d867ebd6 100644 --- a/htdocs/accountancy/admin/journals_list.php +++ b/htdocs/accountancy/admin/journals_list.php @@ -587,7 +587,8 @@ if ($id) { foreach ($fieldlist as $field => $value) { $showfield = 1; $class = "left"; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($valuetoshow == 'all') { $valuetoshow = $langs->trans('All'); } elseif ($fieldlist[$field] == 'nature' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { diff --git a/htdocs/accountancy/admin/subaccount.php b/htdocs/accountancy/admin/subaccount.php index c9f78596bcd..40055a4b75f 100644 --- a/htdocs/accountancy/admin/subaccount.php +++ b/htdocs/accountancy/admin/subaccount.php @@ -19,17 +19,18 @@ /** * \file htdocs/accountancy/admin/subaccount.php - * \ingroup Accountancy (Double entries) - * \brief List of accounting sub-account (auxiliary accounts) + * \ingroup Accountancy (Double entries) + * \brief List of accounting sub-account (auxiliary accounts) */ // Load Dolibarr environment require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + // Load translation files required by the page -$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "hrm", "errors")); +$langs->loadLangs(array("accountancy", "admin", "bills", "compta", "errors", "hrm", "salaries")); $mesg = ''; $action = GETPOST('action', 'aZ09'); @@ -81,6 +82,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL < 2) { unset($arrayfields['reconcilable']); } + /* * Actions */ @@ -120,11 +122,13 @@ if (empty($reshook)) { $form = new Form($db); -$help_url = ''; -$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); +// Page Header +$help_url = 'EN:Module_Double_Entry_Accounting#Setup'; +$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger'); llxHeader('', $title, $help_url); + // Customer $sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe sa"; @@ -219,7 +223,7 @@ if (!empty($search_type) && $search_type >= 0) { $sql .= " HAVING type LIKE '".$db->escape($search_type)."'"; } -// User +// User - Employee $sql .= " UNION "; $sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '3' as type, u.entity FROM ".MAIN_DB_PREFIX."user u"; $sql .= " WHERE u.entity IN (".getEntity('user').")"; @@ -400,6 +404,7 @@ if ($resql) { if (!empty($arrayfields['type']['checked'])) { print ''; $s = ''; + // Customer if ($obj->type == 1) { $s .= ''.$langs->trans("Customer").''; @@ -407,8 +412,8 @@ if ($resql) { // Supplier $s .= ''.$langs->trans("Supplier").''; } elseif ($obj->type == 3) { - // User - $s .= ''.$langs->trans("Employee").''; + // User - Employee + $s .= ''.$langs->trans("Employee").''; } print $s; print ''; @@ -440,6 +445,7 @@ if ($resql) { // Action print ''; $e = ''; + // Customer if ($obj->type == 1) { $e .= ''.img_edit().''; @@ -447,7 +453,7 @@ if ($resql) { // Supplier $e .= ''.img_edit().''; } elseif ($obj->type == 3) { - // User + // User - Employee $e .= ''.img_edit().''; } print $e; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 01d89f1168d..fd8cd8ad688 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Florian Henry - * Copyright (C) 2016-2022 Alexandre Spangaro + * Copyright (C) 2016-2023 Alexandre Spangaro * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -42,22 +42,13 @@ $langs->loadLangs(array("accountancy", "compta")); $action = GETPOST('action', 'aZ09'); $optioncss = GETPOST('optioncss', 'alpha'); -$contextpage = GETPOST('contextpage', 'aZ09'); - -// Load variable for pagination -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$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; -$pagenext = $page + 1; -//if (! $sortfield) $sortfield="p.date_fin"; -//if (! $sortorder) $sortorder="DESC"; - +$type = GETPOST('type', 'alpha'); +if ($type == 'sub') { + $context_default = 'balancesubaccountlist'; +} else { + $context_default = 'balancelist'; +} +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : $context_default; $show_subgroup = GETPOST('show_subgroup', 'alpha'); $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int')); $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int')); @@ -70,10 +61,29 @@ $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha'); if ($search_accountancy_code_end == - 1) { $search_accountancy_code_end = ''; } +$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha'); + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$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; +$pagenext = $page + 1; +if ($sortorder == "") { + $sortorder = "ASC"; +} +if ($sortfield == "") { + $sortfield = "t.numero_compte"; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new BookKeeping($db); -$hookmanager->initHooks(array('balancelist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array $formaccounting = new FormAccounting($db); $formother = new FormOther($db); @@ -84,6 +94,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'"; $sql .= $db->plimit(1); $res = $db->query($sql); + if ($res->num_rows > 0) { $fiscalYear = $db->fetch_object($res); $search_date_start = strtotime($fiscalYear->date_start); @@ -104,45 +115,6 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) { $search_date_end = dol_get_last_day($year_end, $month_end); } } -if ($sortorder == "") { - $sortorder = "ASC"; -} -if ($sortfield == "") { - $sortfield = "t.numero_compte"; -} - - -$param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { - $param .= '&contextpage='.urlencode($contextpage); -} -if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); -} - -$filter = array(); -if (!empty($search_date_start)) { - $filter['t.doc_date>='] = $search_date_start; - $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int'); -} -if (!empty($search_date_end)) { - $filter['t.doc_date<='] = $search_date_end; - $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int'); -} -if (!empty($search_accountancy_code_start)) { - $filter['t.numero_compte>='] = $search_accountancy_code_start; - $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); -} -if (!empty($search_accountancy_code_end)) { - $filter['t.numero_compte<='] = $search_accountancy_code_end; - $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); -} -if (!empty($search_ledger_code)) { - $filter['t.code_journal'] = $search_ledger_code; - foreach ($search_ledger_code as $code) { - $param .= '&search_ledger_code[]='.urlencode($code); - } -} if (!isModEnabled('accounting')) { accessforbidden(); @@ -154,14 +126,13 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } - - /* * Action */ -$parameters = array(); -$arrayfields = array(); +$param = ''; + +$parameters = array('socid'=>$socid); $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'); @@ -172,16 +143,67 @@ if (empty($reshook)) { $show_subgroup = ''; $search_date_start = ''; $search_date_end = ''; + $search_date_startyear = ''; + $search_date_startmonth = ''; + $search_date_startday = ''; + $search_date_endyear = ''; + $search_date_endmonth = ''; + $search_date_endday = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; + $search_not_reconciled = ''; $search_ledger_code = array(); $filter = array(); } -} -/* - * View - */ + // Must be after the remove filter action, before the export. + $filter = array(); + + if (!empty($search_date_start)) { + $filter['t.doc_date>='] = $search_date_start; + $param .= '&date_startmonth=' . GETPOST('date_startmonth', 'int') . '&date_startday=' . GETPOST('date_startday', 'int') . '&date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (!empty($search_date_end)) { + $filter['t.doc_date<='] = $search_date_end; + $param .= '&date_endmonth=' . GETPOST('date_endmonth', 'int') . '&date_endday=' . GETPOST('date_endday', 'int') . '&date_endyear=' . GETPOST('date_endyear', 'int'); + } + if (!empty($search_doc_date)) { + $filter['t.doc_date'] = $search_doc_date; + $param .= '&doc_datemonth=' . GETPOST('doc_datemonth', 'int') . '&doc_dateday=' . GETPOST('doc_dateday', 'int') . '&doc_dateyear=' . GETPOST('doc_dateyear', 'int'); + } + if (!empty($search_accountancy_code_start)) { + if ($type == 'sub') { + $filter['t.subledger_account>='] = $search_accountancy_code_start; + } else { + $filter['t.numero_compte>='] = $search_accountancy_code_start; + } + $param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); + } + if (!empty($search_accountancy_code_end)) { + if ($type == 'sub') { + $filter['t.subledger_account<='] = $search_accountancy_code_end; + } else { + $filter['t.numero_compte<='] = $search_accountancy_code_end; + } + $param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); + } + if (!empty($search_ledger_code)) { + $filter['t.code_journal'] = $search_ledger_code; + foreach ($search_ledger_code as $code) { + $param .= '&search_ledger_code[]=' . urlencode($code); + } + } + if (!empty($search_not_reconciled)) { + $filter['t.reconciled_option'] = $search_not_reconciled; + $param .= '&search_not_reconciled='.urlencode($search_not_reconciled); + } + + // param with type of list + $url_param = substr($param, 1); // remove first "&" + if (!empty($type)) { + $param = '&type=' . $type . $param; + } +} if ($action == 'export_csv') { $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; @@ -190,14 +212,23 @@ if ($action == 'export_csv') { $type_export = 'balance'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); + if ($type == 'sub') { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter, 'AND', 1); + } else { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter); + } if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } foreach ($object->lines as $line) { - print '"'.length_accountg($line->numero_compte).'"'.$sep; - print '"'.$object->get_compte_desc($line->numero_compte).'"'.$sep; + if ($type == 'sub') { + print '"' . length_accounta($line->subledger_account) . '"' . $sep; + print '"' . $line->subledger_label . '"' . $sep; + } else { + print '"' . length_accountg($line->numero_compte) . '"' . $sep; + print '"' . $object->get_compte_desc($line->numero_compte) . '"' . $sep; + } print '"'.price($line->debit).'"'.$sep; print '"'.price($line->credit).'"'.$sep; print '"'.price($line->debit - $line->credit).'"'.$sep; @@ -207,8 +238,15 @@ if ($action == 'export_csv') { exit; } +/* + * View + */ -$title_page = $langs->trans("AccountBalance"); +if ($type == 'sub') { + $title_page = $langs->trans("AccountBalanceSubAccount"); +} else { + $title_page = $langs->trans("AccountBalance"); +} llxHeader('', $title_page); @@ -217,39 +255,52 @@ if ($action != 'export_csv') { // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + if ($type == 'sub') { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + } else { + $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter); + } + if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } - $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + if ($type == 'sub') { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + } else { + $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter); + } + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } print ''; + print ''; + print ''; if ($optioncss != '') { print ''; } - print ''; print ''; - print ''; + print ''; print ''; print ''; + print ''; print ''; $parameters = array(); - $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $button = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; + $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; if (empty($reshook)) { - $button .= 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; + $newcardbutton = 'global->ACCOUNTING_EXPORT_FORMAT.')" />'; print ''; + + if ($type == 'sub') { + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + } else { + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?' . $url_param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected')); + $newcardbutton .= dolGetButtonTitle($langs->trans('AccountBalance')." - ".$langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT . '/accountancy/bookkeeping/balance.php?type=sub&' . $url_param, '', 1, array('morecss' => 'marginleftonly')); + } + $newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create'); + } + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); } - print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $selectedfields = ''; + // Warning to explain why list of record is not consistent with the other list view (missing a lot of lines) + if ($type == 'sub') { + print info_admin($langs->trans("WarningRecordWithoutSubledgerAreExcluded")); + } + $moreforfilter = ''; $moreforfilter .= '
'; @@ -275,18 +346,38 @@ if ($action != 'export_csv') { $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0); $moreforfilter .= $langs->trans('DateEnd').': '; $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0); - - $moreforfilter .= ' - '; - $moreforfilter .= ': '; - $moreforfilter .= ''; - $moreforfilter .= '
'; $moreforfilter .= '
'; + $moreforfilter .= ': '; + $moreforfilter .= ''; + $moreforfilter .= '
'; - $moreforfilter .= $langs->trans("Journal"); + $moreforfilter .= '
'; + $moreforfilter .= $langs->trans("Journals").': '; $moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1); + $moreforfilter .= '
'; + $moreforfilter .= '
'; + $moreforfilter .= '
'; + // Accountancy account + $moreforfilter .= $langs->trans('AccountAccounting').': '; + if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200'); + } else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 'accounts'); + } + $moreforfilter .= ' '; + if ($type == 'sub') { + $moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200'); + } else { + $moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 'accounts'); + } + $moreforfilter .= '
'; + + $moreforfilter .= '
'; + $moreforfilter .= ': '; + $moreforfilter .= ''; $moreforfilter .= '
'; if (!empty($moreforfilter)) { @@ -305,9 +396,6 @@ if ($action != 'export_csv') { print ''; print ''; - print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, '', 'accounts'); - print ' '; - print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, '', 'accounts'); print ''; // Fields from hook @@ -324,6 +412,10 @@ if ($action != 'export_csv') { print ''; print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder); + // TODO : Retrieve the type of third party: Customer / Supplier / Employee + //if ($type == 'sub') { + // print_liste_field_titre("Type", $_SERVER['PHP_SELF'], "t.type", "", $param, "", $sortfield, $sortorder); + //} if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder); } @@ -359,7 +451,7 @@ if ($action != 'export_csv') { $sql .= " GROUP BY t.numero_compte"; $resql = $db->query($sql); - $nrows = $db->num_rows($resql); + $nrows = $resql->num_rows; $opening_balances = array(); for ($i = 0; $i < $nrows; $i++) { $arr = $resql->fetch_array(); @@ -372,11 +464,13 @@ if ($action != 'export_csv') { $accountingaccountstatic->id = 0; $accountingaccountstatic->account_number = ''; - $accountingaccountstatic->fetch(null, $line->numero_compte, true); - if (!empty($accountingaccountstatic->account_number)) { - $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard'); - } else { - $accounting_account = length_accountg($line->numero_compte); + if ($type != 'sub') { + $accountingaccountstatic->fetch(null, $line->numero_compte, true); + if (!empty($accountingaccountstatic->account_number)) { + $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 1); + } else { + $accounting_account = length_accountg($line->numero_compte); + } } $link = ''; @@ -427,7 +521,7 @@ if ($action != 'export_csv') { // Show first line of a break print ''; - print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; + print ''.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').''; print ''; $displayed_account = $root_account_number; @@ -438,19 +532,43 @@ if ($action != 'export_csv') { } print ''; - print ''.$accounting_account.''; + // Accounting account + if ($type == 'sub') { + print ''.$line->subledger_account.' ('.$line->subledger_label.')'; + } else { + print ''.$accounting_account.''; + } + + // Type + // TODO Retrieve the type of third party: Customer / Supplier / Employee + //if ($type == 'sub') { + // print ''; + //} + if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) { print ''.price(price2num($opening_balance, 'MT')).''; } $urlzoom = ''; - if ($line->numero_compte) { - $urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte); - if (GETPOSTISSET('date_startmonth')) { - $urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int'); + if ($type == 'sub') { + if ($line->subledger_account) { + $urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?type=sub&search_accountancy_code_start=' . urlencode($line->subledger_account) . '&search_accountancy_code_end=' . urlencode($line->subledger_account); + if (GETPOSTISSET('date_startmonth')) { + $urlzoom .= '&search_date_startmonth=' . GETPOST('date_startmonth', 'int') . '&search_date_startday=' . GETPOST('date_startday', 'int') . '&search_date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (GETPOSTISSET('date_endmonth')) { + $urlzoom .= '&search_date_endmonth=' . GETPOST('date_endmonth', 'int') . '&search_date_endday=' . GETPOST('date_endday', 'int') . '&search_date_endyear=' . GETPOST('date_endyear', 'int'); + } } - if (GETPOSTISSET('date_endmonth')) { - $urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int'); + } else { + if ($line->numero_compte) { + $urlzoom = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . urlencode($line->numero_compte) . '&search_accountancy_code_end=' . urlencode($line->numero_compte); + if (GETPOSTISSET('date_startmonth')) { + $urlzoom .= '&search_date_startmonth=' . GETPOST('date_startmonth', 'int') . '&search_date_startday=' . GETPOST('date_startday', 'int') . '&search_date_startyear=' . GETPOST('date_startyear', 'int'); + } + if (GETPOSTISSET('date_endmonth')) { + $urlzoom .= '&search_date_endmonth=' . GETPOST('date_endmonth', 'int') . '&search_date_endday=' . GETPOST('date_endday', 'int') . '&search_date_endyear=' . GETPOST('date_endyear', 'int'); + } } } // Debit diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index 4620bf37e4e..42ac08383ea 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2022 Waël Almoman * * 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 @@ -44,7 +45,7 @@ $cancel = GETPOST('cancel', 'aZ09'); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); // id of record -$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp' +$mode = $mode = $action == 'create' ? "_tmp" : GETPOST('mode', 'aZ09'); // '' or '_tmp' $piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id) $accountingaccount = new AccountingAccount($db); @@ -54,10 +55,15 @@ $accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml'); $accountingaccount->fetch(null, $accountingaccount_number, true); $accountingaccount_label = $accountingaccount->label; -$journal_code = GETPOST('code_journal', 'alpha'); +$journal_code = GETPOST('code_journal', 'alpha') ? GETPOST('code_journal', 'alpha') : "NULL"; $accountingjournal->fetch(null, $journal_code); $journal_label = $accountingjournal->label; +$next_num_mvt = (int) GETPOST('next_num_mvt', 'alpha'); +$doc_ref = (string) GETPOST('doc_ref', 'alpha'); +$doc_date = (string) GETPOST('doc_date', 'alpha'); +$doc_date = $doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); + $subledger_account = GETPOST('subledger_account', 'alphanohtml'); if ($subledger_account == -1) { $subledger_account = null; @@ -72,6 +78,10 @@ $save = GETPOST('save', 'alpha'); if (!empty($save)) { $action = 'add'; } +$valid = GETPOST('validate', 'alpha'); +if (!empty($valid)) { + $action = 'valid'; +} $update = GETPOST('update', 'alpha'); if (!empty($update)) { $action = 'confirm_update'; @@ -156,64 +166,79 @@ if ($action == "confirm_update") { } } } -} elseif ($action == "add") { +} elseif ($action == 'add' || $action == 'valid') { $error = 0; - if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) { - $error++; - setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); - $action = ''; - } - if (empty($accountingaccount_number) || $accountingaccount_number == '-1') { - $error++; - setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); - $action = ''; + if (array_sum($debit) != array_sum($credit)) { + $action = 'add'; } - if (!$error) { - $object = new BookKeeping($db); + foreach ($accountingaccount_number as $key => $value) { + $accountingaccount->fetch(null, $accountingaccount_number[$key], true); + $accountingaccount_label[$key] = $accountingaccount->label[$key]; - $object->numero_compte = $accountingaccount_number; - $object->subledger_account = $subledger_account; - $object->subledger_label = $subledger_label; - $object->label_compte = $accountingaccount_label; - $object->label_operation = $label_operation; - $object->debit = $debit; - $object->credit = $credit; - $object->doc_date = (string) GETPOST('doc_date', 'alpha'); - $object->doc_type = (string) GETPOST('doc_type', 'alpha'); - $object->piece_num = $piece_num; - $object->doc_ref = (string) GETPOST('doc_ref', 'alpha'); - $object->code_journal = $journal_code; - $object->journal_label = $journal_label; - $object->fk_doc = GETPOSTINT('fk_doc'); - $object->fk_docdet = GETPOSTINT('fk_docdet'); - - if (floatval($debit) != 0.0) { - $object->montant = $debit; // deprecated - $object->amount = $debit; - $object->sens = 'D'; + // if one added row is empty remove it before continue + if ($key < 1 && (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') || (floatval($debit[$key]) == 0.0) && (floatval($credit[$key]) == 0.0)) { + continue; } - if (floatval($credit) != 0.0) { - $object->montant = $credit; // deprecated - $object->amount = $credit; - $object->sens = 'C'; - } - - $result = $object->createStd($user, false, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - } else { - if ($mode != '_tmp') { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - } - - $debit = 0; - $credit = 0; - + if ((floatval($debit[$key]) != 0.0) && (floatval($credit[$key]) != 0.0)) { + $error++; + setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors'); $action = ''; } + + if (empty($accountingaccount_number[$key]) || $accountingaccount_number[$key] == '-1') { + $error++; + setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors'); + $action = ''; + } + + if (!$error) { + $object = new BookKeeping($db); + $object->numero_compte = $accountingaccount_number[$key]; + $object->subledger_account = $subledger_account[$key]; + $object->subledger_label = $subledger_label[$key]; + $object->label_compte = $accountingaccount_label[$key]; + $object->label_operation = $label_operation[$key]; + $object->debit = price2num($debit[$key]); + $object->credit = price2num($credit[$key]); + $object->doc_date = $doc_date; + $object->doc_type = (string) GETPOST('doc_type', 'alpha'); + $object->piece_num = $piece_num; + $object->doc_ref = $doc_ref; + $object->code_journal = $journal_code; + $object->journal_label = $journal_label; + $object->fk_doc = GETPOSTINT('fk_doc'); + $object->fk_docdet = GETPOSTINT('fk_docdet'); + + if (floatval($debit[$key]) != 0.0) { + $object->montant = $object->debit; // deprecated + $object->amount = $object->debit; + $object->sens = 'D'; + } + + if (floatval($credit[$key]) != 0.0) { + $object->montant = $object->credit; // deprecated + $object->amount = $object->credit; + $object->sens = 'C'; + } + + $result = $object->createStd($user, false, $mode); + if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + if (empty($error)) { + if ($mode != '_tmp') { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + } + $debit = 0; + $credit = 0; + + $action = $action == 'add' ? '' : $action ; // stay in valid mode when not adding line } } elseif ($action == "confirm_delete") { $object = new BookKeeping($db); @@ -230,17 +255,28 @@ if ($action == "confirm_update") { } } $action = ''; -} elseif ($action == "confirm_create") { +} elseif ($action == 'create') { $error = 0; $object = new BookKeeping($db); + $next_num_mvt = !empty($next_num_mvt) ? $next_num_mvt : $object->getNextNumMvt('_tmp'); + $doc_ref = !empty($doc_ref) ? $doc_ref : $next_num_mvt; + + if (empty($doc_date)) { + $tmp_date = dol_getdate(dol_now()); + $_POST['doc_dateday'] = $tmp_date['mday']; + $_POST['doc_datemonth'] = $tmp_date['mon']; + $_POST['doc_dateyear'] = $tmp_date['year']; + unset($tmp_date); + } + if (!$journal_code || $journal_code == '-1') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors'); $action = 'create'; $error++; } - if (!GETPOST('doc_ref', 'alpha')) { + if (empty($doc_ref)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors'); $action = 'create'; $error++; @@ -252,8 +288,8 @@ if ($action == "confirm_update") { $object->credit = 0; $object->doc_date = $date_start = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int')); $object->doc_type = GETPOST('doc_type', 'alpha'); - $object->piece_num = GETPOST('next_num_mvt', 'alpha'); - $object->doc_ref = GETPOST('doc_ref', 'alpha'); + $object->piece_num = $next_num_mvt; + $object->doc_ref = $doc_ref; $object->code_journal = $journal_code; $object->journal_label = $journal_label; $object->fk_doc = 0; @@ -302,7 +338,7 @@ if ($action == 'setjournal') { } if ($action == 'setdocref') { - $refdoc = GETPOST('doc_ref', 'alpha'); + $refdoc = $doc_ref; $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode); if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); @@ -333,7 +369,7 @@ if ($action == 'valid') { $html = new Form($db); $formaccounting = new FormAccounting($db); -$title = $langs->trans("CreateMvts"); +$title = $langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"); llxHeader('', $title); @@ -343,28 +379,37 @@ if ($action == 'delete') { print $formconfirm; } -if ($action == 'create') { - print load_fiche_titre($title); - $object = new BookKeeping($db); - $next_num_mvt = $object->getNextNumMvt('_tmp'); +$object = new BookKeeping($db); +$result = $object->fetchPerMvt($piece_num, $mode); +if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); +} - if (empty($next_num_mvt)) { - dol_print_error('', 'Failed to get next piece number'); +if (!empty($object->piece_num)) { + $backlink = ''.$langs->trans('BackToList').''; + + print load_fiche_titre($langs->trans($mode =="_tmp" ? "CreateMvts": "UpdateMvts"), $backlink); + + print ''; if ($optioncss != '') { + print ''; } + $head = array(); + $h = 0; + $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); + $head[$h][1] = $langs->trans("Transaction"); + $head[$h][2] = 'transaction'; + $h++; - print ''; - if ($optioncss != '') { - print ''; - } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; + print dol_get_fiche_head($head, 'transaction', '', -1); - print dol_get_fiche_head(); + //dol_banner_tab($object, '', $backlink); - print ''; + print '
'; + print '
'; + + print '
'; + print '
'; /*print ''; print ''; @@ -374,7 +419,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; @@ -385,294 +430,218 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print ''; /* print ''; print ''; - print ''; + print ''; print ''; */ print '
' . $langs->trans("NumPiece") . '
'.$langs->trans("Docdate").''; - print $html->selectDate('', 'doc_date', '', '', '', "create_mvt", 1, 1); + print $html->selectDate($doc_date, 'doc_date', '', '', '', "create_mvt", 1, 1); print '
'.$langs->trans("Piece").'
' . $langs->trans("Doctype") . '
'; - print dol_get_fiche_end(); + print ''; - print $form->buttonsSaveCancel("Create"); + print '
'; - print ''; -} else { - $object = new BookKeeping($db); - $result = $object->fetchPerMvt($piece_num, $mode); - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + print '
'; + print ''; + + // Doc type + if (!empty($object->doc_type)) { + print ''; + print ''; + print ''; + print ''; } - if (!empty($object->piece_num)) { - $backlink = ''.$langs->trans('BackToList').''; + // Date document creation + print ''; + print ''; + print ''; + print ''; - print load_fiche_titre($langs->trans("UpdateMvts"), $backlink); - - $head = array(); - $h = 0; - $head[$h][0] = $_SERVER['PHP_SELF'].'?piece_num='.$object->piece_num.($mode ? '&mode='.$mode : ''); - $head[$h][1] = $langs->trans("Transaction"); - $head[$h][2] = 'transaction'; - $h++; - - print dol_get_fiche_head($head, 'transaction', '', -1); - - //dol_banner_tab($object, '', $backlink); - - print '
'; - print '
'; - - print '
'; - print '
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''; + print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print '
'; - - // Account movement + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export print ''; - print ''; - print ''; - print ''; - - // Date - print ''; - print ''; - - // Journal - print ''; - print ''; - - // Ref document - print ''; - print ''; - - print '
'.$langs->trans("NumMvts").''.($mode == '_tmp' ? ''.$langs->trans("Draft").'' : $object->piece_num).'
'; - print ''; - if ($action != 'editdate') { - print ''; - } - print '
'; - print $langs->trans('Docdate'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
'; - print '
'; - if ($action == 'editdate') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $form->selectDate($object->doc_date ? $object->doc_date : - 1, 'doc_date', '', '', '', "setdate"); - print ''; - print '
'; - } else { - print $object->doc_date ? dol_print_date($object->doc_date, 'day') : ' '; - } - print '
'; - print ''; - if ($action != 'editjournal') { - print ''; - } - print '
'; - print $langs->trans('Codejournal'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editjournal') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, array(), 1, 1); - print ''; - print '
'; - } else { - print $object->code_journal; - } - print '
'; - print ''; - if ($action != 'editdocref') { - print ''; - } - print '
'; - print $langs->trans('Piece'); - print 'piece_num).'&mode='.urlencode($mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'
'; - print '
'; - if ($action == 'editdocref') { - print '
'; - if ($optioncss != '') { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'; - } else { - print $object->doc_ref; - } - print '
'; - - print '
'; - - print '
'; - - print '
'; - print ''; - - // Doc type - if (!empty($object->doc_type)) { - print ''; - print ''; - print ''; - print ''; - } - - // Date document creation - print ''; - print ''; + print ''; print ''; print ''; - // Don't show in tmp mode, inevitably empty - if ($mode != "_tmp") { - // Date document export - print ''; - print ''; - print ''; - print ''; - - // Date document validation - print ''; - print ''; - print ''; - print ''; - } - - // Validate - /* + // Date document validation print ''; - print ''; + print ''; print ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print ''; print ''; - */ + } + // Validate + /* + print ''; + print ''; + print ''; + print ''; + */ // check data - /* - print ''; - print ''; - if ($object->doc_type == 'customer_invoice') - { - $sqlmid = 'SELECT rowid as ref'; - $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; - $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); - dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); - $resultmid = $db->query($sqlmid); - if ($resultmid) { - $objmid = $db->fetch_object($resultmid); - $invoicestatic = new Facture($db); - $invoicestatic->fetch($objmid->ref); - $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); - } - else dol_print_error($db); - } - print ''; - print ''; - */ - print "
'.$langs->trans("Doctype").''.$object->doc_type.'
'.$langs->trans("DateCreation").''.$langs->trans("DateExport").''; - print $object->date_creation ? dol_print_date($object->date_creation, 'day') : ' '; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; print '
' . $langs->trans("DateExport") . ''; - print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; - print '
' . $langs->trans("DateValidation") . ''; - print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; - print '
' . $langs->trans("Status") . ''.$langs->trans("DateValidation").''; - if (empty($object->validated)) { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } - print '
' . $langs->trans("Status") . ''; + if (empty($object->validated)) { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + } else { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + } + print '
' . $langs->trans("Control") . '' . $ref .'
\n"; - - print '
'; - - print dol_get_fiche_end(); - - print '
'; - - print '
'; - - $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt - - if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + /* + print ''; + print '' . $langs->trans("Control") . ''; + if ($object->doc_type == 'customer_invoice') { + $sqlmid = 'SELECT rowid as ref'; + $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac"; + $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc); + dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG); + $resultmid = $db->query($sqlmid); + if ($resultmid) { + $objmid = $db->fetch_object($resultmid); + $invoicestatic = new Facture($db); + $invoicestatic->fetch($objmid->ref); + $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1); } else { - // List of movements - print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + dol_print_error($db); + } + } + print '' . $ref .''; + print ''; + */ + print "\n"; - print '
'; - if ($optioncss != '') { - print ''; + print dol_get_fiche_end(); + + print '
'; + + print '
'; + + $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } else { + // List of movements + print load_fiche_titre($langs->trans("ListeMvts"), '', ''); + + if ($optioncss != '') { + print ''; + } + + print ''; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + if (count($object->linesmvt) > 0) { + print '
'; + print ''; + + $total_debit = 0; + $total_credit = 0; + + // Don't show in tmp mode, inevitably empty + if ($mode != "_tmp") { + // Date document export + print ''; + print ''; + print ''; + print ''; + + // Date document validation + print ''; + print ''; + print ''; + print ''; } - print ''; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - print ''."\n"; - if (count($object->linesmvt) > 0) { - print '
'; - print '
' . $langs->trans("DateExport") . ''; + print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : ' '; + print '
' . $langs->trans("DateValidation") . ''; + print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : ' '; + print '
'; + print ''; - $total_debit = 0; - $total_credit = 0; + print_liste_field_titre("AccountAccountingShort"); + print_liste_field_titre("SubledgerAccount"); + print_liste_field_titre("LabelOperation"); + print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); + print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); + if (empty($object->date_validation)) { + print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); + } else { + print_liste_field_titre(""); + } - print ''; + print "\n"; - print_liste_field_titre("AccountAccountingShort"); - print_liste_field_titre("SubledgerAccount"); - print_liste_field_titre("LabelOperation"); - print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"'); - print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"'); - if (empty($object->date_validation)) { - print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center '); - } else { - print_liste_field_titre(""); - } + // In _tmp mode the first line is empty so we remove it + if ($mode == "_tmp") { + array_shift($object->linesmvt); + } - print "\n"; + // Add an empty line at the end to be able to add transaction + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; - // Add an empty line if there is not yet - if (!empty($object->linesmvt[0])) { - $tmpline = $object->linesmvt[0]; - if (!empty($tmpline->numero_compte)) { - $line = new BookKeepingLine(); - $object->linesmvt[] = $line; + // Add a second line empty line if there is not yet + if (empty($object->linesmvt[1])) { + $line = new BookKeepingLine(); + $object->linesmvt[] = $line; + } + + $count_line = count($object->linesmvt); + $num_line = 0; + foreach ($object->linesmvt as $key => $line) { + $num_line++; + print ''; + $total_debit += $line->debit; + $total_credit += $line->credit; + + if ($action == 'update' && $line->id == $id) { + print ''; + print ''; + print ''; - $total_debit += $line->debit; - $total_credit += $line->credit; - - if ($action == 'update' && $line->id == $id) { - print ''; + // Add also input for subledger label + print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'" />'; + print ''; + print ''; + print ''; + print ''; + print ''; + } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { + if ($action == "" || $action == 'add') { + print ''; print ''; print ''; - print ''; - print ''; - print ''; - print ''; - } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) { - if ($action == "" || $action == 'add') { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - } else { - print ''; - $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); - print ''; + print ''; + print ''; + // Add button should not appear twice + if ($num_line === $count_line) { + print ''; } else { - print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + print ''; } - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; } - print "\n"; - } - - $total_debit = price2num($total_debit, 'MT'); - $total_credit = price2num($total_credit, 'MT'); - - if ($total_debit != $total_credit) { - setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); - } - - print '
'; + print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, ''); + print ''; + // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: + // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. + // Also, it is not possible to use a value that is not in the list. + // Also, the label is not automatically filled when a value is selected. + if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + } else { + print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'" />'; } - } - - foreach ($object->linesmvt as $line) { - print '
label_operation).'" />debit)).'" />credit)).'" />'; + print ''."\n"; + print ''; + print ''; - print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); + print $formaccounting->select_account((is_array($accountingaccount_number) ? $accountingaccount_number[$key] : $accountingaccount_number ), 'accountingaccount_number['.$key.']', 1, array(), 1, 1, ''); print ''; // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: @@ -680,124 +649,102 @@ if ($action == 'create') { // Also, it is not possible to use a value that is not in the list. // Also, the label is not automatically filled when a value is selected. if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); + print $formaccounting->select_auxaccount((is_array($subledger_account) ? $subledger_account[$key] : $subledger_account ), 'subledger_account['.$key.']', 1, 'maxwidth250', '', 'subledger_label'); } else { - print 'subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">'; + print ''; } - // Add also input for subledger label - print '
subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">'; + print '
'; print '
label_operation).'">debit)).'">credit)).'">'; - print ''."\n"; - print ''; - print ''; - print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500'); - print ''; - // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because: - // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases. - // Also, it is not possible to use a value that is not in the list. - // Also, the label is not automatically filled when a value is selected. - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label'); - } else { - print ''; - } - print '
'; - print '
'; - if ($resultfetch > 0) { - print $accountingaccount->getNomUrl(0, 1, 1, '', 0); + print ''.length_accounta($line->subledger_account); - if ($line->subledger_label) { - print ' - '.$line->subledger_label.''; - } - print ''.$line->label_operation.''.($line->debit != 0 ? price($line->debit) : '').''.($line->credit != 0 ? price($line->credit) : '').''; - if (empty($line->date_export) && empty($line->date_validation)) { - print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; - print img_edit('', 0, 'class="marginrightonly"'); - print '  '; - } else { - print ''; - print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); - print '  '; - } - - if (empty($line->date_validation)) { - $actiontodelete = 'delete'; - if ($mode == '_tmp' || $action != 'delmouv') { - $actiontodelete = 'confirm_delete'; - } - - print ''; - print img_delete(); - print ''; - } else { - print ''; - print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); - print ''; - } - - print '
'; - print '
'; - - if ($mode == '_tmp' && $action == '') { - print '
'; - print '
'; - if ($total_debit == $total_credit) { - print ''.$langs->trans("ValidTransaction").''; + } else { + print ''; + $resultfetch = $accountingaccount->fetch(null, $line->numero_compte, true); + print ''; + if ($resultfetch > 0) { + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); } else { - print ''; + print $line->numero_compte.' ('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')'; + } + print ''; + print ''.length_accounta($line->subledger_account); + if ($line->subledger_label) { + print ' - '.$line->subledger_label.''; + } + print ''; + print ''.$line->label_operation.''; + print ''.($line->debit != 0 ? price($line->debit) : '').''; + print ''.($line->credit != 0 ? price($line->credit) : '').''; + + print ''; + if (empty($line->date_export) && empty($line->date_validation)) { + print 'id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">'; + print img_edit('', 0, 'class="marginrightonly"'); + print '  '; + } else { + print ''; + print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"'); + print '  '; } - print '   '; - print ''.$langs->trans("Cancel").''; + if (empty($line->date_validation)) { + $actiontodelete = 'delete'; + if ($mode == '_tmp' || $action != 'delmouv') { + $actiontodelete = 'confirm_delete'; + } - print "
"; + print ''; + print img_delete(); + print ''; + } else { + print ''; + print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated")); + print ''; + } + + print ''; } + print "\n"; } - print '
'; + $total_debit = price2num($total_debit, 'MT'); + $total_credit = price2num($total_credit, 'MT'); + + if ($total_debit != $total_credit) { + setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings'); + } + + print ''; + print ''; + + if ($mode == '_tmp' && $action == '') { + print '
'; + print '
'; + if ($total_debit == $total_credit) { + print ''; + } else { + print ''; + } + + print '   '; + print ''.$langs->trans("Cancel").''; + + print "
"; + } } - } else { - print load_fiche_titre($langs->trans("NoRecords")); + + print ''; } +} else { + print load_fiche_titre($langs->trans("NoRecords")); } print dol_get_fiche_end(); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 2b2df70d647..23bb513a85b 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -2,8 +2,10 @@ /* Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2022 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016-2017 Laurent Destailleur * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2022 Progiseize * * 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 @@ -102,7 +104,9 @@ if (GETPOST("button_export_file_x") || GETPOST("button_export_file.x") || GETPOS $action = 'export_file'; } -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + +$search_accountancy_code = GETPOST("search_accountancy_code", 'alpha'); $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -253,6 +257,7 @@ if (empty($reshook)) { $search_doc_type = ''; $search_doc_ref = ''; $search_doc_date = ''; + $search_account_category = ''; $search_accountancy_code = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; @@ -335,6 +340,20 @@ if (empty($reshook)) { $filter['t.doc_ref'] = $search_doc_ref; $param .= '&search_doc_ref='.urlencode($search_doc_ref); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code)) { $filter['t.numero_compte'] = $search_accountancy_code; $param .= '&search_accountancy_code='.urlencode($search_accountancy_code); @@ -474,7 +493,7 @@ if (empty($reshook)) { if ($conf->global->ACCOUNTING_REEXPORT == 1) { setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsEnable"), null, 'mesgs'); } else { - setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'mesgs'); + setEventMessages($langs->trans("ExportOfPiecesAlreadyExportedIsDisable"), null, 'warnings'); } } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -642,6 +661,9 @@ $sql .= " t.tms as date_modification,"; $sql .= " t.date_export,"; $sql .= " t.date_validated as date_validation,"; $sql .= " t.import_key"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= ' FROM '.MAIN_DB_PREFIX.$object->table_element.' as t'; // Manage filter $sqlwhere = array(); @@ -672,7 +694,13 @@ if (count($filter) > 0) { } elseif ($key == 't.reconciled_option') { $sqlwhere[] = 't.lettering_code IS NULL'; } elseif ($key == 't.code_journal' && !empty($value)) { - $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + if (is_array($value)) { + $sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1); + } else { + $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); + } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } @@ -685,9 +713,6 @@ if (empty($conf->global->ACCOUNTING_REEXPORT)) { if (count($sqlwhere) > 0) { $sql .= ' AND '.implode(' AND ', $sqlwhere); } -if (!empty($sortfield)) { - $sql .= $db->order($sortfield, $sortorder); -} //print $sql; @@ -715,58 +740,62 @@ if ($action == 'export_fileconfirm' && $user->hasRight('accounting', 'mouvements } } - $mimetype = $accountancyexport->getMimeType($formatexportset); - - top_httphead($mimetype, 1); - - // Output data on screen - $accountancyexport->export($object->lines, $formatexportset); - $notifiedexportdate = GETPOST('notifiedexportdate', 'alpha'); $notifiedvalidationdate = GETPOST('notifiedvalidationdate', 'alpha'); + $withAttachment = !empty(trim(GETPOST('notifiedexportfull', 'alphanohtml'))) ? 1 : 0; - if (!empty($accountancyexport->errors)) { - dol_print_error('', '', $accountancyexport->errors); - } elseif (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { - // Specify as export : update field date_export or date_validated - $error = 0; - $db->begin(); + // Output data on screen or download + $result = $accountancyexport->export($object->lines, $formatexportset, $withAttachment); - if (is_array($object->lines)) { - foreach ($object->lines as $movement) { - $now = dol_now(); + $error = 0; + if ($result < 0) { + $error++; + } else { + if (!empty($notifiedexportdate) || !empty($notifiedvalidationdate)) { + if (is_array($object->lines)) { + // Specify as export : update field date_export or date_validated + $db->begin(); - $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; - $sql .= " SET"; - if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - $sql .= ", date_validated = '".$db->idate($now)."'"; - } elseif (!empty($notifiedexportdate)) { - $sql .= " date_export = '".$db->idate($now)."'"; - } elseif (!empty($notifiedvalidationdate)) { - $sql .= " date_validated = '".$db->idate($now)."'"; + foreach ($object->lines as $movement) { + $now = dol_now(); + + $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; + $sql .= " SET"; + if (!empty($notifiedexportdate) && !empty($notifiedvalidationdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + $sql .= ", date_validated = '".$db->idate($now)."'"; + } elseif (!empty($notifiedexportdate)) { + $sql .= " date_export = '".$db->idate($now)."'"; + } elseif (!empty($notifiedvalidationdate)) { + $sql .= " date_validated = '".$db->idate($now)."'"; + } + $sql .= " WHERE rowid = ".((int) $movement->id); + + dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); + + $result = $db->query($sql); + if (!$result) { + $error++; + break; + } } - $sql .= " WHERE rowid = ".((int) $movement->id); - dol_syslog("/accountancy/bookkeeping/list.php Function export_file Specify movements as exported", LOG_DEBUG); - - $result = $db->query($sql); - if (!$result) { + if (!$error) { + $db->commit(); + } else { $error++; - break; + $accountancyexport->errors[] = $langs->trans('NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated'); + $db->rollback(); } } } - - if (!$error) { - $db->commit(); - } else { - $error++; - $db->rollback(); - dol_print_error('', $langs->trans("NotAllExportedMovementsCouldBeRecordedAsExportedOrValidated")); - } } - exit; + + if ($error) { + setEventMessages('', $accountancyexport->errors, 'errors'); + header('Location: '.$_SERVER['PHP_SELF']); + } + exit(); // download or show errors } } @@ -783,28 +812,38 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals"); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { - $num = $nbtotalofrecords; -} else { + +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); // Output page @@ -854,7 +893,17 @@ if ($action == 'export_file') { $form_question['separator3'] = array('name'=>'separator3', 'type'=>'separator'); } - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 350, 600); + // add documents in an archive for accountancy export (Quadratus) + if (getDolGlobalString('ACCOUNTING_EXPORT_MODELCSV') == AccountancyExport::$EXPORT_TYPE_QUADRATUS) { + $form_question['notifiedexportfull'] = array( + 'name' => 'notifiedexportfull', + 'type' => 'checkbox', + 'label' => $langs->trans('NotifiedExportFull'), + 'value' => 'false', + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 400, 600); } //if ($action == 'delbookkeepingyear') { @@ -953,11 +1002,14 @@ $newcardbutton = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint; if (empty($reshook)) { // Button re-export if (!empty($conf->global->ACCOUNTING_REEXPORT)) { - $newcardbutton .= ''.img_picto($langs->trans("Activated"), 'switch_on').' '; + $newcardbutton .= ''.img_picto($langs->trans("ClickToHideAlreadyExportedLines"), 'switch_off', 'class="small size15x valignmiddle"'); + $newcardbutton .= ''.$langs->trans("ClickToHideAlreadyExportedLines").''; + $newcardbutton .= ''; } else { - $newcardbutton .= ''.img_picto($langs->trans("Disabled"), 'switch_off').' '; + $newcardbutton .= ''.img_picto($langs->trans("DocsAlreadyExportedAreExcluded"), 'switch_on', 'class="warning size15x valignmiddle"').''; + $newcardbutton .= ''.$langs->trans("DocsAlreadyExportedAreExcluded").''; + $newcardbutton .= ''; } - $newcardbutton .= ''.$langs->trans("IncludeDocsAlreadyExported").''; if ($user->hasRight('accounting', 'mouvements', 'export')) { $newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file&token='.newToken().($param ? '&'.$param : ''), $user->hasRight('accounting', 'mouvements', 'export')); @@ -991,23 +1043,33 @@ if ($massaction == 'preunletteringauto') { include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields if ($massactionbutton && $contextpage != 'poslist') { $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); } $moreforfilter = ''; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; $parameters = array(); -$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { $moreforfilter .= $hookmanager->resPrint; } else { $moreforfilter = $hookmanager->resPrint; } +print '
'; +print $moreforfilter; +print '
'; + print '
'; -print ''; +print '
'; // Filters lines print ''; @@ -1163,8 +1225,7 @@ print "\n"; print ''; if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); -} + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn ');} if (!empty($arrayfields['t.piece_num']['checked'])) { print_liste_field_titre($arrayfields['t.piece_num']['label'], $_SERVER['PHP_SELF'], "t.piece_num", "", $param, "", $sortfield, $sortorder); } @@ -1511,6 +1572,16 @@ while ($i < min($num, $limit)) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/bookkeeping/listbyaccount.php b/htdocs/accountancy/bookkeeping/listbyaccount.php index 4a6e37ceb29..78aea811a5d 100644 --- a/htdocs/accountancy/bookkeeping/listbyaccount.php +++ b/htdocs/accountancy/bookkeeping/listbyaccount.php @@ -79,7 +79,8 @@ $search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_star $search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear); $search_import_key = GETPOST("search_import_key", 'alpha'); -$search_accountancy_code = GETPOST("search_accountancy_code"); +$search_account_category = GETPOST('search_account_category', 'int'); + $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha'); if ($search_accountancy_code_start == - 1) { $search_accountancy_code_start = ''; @@ -198,6 +199,8 @@ if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } +$error = 0; + /* * Action @@ -224,7 +227,7 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_doc_date = ''; - $search_accountancy_code = ''; + $search_account_category = ''; $search_accountancy_code_start = ''; $search_accountancy_code_end = ''; $search_label_account = ''; @@ -280,6 +283,20 @@ if (empty($reshook)) { $filter['t.doc_date'] = $search_doc_date; $param .= '&doc_datemonth='.GETPOST('doc_datemonth', 'int').'&doc_dateday='.GETPOST('doc_dateday', 'int').'&doc_dateyear='.GETPOST('doc_dateyear', 'int'); } + if ($search_account_category != '-1' && !empty($search_account_category)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php'; + $accountingcategory = new AccountancyCategory($db); + + $listofaccountsforgroup = $accountingcategory->getCptsCat(0, 'fk_accounting_category = '.((int) $search_account_category)); + $listofaccountsforgroup2 = array(); + if (is_array($listofaccountsforgroup)) { + foreach ($listofaccountsforgroup as $tmpval) { + $listofaccountsforgroup2[] = "'".$db->escape($tmpval['id'])."'"; + } + } + $filter['t.search_accounting_code_in'] = join(',', $listofaccountsforgroup2); + $param .= '&search_account_category='.urlencode($search_account_category); + } if (!empty($search_accountancy_code_start)) { if ($type == 'sub') { $filter['t.subledger_account>='] = $search_accountancy_code_start; @@ -358,7 +375,6 @@ if (empty($reshook)) { $filter['t.import_key'] = $search_import_key; $param .= '&search_import_key='.urlencode($search_import_key); } - // param with type of list $url_param = substr($param, 1); // remove first "&" if (!empty($type)) { @@ -544,25 +560,29 @@ llxHeader('', $title_page); // List $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + // TODO Perf Replace this by a count if ($type == 'sub') { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1, 1); } else { - $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter); + $nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 0, 1); } if ($nbtotalofrecords < 0) { setEventMessages($object->error, $object->errors, 'errors'); + $error++; } } -if ($type == 'sub') { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); -} else { - $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter); -} +if (!$error) { + if ($type == 'sub') { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1); + } else { + $result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 0); + } -if ($result < 0) { - setEventMessages($object->error, $object->errors, 'errors'); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } } $arrayofselected = is_array($toselect) ? $toselect : array(); @@ -711,7 +731,7 @@ if ($type == 'sub') { $moreforfilter = ''; -// Accountancy account +// Search on accountancy custom groups or account $moreforfilter .= '
'; $moreforfilter .= $langs->trans('AccountAccounting').': '; $moreforfilter .= '
'; @@ -729,6 +749,13 @@ if ($type == 'sub') { $moreforfilter .= '
'; $moreforfilter .= '
'; +$moreforfilter .= '
'; +$moreforfilter .= $langs->trans('AccountingCategory').': '; +$moreforfilter .= '
'; +$moreforfilter .= $formaccounting->select_accounting_category($search_account_category, 'search_account_category', 1, 0, 0, 0); +$moreforfilter .= '
'; +$moreforfilter .= '
'; + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) { @@ -935,8 +962,8 @@ while ($i < min($num, $limit)) { } else { print ''; } - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -945,13 +972,13 @@ while ($i < min($num, $limit)) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; @@ -1206,8 +1233,8 @@ while ($i < min($num, $limit)) { if ($num > 0 && $colspan > 0) { print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print ''; // Show balance of last shown account @@ -1216,22 +1243,42 @@ if ($num > 0 && $colspan > 0) { print ''; if ($balance > 0) { print ''; print ''; } else { print ''; print ''; } print ''; print ''; } + +// Clean total values to round them +if (!empty($totalarray['val']['totaldebit'])) { + $totalarray['val']['totaldebit'] = price2num($totalarray['val']['totaldebit'], 'MT'); +} +if (!empty($totalarray['val']['totalcredit'])) { + $totalarray['val']['totalcredit'] = price2num($totalarray['val']['totalcredit'], 'MT'); +} + + // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; +} $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 68662ccb610..d68f4e79f5e 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -353,7 +353,7 @@ class AccountancyCategory // extends CommonObject $sql .= " formula=".(isset($this->formula) ? "'".$this->db->escape($this->formula)."'" : "null").","; $sql .= " position=".(isset($this->position) ? $this->position : "null").","; $sql .= " fk_country=".(isset($this->fk_country) ? $this->fk_country : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " active=".(isset($this->active) ? $this->active : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -446,7 +446,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -488,7 +488,7 @@ class AccountancyCategory // extends CommonObject } else { $this->error = "Error ".$this->db->lasterror(); $this->errors[] = $this->error; - dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); + dol_syslog(__METHOD__." ".implode(',', $this->errors), LOG_ERR); return -1; } @@ -605,60 +605,6 @@ class AccountancyCategory // extends CommonObject } } - /** - * Function to know all custom groupd from an accounting account - * - * @return array|integer Result in table (array), -1 if KO - */ - public function getCatsCpts() - { - global $mysoc, $conf; - - if (empty($mysoc->country_id)) { - dol_print_error('', 'Call to select_accounting_account with mysoc country not yet defined'); - exit(); - } - - $sql = "SELECT t.rowid, t.account_number, t.label as account_label, cat.code, cat.position, cat.label as name_cat, cat.sens "; - $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; - $sql .= " WHERE t.fk_accounting_category IN ( SELECT c.rowid "; - $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; - $sql .= " WHERE c.active = 1"; - $sql .= " AND c.entity = ".$conf->entity; - $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; - $sql .= " AND cat.rowid = t.fk_accounting_category"; - $sql .= " AND t.entity = ".$conf->entity; - $sql .= " ORDER BY cat.position ASC"; - - $resql = $this->db->query($sql); - if ($resql) { - $i = 0; - $obj = ''; - $num = $this->db->num_rows($resql); - $data = array(); - if ($num) { - while ($obj = $this->db->fetch_object($resql)) { - $name_cat = $obj->name_cat; - $data[$name_cat][$i] = array( - 'id' => $obj->rowid, - 'code' => $obj->code, - 'position' => $obj->position, - 'account_number' => $obj->account_number, - 'account_label' => $obj->account_label, - 'sens' => $obj->sens - ); - $i++; - } - } - return $data; - } else { - $this->error = "Error ".$this->db->lasterror(); - dol_syslog(__METHOD__." ".$this->error, LOG_ERR); - - return -1; - } - } - /** * Function to show result of an accounting account from the ledger with a direction and a period * @@ -678,6 +624,22 @@ class AccountancyCategory // extends CommonObject $this->sdc = 0; $this->sdcpermonth = array(); + if (is_array($cpt)) { + $listofaccount = ''; + foreach ($cpt as $cptcursor) { + if (! is_null($cptcursor)) { + if ($listofaccount) { + $listofaccount .= ","; + } + $listofaccount .= "'".$cptcursor."'"; + } + } + if (empty($listofaccount)) { + // List of account is empty, so we do no try sql request, we can say result is empty. + return 0; + } + } + $sql = "SELECT SUM(t.debit) as debit, SUM(t.credit) as credit"; if (is_array($cpt)) { $sql .= ", t.numero_compte as accountancy_account"; @@ -686,13 +648,6 @@ class AccountancyCategory // extends CommonObject //if (in_array($this->db->type, array('mysql', 'mysqli'))) $sql.=' USE INDEX idx_accounting_bookkeeping_doc_date'; $sql .= " WHERE t.entity = ".$conf->entity; if (is_array($cpt)) { - $listofaccount = ''; - foreach ($cpt as $cptcursor) { - if ($listofaccount) { - $listofaccount .= ","; - } - $listofaccount .= "'".$cptcursor."'"; - } $sql .= " AND t.numero_compte IN (".$this->db->sanitize($listofaccount, 1).")"; } else { $sql .= " AND t.numero_compte = '".$this->db->escape($cpt)."'"; @@ -709,22 +664,28 @@ class AccountancyCategory // extends CommonObject if (is_array($cpt)) { $sql .= " GROUP BY t.numero_compte"; } - //print $sql; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $obj = $this->db->fetch_object($resql); - if ($sens == 1) { - $this->sdc = $obj->debit - $obj->credit; - } else { - $this->sdc = $obj->credit - $obj->debit; - } - if (is_array($cpt)) { - $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + $i = 0; + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + if ($sens == 1) { + $this->sdc = $obj->debit - $obj->credit; + } else { + $this->sdc = $obj->credit - $obj->debit; + } + if (is_array($cpt)) { + $this->sdcperaccount[$obj->accountancy_account] = $this->sdc; + } + } + $i++; } } + return $num; } else { $this->error = "Error ".$this->db->lasterror(); @@ -734,12 +695,75 @@ class AccountancyCategory // extends CommonObject } } + /** + * Function to get an array of all active custom groups (llx_c_accunting_categories) with their accounts from the chart of account (ll_accounting_acount) + * + * @param int $catid Custom group ID + * @return array|integer Result in table (array), -1 if KO + * @see getCats(), getCptsCat() + */ + public function getCatsCpts($catid = 0) + { + global $mysoc, $conf; + + if (empty($mysoc->country_id)) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + + $sql = "SELECT t.rowid, t.account_number, t.label as account_label,"; + $sql .= " cat.code, cat.position, cat.label as name_cat, cat.sens, cat.category_type, cat.formula"; + $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t, ".MAIN_DB_PREFIX."c_accounting_category as cat"; + $sql .= " WHERE t.fk_accounting_category IN (SELECT c.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_accounting_category as c"; + $sql .= " WHERE c.active = 1"; + $sql .= " AND c.entity = ".$conf->entity; + $sql .= " AND (c.fk_country = ".((int) $mysoc->country_id)." OR c.fk_country = 0)"; + $sql .= " AND cat.rowid = t.fk_accounting_category"; + $sql .= " AND t.entity = ".$conf->entity; + if ($catid > 0) { + $sql .= " AND cat.rowid = ".((int) $catid); + } + $sql .= " ORDER BY cat.position ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $obj = ''; + $num = $this->db->num_rows($resql); + $data = array(); + if ($num) { + while ($obj = $this->db->fetch_object($resql)) { + $name_cat = $obj->name_cat; + $data[$name_cat][$obj->rowid] = array( + 'id' => $obj->rowid, + 'code' => $obj->code, + 'label' => $obj->label, + 'position' => $obj->position, + 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, + 'account_number' => $obj->account_number, + 'account_label' => $obj->account_label + ); + } + } + return $data; + } else { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(__METHOD__." ".$this->error, LOG_ERR); + return -1; + } + } + /** * Return list of custom groups. + * For list + detail of accounting account, see getCatsCpt() * * @param int $categorytype -1=All, 0=Only non computed groups, 1=Only computed groups * @param int $active 1= active, 0=not active * @return array|int Array of groups or -1 if error + * @see getCatsCpts(), getCptsCat() */ public function getCats($categorytype = -1, $active = 1) { @@ -774,9 +798,10 @@ class AccountancyCategory // extends CommonObject 'rowid' => $obj->rowid, 'code' => $obj->code, 'label' => $obj->label, - 'formula' => $obj->formula, 'position' => $obj->position, 'category_type' => $obj->category_type, + 'formula' => $obj->formula, + 'sens' => $obj->sens, 'bc' => $obj->sens ); $i++; @@ -794,12 +819,15 @@ class AccountancyCategory // extends CommonObject /** - * Get all accounting account of a custom group (or a list of custom groups). + * Get all accounting account of a given custom group (or a list of custom groups). * You must choose between first parameter (personalized group) or the second (free criteria filter) * * @param int $cat_id Id if personalized accounting group/category - * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must not come from an input of a user. + * @param string $predefinedgroupwhere Sql criteria filter to select accounting accounts. This value must be sanitized and not come from an input of a user. + * Example: "pcg_type = 'EXPENSE' AND fk_pcg_version = 'xx'" + * Example: "fk_accounting_category = 99" * @return array|int Array of accounting accounts or -1 if error + * @see getCats(), getCatsCpts() */ public function getCptsCat($cat_id, $predefinedgroupwhere = '') { diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 3c45315ffa9..d34f89d95d3 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -5,13 +5,15 @@ * Copyright (C) 2015 Florian Henry * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Pierre-Henry Favre - * Copyright (C) 2016-2021 Alexandre Spangaro + * Copyright (C) 2016-2023 Alexandre Spangaro + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz * Copyright (C) 2017-2019 Frédéric France * Copyright (C) 2017 André Schild * Copyright (C) 2020 Guillaume Alexandre * Copyright (C) 2022 Joachim Kueter + * Copyright (C) 2022 Progiseize * * 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 @@ -36,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; /** @@ -200,7 +203,7 @@ class AccountancyExport 'ACCOUNTING_EXPORT_FORMAT' => empty($conf->global->ACCOUNTING_EXPORT_FORMAT) ? 'txt' : $conf->global->ACCOUNTING_EXPORT_FORMAT, 'ACCOUNTING_EXPORT_SEPARATORCSV' => empty($conf->global->ACCOUNTING_EXPORT_SEPARATORCSV) ? ',' : $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV, 'ACCOUNTING_EXPORT_ENDLINE' => empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? 1 : $conf->global->ACCOUNTING_EXPORT_ENDLINE, - 'ACCOUNTING_EXPORT_DATE' => empty($conf->global->ACCOUNTING_EXPORT_DATE) ? '%d%m%Y' : $conf->global->ACCOUNTING_EXPORT_DATE, + 'ACCOUNTING_EXPORT_DATE' => getDolGlobalString('ACCOUNTING_EXPORT_DATE', '%Y-%m-%d'), ), self::$EXPORT_TYPE_CEGID => array( 'label' => $langs->trans('Modelcsv_CEGID'), @@ -313,9 +316,10 @@ class AccountancyExport * * @param array $TData Array with data * @param int $formatexportset Id of export format - * @return void + * @param int $withAttachment [=0] Not add files or 1 to have attached in an archive (ex : Quadratus) + * @return int <0 if KO, >0 OK */ - public function export(&$TData, $formatexportset) + public function export(&$TData, $formatexportset, $withAttachment = 0) { global $conf, $langs; global $search_date_end; // Used into /accountancy/tpl/export_journal.tpl.php @@ -325,8 +329,44 @@ class AccountancyExport $type_export = 'general_ledger'; global $db; // The tpl file use $db + $completefilename = ''; + $exportFile = null; + $exportFileName = ''; + $exportFilePath = ''; + $archiveFileList = array(); + if ($withAttachment == 1) { + // PHP ZIP extension must be enabled + if (!extension_loaded('zip')) { + $langs->load('install'); + $this->errors[] = $langs->trans('ErrorPHPDoesNotSupport', 'ZIP'); + return -1; + } + } else { + $mimetype = $this->getMimeType($formatexportset); + top_httphead($mimetype, 1); + } include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; + if ($withAttachment == 1 && !empty($completefilename)) { + // create export file + $tmpDir = !empty($conf->accounting->multidir_temp[$conf->entity]) ? $conf->accounting->multidir_temp[$conf->entity] : $conf->accounting->dir_temp; + $exportFileFullName = $completefilename; + $exportFileBaseName = basename($exportFileFullName); + $exportFileName = pathinfo($exportFileBaseName, PATHINFO_FILENAME); + $exportFilePath = $tmpDir.'/'.$exportFileFullName; + $exportFile = fopen($exportFilePath, 'w'); + if (!$exportFile) { + $this->errors[] = $langs->trans('ErrorFileNotFound', $exportFilePath); + return -1; + } + $archiveFileList[0] = array( + 'path' => $exportFilePath, + 'name' => $exportFileFullName, + ); + // archive name and path + $archiveFullName = $exportFileName.'.zip'; + $archivePath = $tmpDir.'/'.$archiveFullName; + } switch ($formatexportset) { case self::$EXPORT_TYPE_CONFIGURABLE: @@ -345,7 +385,7 @@ class AccountancyExport $this->exportCiel($TData); break; case self::$EXPORT_TYPE_QUADRATUS: - $this->exportQuadratus($TData); + $archiveFileList = $this->exportQuadratus($TData, $exportFile, $archiveFileList, $withAttachment); break; case self::$EXPORT_TYPE_WINFIC: $this->exportWinfic($TData); @@ -399,6 +439,69 @@ class AccountancyExport } break; } + + // create and download export file or archive + if ($withAttachment == 1) { + $error = 0; + + // close export file + if ($exportFile) { + fclose($exportFile); + } + + if (!empty($archiveFullName) && !empty($archivePath) && !empty($archiveFileList)) { + // archive files + $downloadFileMimeType = 'application/zip'; + $downloadFileFullName = $archiveFullName; + $downloadFilePath = $archivePath; + + // create archive + $archive = new ZipArchive(); + $res = $archive->open($archivePath, ZipArchive::OVERWRITE | ZipArchive::CREATE); + if ($res !== true) { + $error++; + $this->errors[] = $langs->trans('ErrorFileNotFound', $archivePath); + } + if (!$error) { + // add files + foreach ($archiveFileList as $archiveFileArr) { + $res = $archive->addFile($archiveFileArr['path'], $archiveFileArr['name']); + if (!$res) { + $error++; + $this->errors[] = $langs->trans('ErrorArchiveAddFile', $archiveFileArr['name']); + break; + } + } + } + if (!$error) { + // close archive + $archive->close(); + } + } elseif (!empty($exportFileFullName) && !empty($exportFilePath)) { + // only one file to download + $downloadFileMimeType = 'text/csv'; + $downloadFileFullName = $exportFileFullName; + $downloadFilePath = $exportFilePath; + } + + if (!$error) { + // download export file + if (!empty($downloadFileMimeType) && !empty($downloadFileFullName) && !empty($downloadFilePath)) { + header('Content-Type: '.$downloadFileMimeType); + header('Content-Disposition: attachment; filename='.$downloadFileFullName); + header('Cache-Control: Public, must-revalidate'); + header('Pragma: public'); + header('Content-Length: '.dol_filesize($downloadFilePath)); + readfileLowMemory($downloadFilePath); + } + } + + if ($error) { + return -1; + } + } + + return 1; } @@ -444,14 +547,14 @@ class AccountancyExport print $date.$separator; print $line->piece_num.$separator; print length_accountg($line->numero_compte).$separator; - print ''.$separator; + print $separator; print $line->label_operation.$separator; print $date.$separator; if ($line->sens == 'D') { print price($line->debit).$separator; - print ''.$separator; + print $separator; } elseif ($line->sens == 'C') { - print ''.$separator; + print $separator; print price($line->credit).$separator; } print $line->doc_ref.$separator; @@ -579,15 +682,18 @@ class AccountancyExport /** * Export format : Quadratus (Format ASCII) * Format since 2015 compatible QuadraCOMPTA - * Last review for this format : 2021/09/13 Alexandre Spangaro (aspangaro@open-dsi.fr) + * Last review for this format : 2023/01/28 Alexandre Spangaro (aspangaro@open-dsi.fr) * * Help : https://docplayer.fr/20769649-Fichier-d-entree-ascii-dans-quadracompta.html * In QuadraCompta | Use menu : "Outils" > "Suivi des dossiers" > "Import ASCII(Compta)" * - * @param array $TData data - * @return void + * @param array $TData Data + * @param resource $exportFile [=null] File resource to export or print if null + * @param array $archiveFileList [=array()] Archive file list : array of ['path', 'name'] + * @param bool $withAttachment [=0] Not add files or 1 to have attached in an archive + * @return array Archive file list : array of ['path', 'name'] */ - public function exportQuadratus(&$TData) + public function exportQuadratus(&$TData, $exportFile = null, $archiveFileList = array(), $withAttachment = 0) { global $conf, $db; @@ -597,6 +703,14 @@ class AccountancyExport // $date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy // $date_ecriture = dol_print_date(time(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be ddmmyy foreach ($TData as $data) { + // Clean some data + $data->doc_ref = dol_string_unaccent($data->doc_ref); + $data->label_operation = dol_string_unaccent($data->label_operation); + $data->numero_compte = dol_string_unaccent($data->numero_compte); + $data->label_compte = dol_string_unaccent($data->label_compte); + $data->subledger_account = dol_string_unaccent($data->subledger_account); + $data->subledger_label = dol_string_unaccent($data->subledger_label); + $code_compta = $data->numero_compte; if (!empty($data->subledger_account)) { $code_compta = $data->subledger_account; @@ -628,16 +742,20 @@ class AccountancyExport if ($data->doc_type == 'customer_invoice') { $Tab['type_compte'] = 'C'; } elseif ($data->doc_type == 'supplier_invoice') { - $Tab['coll_compte'] = 'F'; + $Tab['type_compte'] = 'F'; } else { - $Tab['coll_compte'] = 'G'; + $Tab['type_compte'] = 'G'; } $Tab['filler3'] = str_repeat(' ', 235); $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } $Tab = array(); @@ -651,7 +769,7 @@ class AccountancyExport //$Tab['date_ecriture'] = $date_ecriture; $Tab['date_ecriture'] = dol_print_date($data->doc_date, '%d%m%y'); $Tab['filler'] = ' '; - $Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).' '.dol_string_unaccent($data->label_operation), 20), 20); + $Tab['libelle_ecriture'] = str_pad(self::trunc($data->doc_ref.' '.$data->label_operation, 20), 20); // Credit invoice - invert sens /* @@ -701,19 +819,70 @@ class AccountancyExport // TODO: we should filter more than only accent to avoid wrong line size // TODO: remove invoice number doc_ref in libelle, // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software - //$Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref) . ' ' . dol_string_unaccent($data->label_operation), 30), 30); - $Tab['libelle_ecriture2'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 30), 30); + //$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30); + $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30); $Tab['codetva'] = str_repeat(' ', 2); // We need to keep the 10 lastest number of invoice doc_ref not the beginning part that is the unusefull almost same part // $Tab['num_piece3'] = str_pad(self::trunc($data->piece_num, 10), 10); $Tab['num_piece3'] = substr(self::trunc($data->doc_ref, 20), -10); - $Tab['filler4'] = str_repeat(' ', 73); + $Tab['reserved'] = str_repeat(' ', 10); // position 159 + $Tab['currency_amount'] = str_repeat(' ', 13); // position 169 + // get document file + $attachmentFileName = ''; + if ($withAttachment == 1) { + $attachmentFileKey = trim($data->piece_num); + if (!isset($archiveFileList[$attachmentFileKey])) { + $objectDirPath = ''; + $objectFileName = dol_sanitizeFileName($data->doc_ref); + if ($data->doc_type == 'customer_invoice') { + $objectDirPath = !empty($conf->facture->multidir_output[$conf->entity]) ? $conf->facture->multidir_output[$conf->entity] : $conf->facture->dir_output; + } elseif ($data->doc_type == 'expense_report') { + $objectDirPath = !empty($conf->expensereport->multidir_output[$conf->entity]) ? $conf->expensereport->multidir_output[$conf->entity] : $conf->factureexpensereport->dir_output; + } elseif ($data->doc_type == 'supplier_invoice') { + $objectDirPath = !empty($conf->fournisseur->facture->multidir_output[$conf->entity]) ? $conf->fournisseur->facture->multidir_output[$conf->entity] : $conf->fournisseur->facture->dir_output; + } + $arrayofinclusion = array(); + $arrayofinclusion[] = '^'.preg_quote($objectFileName, '/').'\.pdf$'; + $fileFoundList = dol_dir_list($objectDirPath.'/'.$objectFileName, 'files', 0, implode('|', $arrayofinclusion), '(\.meta|_preview.*\.png)$', 'date', SORT_DESC, 0, true); + if (!empty($fileFoundList)) { + $attachmentFileNameTrunc = str_pad(self::trunc($data->piece_num, 8), 8, '0', STR_PAD_LEFT); + foreach ($fileFoundList as $fileFound) { + if (strstr($fileFound['name'], $objectFileName)) { + $fileFoundPath = $objectDirPath.'/'.$objectFileName.'/'.$fileFound['name']; + if (file_exists($fileFoundPath)) { + $archiveFileList[$attachmentFileKey] = array( + 'path' => $fileFoundPath, + 'name' => $attachmentFileNameTrunc.'.pdf', + ); + break; + } + } + } + } + } + + if (isset($archiveFileList[$attachmentFileKey])) { + $attachmentFileName = $archiveFileList[$attachmentFileKey]['name']; + } + } + if (dol_strlen($attachmentFileName) == 12) { + $Tab['attachment'] = $attachmentFileName; // position 182 + } else { + $Tab['attachment'] = str_repeat(' ', 12); // position 182 + } + $Tab['filler4'] = str_repeat(' ', 38); $Tab['end_line'] = $end_line; - print implode($Tab); + if ($exportFile) { + fwrite($exportFile, implode($Tab)); + } else { + print implode($Tab); + } } + + return $archiveFileList; } /** diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 94ee1ac6029..8e5f7690dd1 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -723,7 +723,7 @@ class AccountingAccount extends CommonObject } /** - * Return Suggest accounting accounts to bind + * Return a suggested account (from chart of accounts) to bind * * @param Societe $buyer Object buyer * @param Societe $seller Object seller @@ -733,6 +733,8 @@ class AccountingAccount extends CommonObject * @param array $accountingAccount Array of Accounting account * @param string $type Customer / Supplier * @return array|int Accounting accounts suggested or < 0 if technical error. + * 'suggestedaccountingaccountbydefaultfor'=>Will be used for the label to show on tooltip for account by default on any product + * 'suggestedaccountingaccountfor'=>Is the account suggested for this product */ public function getAccountingCodeToBind(Societe $buyer, Societe $seller, Product $product, $facture, $factureDet, $accountingAccount = array(), $type = '') { diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 4accf66e154..f56932d4985 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -454,27 +454,12 @@ class AccountingJournal extends CommonObject } $sql = ""; - - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= "WITH in_accounting_bookkeeping(fk_docdet) AS ("; - $sql .= " SELECT DISTINCT fk_docdet"; - $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping"; - $sql .= " WHERE doc_type = 'asset'"; - $sql .= ") "; - }*/ - $sql .= "SELECT ad.fk_asset AS rowid, a.ref AS asset_ref, a.label AS asset_label, a.acquisition_value_ht AS asset_acquisition_value_ht"; $sql .= ", a.disposal_date AS asset_disposal_date, a.disposal_amount_ht AS asset_disposal_amount_ht, a.disposal_subject_to_vat AS asset_disposal_subject_to_vat"; $sql .= ", ad.rowid AS depreciation_id, ad.depreciation_mode, ad.ref AS depreciation_ref, ad.depreciation_date, ad.depreciation_ht, ad.accountancy_code_debit, ad.accountancy_code_credit"; $sql .= " FROM " . MAIN_DB_PREFIX . "asset_depreciation as ad"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "asset as a ON a.rowid = ad.fk_asset"; - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " LEFT JOIN in_accounting_bookkeeping as iab ON iab.fk_docdet = ad.rowid"; - }*/ $sql .= " WHERE a.entity IN (" . getEntity('asset', 0) . ')'; // We don't share object for accountancy, we use source object sharing - // Compatibility with Mysql 5.7 if ($in_bookkeeping == 'already') { $sql .= " AND EXISTS (SELECT iab.fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping AS iab WHERE iab.fk_docdet = ad.rowid AND doc_type = 'asset')"; } elseif ($in_bookkeeping == 'notyet') { @@ -488,11 +473,6 @@ class AccountingJournal extends CommonObject if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) { $sql .= " AND ad.depreciation_date >= '" . $this->db->idate($conf->global->ACCOUNTING_DATE_START_BINDING) . "'"; } - // Already in bookkeeping or not - // FIXME sql error with Mysql 5.7 - /*if ($in_bookkeeping == 'already' || $in_bookkeeping == 'notyet') { - $sql .= " AND iab.fk_docdet IS" . ($in_bookkeeping == 'already' ? " NOT" : "") . " NULL"; - }*/ $sql .= " ORDER BY ad.depreciation_date"; dol_syslog(__METHOD__, LOG_DEBUG); @@ -755,7 +735,7 @@ class AccountingJournal extends CommonObject } } - $journal_data[$pre_data_id] = $element; + $journal_data[(int) $pre_data_id] = $element; } unset($pre_data); diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 95ba38d20bb..897f60e8aaa 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -817,56 +817,61 @@ class BookKeeping extends CommonObject /** - * Load object in memory from the database + * Load object in memory from the database in ->lines. Or just make a simple count if $countonly=1. * - * @param string $sortorder Sort Order - * @param string $sortfield Sort field - * @param int $limit offset limit - * @param int $offset offset limit - * @param array $filter filter array - * @param string $filtermode filter mode (AND or OR) - * @param int $option option (0: general account or 1: subaccount) - * - * @return int <0 if KO, >=0 if OK + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) + * @param int $countonly Do not fill the $object->lines, return only the count. + * @return int <0 if KO, Number of lines if OK */ - public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) + public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0, $countonly = 0) { global $conf; dol_syslog(__METHOD__, LOG_DEBUG); $this->lines = array(); + $num = 0; $sql = 'SELECT'; - $sql .= ' t.rowid,'; - $sql .= " t.doc_date,"; - $sql .= " t.doc_type,"; - $sql .= " t.doc_ref,"; - $sql .= " t.fk_doc,"; - $sql .= " t.fk_docdet,"; - $sql .= " t.thirdparty_code,"; - $sql .= " t.subledger_account,"; - $sql .= " t.subledger_label,"; - $sql .= " t.numero_compte,"; - $sql .= " t.label_compte,"; - $sql .= " t.label_operation,"; - $sql .= " t.debit,"; - $sql .= " t.credit,"; - $sql .= " t.montant as amount,"; - $sql .= " t.sens,"; - $sql .= " t.multicurrency_amount,"; - $sql .= " t.multicurrency_code,"; - $sql .= " t.lettering_code,"; - $sql .= " t.date_lettering,"; - $sql .= " t.fk_user_author,"; - $sql .= " t.import_key,"; - $sql .= " t.code_journal,"; - $sql .= " t.journal_label,"; - $sql .= " t.piece_num,"; - $sql .= " t.date_creation,"; - $sql .= " t.date_export,"; - $sql .= " t.date_validated as date_validation,"; - $sql .= " t.import_key"; + if ($countonly) { + $sql .= ' COUNT(t.rowid) as nb'; + } else { + $sql .= ' t.rowid,'; + $sql .= " t.doc_date,"; + $sql .= " t.doc_type,"; + $sql .= " t.doc_ref,"; + $sql .= " t.fk_doc,"; + $sql .= " t.fk_docdet,"; + $sql .= " t.thirdparty_code,"; + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; + $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + $sql .= " t.label_operation,"; + $sql .= " t.debit,"; + $sql .= " t.credit,"; + $sql .= " t.montant as amount,"; + $sql .= " t.sens,"; + $sql .= " t.multicurrency_amount,"; + $sql .= " t.multicurrency_code,"; + $sql .= " t.lettering_code,"; + $sql .= " t.date_lettering,"; + $sql .= " t.fk_user_author,"; + $sql .= " t.import_key,"; + $sql .= " t.code_journal,"; + $sql .= " t.journal_label,"; + $sql .= " t.piece_num,"; + $sql .= " t.date_creation,"; + $sql .= " t.date_export,"; + $sql .= " t.date_validated as date_validation,"; + $sql .= " t.import_key"; + } // Manage filter $sqlwhere = array(); if (count($filter) > 0) { @@ -880,7 +885,7 @@ class BookKeeping extends CommonObject } elseif ($key == 't.fk_doc' || $key == 't.fk_docdet' || $key == 't.piece_num') { $sqlwhere[] = $key.'='.$value; } elseif ($key == 't.subledger_account' || $key == 't.numero_compte') { - $sqlwhere[] = $key.' LIKE \''.$this->db->escape($value).'%\''; + $sqlwhere[] = $key.' LIKE \''.$this->db->escapeforlike($this->db->escape($value)).'%\''; } elseif ($key == 't.date_creation>=' || $key == 't.date_creation<=') { $sqlwhere[] = $key.'\''.$this->db->idate($value).'\''; } elseif ($key == 't.date_export>=' || $key == 't.date_export<=') { @@ -897,18 +902,19 @@ class BookKeeping extends CommonObject } else { $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } + } elseif ($key == 't.search_accounting_code_in' && !empty($value)) { + $sqlwhere[] = 't.numero_compte IN ('.$this->db->sanitize($value, 1).')'; } else { $sqlwhere[] = natural_search($key, $value, 0, 1); } } } $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql .= ' WHERE 1 = 1'; - $sql .= " AND entity = " . ((int) $conf->entity); // Do not use getEntity for accounting features + $sql .= ' WHERE entity = ' . ((int) $conf->entity); // Do not use getEntity for accounting features if (count($sqlwhere) > 0) { $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } - // Affichage par compte comptable + // Filter by ledger account or subledger account if (!empty($option)) { $sql .= " AND t.subledger_account IS NOT NULL"; $sql .= " AND t.subledger_account <> ''"; @@ -919,54 +925,63 @@ class BookKeeping extends CommonObject $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); } - $sql .= $this->db->order($sortfield, $sortorder); - if (!empty($limit)) { - $sql .= $this->db->plimit($limit + 1, $offset); + if (!$countonly) { + $sql .= $this->db->order($sortfield, $sortorder); + if (!empty($limit)) { + $sql .= $this->db->plimit($limit + 1, $offset); + } } $resql = $this->db->query($sql); if ($resql) { - $num = $this->db->num_rows($resql); + if ($countonly) { + $obj = $this->db->fetch_object($resql); + if ($obj) { + $num = $obj->nb; + } + } else { + $num = $this->db->num_rows($resql); - $i = 0; - while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { - $line = new BookKeepingLine(); + $i = 0; + while (($obj = $this->db->fetch_object($resql)) && (empty($limit) || $i < min($limit, $num))) { + $line = new BookKeepingLine(); - $line->id = $obj->rowid; + $line->id = $obj->rowid; - $line->doc_date = $this->db->jdate($obj->doc_date); - $line->doc_type = $obj->doc_type; - $line->doc_ref = $obj->doc_ref; - $line->fk_doc = $obj->fk_doc; - $line->fk_docdet = $obj->fk_docdet; - $line->thirdparty_code = $obj->thirdparty_code; - $line->subledger_account = $obj->subledger_account; - $line->subledger_label = $obj->subledger_label; - $line->numero_compte = $obj->numero_compte; - $line->label_compte = $obj->label_compte; - $line->label_operation = $obj->label_operation; - $line->debit = $obj->debit; - $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated - $line->amount = $obj->amount; - $line->sens = $obj->sens; - $line->multicurrency_amount = $obj->multicurrency_amount; - $line->multicurrency_code = $obj->multicurrency_code; - $line->lettering_code = $obj->lettering_code; - $line->date_lettering = $obj->date_lettering; - $line->fk_user_author = $obj->fk_user_author; - $line->import_key = $obj->import_key; - $line->code_journal = $obj->code_journal; - $line->journal_label = $obj->journal_label; - $line->piece_num = $obj->piece_num; - $line->date_creation = $this->db->jdate($obj->date_creation); - $line->date_export = $this->db->jdate($obj->date_export); - $line->date_validation = $this->db->jdate($obj->date_validation); - $line->import_key = $obj->import_key; + $line->doc_date = $this->db->jdate($obj->doc_date); + $line->doc_type = $obj->doc_type; + $line->doc_ref = $obj->doc_ref; + $line->fk_doc = $obj->fk_doc; + $line->fk_docdet = $obj->fk_docdet; + $line->thirdparty_code = $obj->thirdparty_code; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; + $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->label_operation = $obj->label_operation; + $line->debit = $obj->debit; + $line->credit = $obj->credit; + $line->montant = $obj->amount; // deprecated + $line->amount = $obj->amount; + $line->sens = $obj->sens; + $line->multicurrency_amount = $obj->multicurrency_amount; + $line->multicurrency_code = $obj->multicurrency_code; + $line->lettering_code = $obj->lettering_code; + $line->date_lettering = $obj->date_lettering; + $line->fk_user_author = $obj->fk_user_author; + $line->import_key = $obj->import_key; + $line->code_journal = $obj->code_journal; + $line->journal_label = $obj->journal_label; + $line->piece_num = $obj->piece_num; + $line->date_creation = $this->db->jdate($obj->date_creation); + $line->date_export = $this->db->jdate($obj->date_export); + $line->date_validation = $this->db->jdate($obj->date_validation); + $line->import_key = $obj->import_key; - $this->lines[] = $line; + $this->lines[] = $line; - $i++; + $i++; + } } $this->db->free($resql); @@ -1139,9 +1154,10 @@ class BookKeeping extends CommonObject * @param int $offset offset limit * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) + * @param int $option option (0: general account or 1: subaccount) * @return int <0 if KO, >0 if OK */ - public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAllBalance($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0) { global $conf; @@ -1151,6 +1167,11 @@ class BookKeeping extends CommonObject $sql = 'SELECT'; $sql .= " t.numero_compte,"; + $sql .= " t.label_compte,"; + if (!empty($option)) { + $sql .= " t.subledger_account,"; + $sql .= " t.subledger_label,"; + } $sql .= " SUM(t.debit) as debit,"; $sql .= " SUM(t.credit) as credit"; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; @@ -1176,6 +1197,8 @@ class BookKeeping extends CommonObject } else { $sqlwhere[] = natural_search("t.code_journal", $value, 3, 1); } + } elseif ($key == 't.reconciled_option') { + $sqlwhere[] = 't.lettering_code IS NULL'; } else { $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; } @@ -1186,7 +1209,17 @@ class BookKeeping extends CommonObject $sql .= " AND ".implode(" ".$filtermode." ", $sqlwhere); } - $sql .= ' GROUP BY t.numero_compte'; + if (!empty($option)) { + $sql .= ' AND t.subledger_account IS NOT NULL'; + $sql .= ' AND t.subledger_account != ""'; + $sql .= ' GROUP BY t.numero_compte, t.label_compte, t.subledger_account, t.subledger_label'; + $sortfield = 't.subledger_account'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortfield ? ','.$sortfield : ''); + } else { + $sql .= ' GROUP BY t.numero_compte, t.label_compte'; + $sortfield = 't.numero_compte'.($sortfield ? ','.$sortfield : ''); + $sortorder = 'ASC'.($sortorder ? ','.$sortorder : ''); + } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); @@ -1204,6 +1237,9 @@ class BookKeeping extends CommonObject $line = new BookKeepingLine(); $line->numero_compte = $obj->numero_compte; + $line->label_compte = $obj->label_compte; + $line->subledger_account = $obj->subledger_account; + $line->subledger_label = $obj->subledger_label; $line->debit = $obj->debit; $line->credit = $obj->credit; diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 393629ae505..5f603a973c2 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -121,26 +121,12 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('acc if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - /*if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facturedet.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "facturedet.fk_code_ventilation = 0"; - } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facturedet as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.((int) $conf->entity); - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_sell=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; - }*/ - // Customer Invoice lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref as ref, f.datef, f.type as ftype, f.fk_facture_source,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; @@ -281,12 +267,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -300,7 +288,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -324,7 +315,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); //print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, ''); @@ -405,7 +396,17 @@ if ($resql) { print ''; print '
'; } print ''; @@ -558,7 +565,7 @@ print "
'.$langs->trans("NoRecordFound").'
' . $langs->trans("TotalForAccount") . ' ' . length_accountg($displayed_account_number) . ':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("TotalForAccount").' '.$accountg.':'.price($sous_total_debit).''.price($sous_total_credit).''.price(price2num($sous_total_debit, 'MT')).''.price(price2num($sous_total_credit, 'MT')).'
'.$langs->trans("Balance").':'; - print price($sous_total_debit - $sous_total_credit); + print price(price2num($sous_total_debit - $sous_total_credit, 'MT')); print ''; - print price($sous_total_credit - $sous_total_debit); + print price(price2num($sous_total_credit - $sous_total_debit, 'MT')); print '
'.$langs->trans("NoRecordFound").'
'; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/customer/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } @@ -420,6 +421,12 @@ if ($resql) { print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''.price($row[14]).'
\n"; print '
'; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index e4f7d556c16..b8df8890a01 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -529,6 +529,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print ""; diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 57a9dd99e5e..35be32d6b34 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -43,10 +43,11 @@ $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", $action = GETPOST('action', 'aZ09'); $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') : 'accountancycustomerlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); + $default_account = GETPOST('default_account', 'int'); // Select Box @@ -73,8 +74,6 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); -$btn_ventil = GETPOST('ventil', 'alpha'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -520,8 +519,8 @@ if ($result) { print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); - print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); + print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall '); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); $checkpicto = ''; if ($massactionbutton) { $checkpicto = $form->showCheckAddButtons('checkforselect', 1); @@ -640,7 +639,7 @@ if ($result) { print ''.dol_print_date($facture_static->date, 'day').''; // Ref Product - print ''; + print ''; if ($product_static->id > 0) { print $product_static->getNomUrl(1); } @@ -649,7 +648,7 @@ if ($result) { } print ''; - // Description + // Description of line print ''; $text = dolGetFirstLineOfText(dol_string_nohtmltag($facture_static_det->desc, 1)); $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; @@ -683,15 +682,22 @@ if ($result) { // Found accounts print ''; + // First show default account for any products $s = '1. '.(($facture_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; - $shelp = ''; + $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); + } elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithvat') { + $shelp = $langs->trans("SaleEECWithVAT"); + } elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithoutvatnumber') { + $shelp = $langs->trans("SaleEECWithoutVATNumber"); + $ttype = 'warning'; } elseif ($suggestedaccountingaccountbydefaultfor == 'export') { $shelp .= $langs->trans("SaleExport"); } $s .= ($code_sell_l > 0 ? length_accountg($code_sell_l) : ''.$langs->trans("NotDefined").''); - print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1); + // Now show account for product if ($product_static->id > 0) { print '
'; $s = '2. '.(($facture_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; @@ -749,6 +755,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print ""; diff --git a/htdocs/accountancy/expensereport/index.php b/htdocs/accountancy/expensereport/index.php index 5064003c7ff..339ffe68b96 100644 --- a/htdocs/accountancy/expensereport/index.php +++ b/htdocs/accountancy/expensereport/index.php @@ -58,6 +58,8 @@ $year_current = $year_start; // Validate History $action = GETPOST('action', 'aZ09'); +$chartaccountcode = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version'); + // Security check if (!isModEnabled('accounting')) { accessforbidden(); @@ -65,7 +67,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -74,7 +76,7 @@ if (empty($user->rights->accounting->mouvements->lire)) { * Actions */ -if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accounting->bind->write) { +if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) { // Clean database $db->begin(); $sql1 = "UPDATE ".MAIN_DB_PREFIX."expensereport_det as erd"; @@ -101,6 +103,7 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); @@ -109,8 +112,7 @@ if ($action == 'validatehistory') { $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid"; $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd"; $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id"; - $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.entity =".((int) $conf->entity); - $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as syst ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid = ".((int) $conf->global->CHARTOFACCOUNTS).' AND syst.active = 1,'; + $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND accnt.entity =".((int) $conf->entity); $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er"; $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity); $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0"; @@ -143,12 +145,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -162,7 +166,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -176,6 +183,7 @@ llxHeader('', $langs->trans("ExpenseReportsVentilation")); $textprevyear = ''.img_previous().''; $textnextyear = ' '.img_next().''; + print load_fiche_titre($langs->trans("ExpenseReportsVentilation")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy'); print ''.$langs->trans("DescVentilExpenseReport").'
'; @@ -185,7 +193,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -247,7 +255,7 @@ $sql .= " AND aa.account_number IS NULL"; $sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label"; $sql .= ' ORDER BY aa.account_number'; -dol_syslog('/accountancy/expensereport/index.php:: sql='.$sql); +dol_syslog('/accountancy/expensereport/index.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -263,20 +271,49 @@ if ($resql) { print ''; print ''; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; for ($i = 2; $i <= 13; $i++) { + $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + if ($cursormonth > 12) { + $cursormonth -= 12; + } + $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); + print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''; } print ''.price($row[14]).''; print ''; } $db->free($resql); + + if ($num == 0) { + print ''; + print ''.$langs->trans("NoRecordFound").''; + print ''; + } } else { print $db->lasterror(); // Show last sql error } @@ -359,6 +396,12 @@ if ($resql) { print ''; } $db->free($resql); + + if ($num == 0) { + print ''; + print ''.$langs->trans("NoRecordFound").''; + print ''; + } } else { print $db->lasterror(); // Show last sql error } @@ -367,7 +410,7 @@ print ''; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/expensereport/lines.php b/htdocs/accountancy/expensereport/lines.php index aef45ae3ce1..1d0653fc5ac 100644 --- a/htdocs/accountancy/expensereport/lines.php +++ b/htdocs/accountancy/expensereport/lines.php @@ -427,6 +427,13 @@ if ($result) { print ""; $i++; } + if ($num_lines == 0) { + $colspan=10; + if (!empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) { + $colspan++; + } + print ''.$langs->trans("NoRecordFound").''; + } print ""; print ""; diff --git a/htdocs/accountancy/expensereport/list.php b/htdocs/accountancy/expensereport/list.php index b90a8a2c573..1cf9149024a 100644 --- a/htdocs/accountancy/expensereport/list.php +++ b/htdocs/accountancy/expensereport/list.php @@ -40,10 +40,9 @@ $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", $action = GETPOST('action', 'aZ09'); $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') : 'expensereportlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'accountancyexpensereportlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -419,8 +418,8 @@ if ($result) { print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "erd.comments", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right maxwidth50 '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); - print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', ''); + print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall '); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', ''); $checkpicto = ''; if ($massactionbutton) { $checkpicto = $form->showCheckAddButtons('checkforselect', 1); @@ -443,7 +442,6 @@ if ($result) { $expensereport_static->id = $objp->erid; $userstatic->id = $objp->userid; - $userstatic->ref = $objp->label; $userstatic->login = $objp->login; $userstatic->statut = $objp->statut; $userstatic->email = $objp->email; @@ -513,6 +511,9 @@ if ($result) { print ""; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } print ''; print ""; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index 4aba6bfeda4..c23392cada0 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -349,7 +349,11 @@ if ($result) { $societestatic->email = $tabcompany[$obj->rowid]['email']; $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30); if ($compta_soc) { - $tabtp[$obj->rowid][$compta_soc] += $amounttouse; + if (empty($tabtp[$obj->rowid][$compta_soc])) { + $tabtp[$obj->rowid][$compta_soc] = $amounttouse; + } else { + $tabtp[$obj->rowid][$compta_soc] += $amounttouse; + } } } elseif ($links[$key]['type'] == 'user') { $userstatic->id = $links[$key]['url_id']; @@ -510,7 +514,11 @@ if ($result) { } } - $tabbq[$obj->rowid][$compta_bank] += $amounttouse; + if (empty($tabbq[$obj->rowid][$compta_bank])) { + $tabbq[$obj->rowid][$compta_bank] = $amounttouse; + } else { + $tabbq[$obj->rowid][$compta_bank] += $amounttouse; + } // If no links were found to know the amount on thirdparty, we try to guess it. // This may happens on bank entries without the links lines to 'company'. @@ -793,7 +801,7 @@ if (!$error && $action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id)); diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index a5b82e7b2d0..746383fef0b 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -376,7 +376,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); diff --git a/htdocs/accountancy/journal/sellsjournal.php b/htdocs/accountancy/journal/sellsjournal.php index 0519762baef..666024833d0 100644 --- a/htdocs/accountancy/journal/sellsjournal.php +++ b/htdocs/accountancy/journal/sellsjournal.php @@ -4,7 +4,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2012 Regis Houssin * Copyright (C) 2013 Christophe Battarel - * Copyright (C) 2013-2021 Alexandre Spangaro + * Copyright (C) 2013-2022 Alexandre Spangaro * Copyright (C) 2013-2016 Florian Henry * Copyright (C) 2013-2016 Olivier Geffroy * Copyright (C) 2014 Raphaël Doursenaud @@ -106,7 +106,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code,"; +$sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,"; if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) { @@ -168,6 +168,7 @@ if ($result) { $tabht = array(); $tabtva = array(); $def_tva = array(); + $tabwarranty = array(); $tabttc = array(); $tablocaltax1 = array(); $tablocaltax2 = array(); @@ -248,7 +249,13 @@ if ($result) { $tablocaltax2[$obj->rowid][$compta_localtax2] = 0; } - $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc * $situation_ratio; + $total_ttc = $obj->total_ttc * $situation_ratio; + if (!empty($conf->global->INVOICE_USE_RETAINED_WARRANTY) && $obj->retained_warranty > 0) { + $retained_warranty = (double) price2num($total_ttc * $obj->retained_warranty / 100, 'MT'); + $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty; + $total_ttc -= $retained_warranty; + } + $tabttc[$obj->rowid][$compta_soc] += $total_ttc; $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio; if (empty($line->tva_npr)) { $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio; // We ignore line if VAT is a NPR @@ -300,6 +307,10 @@ if ($action == 'writebookkeeping') { $accountingaccountcustomer->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER, true); + $accountingaccountcustomerwarranty = new AccountingAccount($db); + + $accountingaccountcustomerwarranty->fetch(null, $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY, true); + foreach ($tabfac as $key => $val) { // Loop on each invoice $errorforline = 0; @@ -344,6 +355,55 @@ if ($action == 'writebookkeeping') { setEventMessages($langs->trans('ErrorInvoiceContainsLinesNotYetBounded', $val['ref']), null, 'errors'); } + // Warranty + if (!$errorforline) { + foreach ($tabwarranty[$key] as $k => $mt) { + $bookkeeping = new BookKeeping($db); + $bookkeeping->doc_date = $val["date"]; + $bookkeeping->date_lim_reglement = $val["datereg"]; + $bookkeeping->doc_ref = $val["ref"]; + $bookkeeping->date_creation = $now; + $bookkeeping->doc_type = 'customer_invoice'; + $bookkeeping->fk_doc = $key; + $bookkeeping->fk_docdet = 0; // Useless, can be several lines that are source of this record to add + $bookkeeping->thirdparty_code = $companystatic->code_client; + + $bookkeeping->subledger_account = $tabcompany[$key]['code_compta']; + $bookkeeping->subledger_label = $tabcompany[$key]['name']; + + $bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY; + $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label; + + $bookkeeping->label_operation = dol_trunc($companystatic->name, 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty"); + $bookkeeping->montant = $mt; + $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C'; + $bookkeeping->debit = ($mt >= 0) ? $mt : 0; + $bookkeeping->credit = ($mt < 0) ? -$mt : 0; + $bookkeeping->code_journal = $journal; + $bookkeeping->journal_label = $langs->transnoentities($journal_label); + $bookkeeping->fk_user_author = $user->id; + $bookkeeping->entity = $conf->entity; + + $totaldebit += $bookkeeping->debit; + $totalcredit += $bookkeeping->credit; + + $result = $bookkeeping->create($user); + if ($result < 0) { + if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists + $error++; + $errorforline++; + $errorforinvoice[$key] = 'alreadyjournalized'; + //setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings'); + } else { + $error++; + $errorforline++; + $errorforinvoice[$key] = 'other'; + setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); + } + } + } + } + // Thirdparty if (!$errorforline) { foreach ($tabttc[$key] as $k => $mt) { @@ -390,7 +450,7 @@ if ($action == 'writebookkeeping') { setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors'); } } else { - if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) { + if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php'; $lettering_static = new Lettering($db); $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id)); @@ -624,6 +684,25 @@ if ($action == 'exportcsv') { // ISO and not UTF8 ! continue; } + // Warranty + foreach ($tabwarranty[$key] as $k => $mt) { + //if ($mt) { + print '"'.$key.'"'.$sep; + print '"'.$date.'"'.$sep; + print '"'.$val["ref"].'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY).'"'.$sep; + print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; + print '"'.$langs->trans("Thirdparty").'"'.$sep; + print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").'"'.$sep; + print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; + print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; + print '"'.$journal.'"'; + print "\n"; + //} + } + // Third party foreach ($tabttc[$key] as $k => $mt) { //if ($mt) { @@ -849,6 +928,36 @@ if (empty($action) || $action == 'view') { print ""; } + // Warranty + foreach ($tabwarranty[$key] as $k => $mt) { + print ''; + print ""; + print "".$date.""; + print "".$invoicestatic->getNomUrl(1).""; + // Account + print ""; + $accountoshow = length_accountg($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("MainAccountForCustomersNotDefined").''; + } else { + print $accountoshow; + } + print ''; + // Subledger account + print ""; + $accountoshow = length_accounta($k); + if (($accountoshow == "") || $accountoshow == 'NotDefined') { + print ''.$langs->trans("ThirdpartyAccountNotDefined").''; + } else { + print $accountoshow; + } + print ''; + print "".$companystatic->getNomUrl(0, 'customer', 16).' - '.$invoicestatic->ref.' - '.$langs->trans("Retainedwarranty").""; + print ''.($mt >= 0 ? price($mt) : '').""; + print ''.($mt < 0 ? price(-$mt) : '').""; + print ""; + } + // Third party foreach ($tabttc[$key] as $k => $mt) { print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index b214b89734c..87e67bbfcb6 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -119,26 +119,12 @@ if (($action == 'clean' || $action == 'validatehistory') && $user->rights->accou if ($action == 'validatehistory') { $error = 0; $nbbinddone = 0; + $nbbindfailed = 0; $notpossible = 0; $db->begin(); // Now make the binding. Bind automatically only for product with a dedicated account that exists into chart of account, others need a manual bind - /*if ($db->type == 'pgsql') { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " FROM " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " WHERE " . MAIN_DB_PREFIX . "facture_fourn_det.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; - $sql1 .= " AND " . MAIN_DB_PREFIX . "facture_fourn_det.fk_code_ventilation = 0"; - } else { - $sql1 = "UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det as fd, " . MAIN_DB_PREFIX . "product as p, " . MAIN_DB_PREFIX . "accounting_account as accnt , " . MAIN_DB_PREFIX . "accounting_system as syst"; - $sql1 .= " SET fk_code_ventilation = accnt.rowid"; - $sql1 .= " WHERE fd.fk_product = p.rowid AND accnt.fk_pcg_version = syst.pcg_version AND syst.rowid=" . ((int) $conf->global->CHARTOFACCOUNTS).' AND accnt.entity = '.$conf->entity; - $sql1 .= " AND accnt.active = 1 AND p.accountancy_code_buy=accnt.account_number"; - $sql1 .= " AND fd.fk_code_ventilation = 0"; - }*/ - // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype, f.fk_facture_source,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; @@ -279,12 +265,14 @@ if ($action == 'validatehistory') { if (!$resqlupdate) { $error++; setEventMessages($db->lasterror(), null, 'errors'); + $nbbindfailed++; break; } else { $nbbinddone++; } } else { $notpossible++; + $nbbindfailed++; } $i++; @@ -298,7 +286,10 @@ if ($action == 'validatehistory') { $db->rollback(); } else { $db->commit(); - setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, 'mesgs'); + setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs')); + if ($nbbindfailed) { + setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings'); + } } } @@ -320,7 +311,7 @@ print '
'; $y = $year_current; -$buttonbind = ''.$langs->trans("ValidateHistory").''; +$buttonbind = ''.img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("ValidateHistory").''; print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1); @@ -402,14 +393,37 @@ if ($resql) { print ''; print ''; if ($row[0] == 'tobind') { - print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind")); + $startmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1); + if ($startmonth > 12) { + $startmonth -= 12; + } + $startyear = ($startmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $endmonth = ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + 11; + if ($endmonth > 12) { + $endmonth -= 12; + } + $endyear = ($endmonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind")); } else { print $row[1]; } print ''; for ($i = 2; $i <= 13; $i++) { + $cursormonth = (($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) + $i - 2); + if ($cursormonth > 12) { + $cursormonth -= 12; + } + $cursoryear = ($cursormonth < ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1)) ? $y + 1 : $y; + $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt'); + print ''; print price($row[$i]); + // Add link to make binding + if (!empty(price2num($row[$i]))) { + print ''; + print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad($cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"'); + print ''; + } print ''; } print ''.price($row[14]).''; @@ -541,7 +555,7 @@ print "\n"; print ''; -if ($conf->global->MAIN_FEATURES_LEVEL > 0) { // This part of code looks strange. Why showing a report that should rely on result of this step ? +if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ? print '
'; print '
'; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 25368f30c61..ea9841d2fbb 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -558,6 +558,10 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print ""; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index b78227a67f6..aae34a51e03 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -44,10 +44,11 @@ $langs->loadLangs(array("bills", "companies", "compta", "accountancy", "other", $action = GETPOST('action', 'aZ09'); $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') : 'accountancysupplierlist'; // To manage different context of search $optioncss = GETPOST('optioncss', 'alpha'); + $default_account = GETPOST('default_account', 'int'); // Select Box @@ -75,8 +76,6 @@ $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_en $search_country = GETPOST('search_country', 'alpha'); $search_tvaintra = GETPOST('search_tvaintra', 'alpha'); -$btn_ventil = GETPOST('ventil', 'alpha'); - // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -112,7 +111,7 @@ if (!isModEnabled('accounting')) { if ($user->socid > 0) { accessforbidden(); } -if (empty($user->rights->accounting->mouvements->lire)) { +if (!$user->hasRight('accounting', 'mouvements', 'lire')) { accessforbidden(); } @@ -532,8 +531,8 @@ if ($result) { print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Country", $_SERVER["PHP_SELF"], "co.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("VATIntraShort", $_SERVER["PHP_SELF"], "s.tva_intra", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'nowraponall '); - print_liste_field_titre("IntoAccount", '', '', '', '', '', '', '', 'center '); + print_liste_field_titre("DataUsedToSuggestAccount", '', '', '', '', '', '', '', 'nowraponall '); + print_liste_field_titre("AccountAccountingSuggest", '', '', '', '', '', '', '', 'center '); $checkpicto = ''; if ($massactionbutton) { $checkpicto = $form->showCheckAddButtons('checkforselect', 1); @@ -712,14 +711,19 @@ if ($result) { // Found accounts print ''; $s = '1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; - $shelp = ''; + $shelp = ''; $ttype = 'help'; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); + } elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithvat') { + $shelp = $langs->trans("SaleEECWithVAT"); + } elseif ($suggestedaccountingaccountbydefaultfor == 'eecwithoutvatnumber') { + $shelp = $langs->trans("SaleEECWithoutVATNumber"); + $ttype = 'warning'; } elseif ($suggestedaccountingaccountbydefaultfor == 'export') { $shelp .= $langs->trans("SaleExport"); } $s .= ($code_buy_l > 0 ? length_accountg($code_buy_l) : ''.$langs->trans("NotDefined").''); - print $form->textwithpicto($s, $shelp, 1, 'help', '', 0, 2, '', 1); + print $form->textwithpicto($s, $shelp, 1, $ttype, '', 0, 2, '', 1); if ($product_static->id > 0) { print '
'; $s = '2. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("ThisService") : $langs->trans("ThisProduct")).': '; @@ -777,6 +781,9 @@ if ($result) { print ''; $i++; } + if ($num_lines == 0) { + print ''.$langs->trans("NoRecordFound").''; + } print ''; print ""; diff --git a/htdocs/accountancy/tpl/export_journal.tpl.php b/htdocs/accountancy/tpl/export_journal.tpl.php index 22537a60a39..8e3c914a6f5 100644 --- a/htdocs/accountancy/tpl/export_journal.tpl.php +++ b/htdocs/accountancy/tpl/export_journal.tpl.php @@ -1,6 +1,8 @@ + * Copyright (C) 2022 Lionel Vessiller * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2022 Progiseize * * 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 @@ -33,7 +35,9 @@ $siren = getDolGlobalString('MAIN_INFO_SIREN'); $date_export = "_".dol_print_date(dol_now(), '%Y%m%d%H%M%S'); $endaccountingperiod = dol_print_date(dol_now(), '%Y%m%d'); -header('Content-Type: text/csv'); +if (empty($withAttachment)) { + header('Content-Type: text/csv'); +} include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php'; $accountancyexport = new AccountancyExport($db); @@ -66,4 +70,6 @@ if (($accountancyexport->getFormatCode($formatexportset) == 'fec' || $accountanc $completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format; } -header('Content-Disposition: attachment;filename='.$completefilename); +if (empty($withAttachment)) { + header('Content-Disposition: attachment;filename=' . $completefilename); +} diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index d20bd784ced..f9e15e88fca 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -152,10 +152,13 @@ if ($action == 'set_default') { setEventMessages('RecordModifiedSuccessfully', null, 'mesgs'); $db->commit(); } -} - -// Action to update or add a constant -if ($action == 'update' || $action == 'add') { +} elseif ($action == 'setcodemember') { + $result = dolibarr_set_const($db, "MEMBER_CODEMEMBER_ADDON", $value, 'chaine', 0, '', $conf->entity); + if ($result <= 0) { + dol_print_error($db); + } +} elseif ($action == 'update' || $action == 'add') { + // Action to update or add a constant $constname = GETPOST('constname', 'alpha'); $constvalue = (GETPOST('constvalue_'.$constname) ? GETPOST('constvalue_'.$constname) : GETPOST('constvalue')); @@ -223,6 +226,97 @@ $head = member_admin_prepare_head(); print dol_get_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user'); +$dirModMember = array_merge(array('/core/modules/member/'), $conf->modules_parts['member']); +foreach ($conf->modules_parts['models'] as $mo) { + //Add more models + $dirModMember[] = $mo.'core/modules/member/'; +} + +// Module to manage customer/supplier code + +print load_fiche_titre($langs->trans("MemberCodeChecker"), '', ''); + +print '
'; +print ''."\n"; +print ''."\n"; +print ' '; +print ' '; +print ' '; +print ' '; +print ' '; +print "\n"; + +$arrayofmodules = array(); + +foreach ($dirModMember as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + // Loop on each module find in opened directory + while (($file = readdir($handle)) !== false) { + // module filename has to start with mod_member_ + if (substr($file, 0, 11) == 'mod_member_' && substr($file, -3) == 'php') { + $file = substr($file, 0, dol_strlen($file) - 4); + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + continue; + } + $modCodeMember = new $file; + // Show modules according to features level + if ($modCodeMember->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($modCodeMember->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } + + $arrayofmodules[$file] = $modCodeMember; + } + } + closedir($handle); + } +} + +$arrayofmodules = dol_sort_array($arrayofmodules, 'position'); + +foreach ($arrayofmodules as $file => $modCodeMember) { + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + + if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == "$file") { + print '\n"; + } else { + $disabled = (isModEnabled('multicompany') && (is_object($mc) && !empty($mc->sharings['referent']) && $mc->sharings['referent'] != $conf->entity) ? true : false); + print ''; + } + + print ''; + + print ''; +} +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$modCodeMember->name.''.$modCodeMember->info($langs).''.$modCodeMember->getExample($langs).''."\n"; + print img_picto($langs->trans("Activated"), 'switch_on'); + print "'; + if (!$disabled) { + print ''; + } + print img_picto($langs->trans("Disabled"), 'switch_off'); + if (!$disabled) { + print ''; + } + print ''; + $s = $modCodeMember->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print '
'; +print '
'; + +print "
"; + print '
'; print ''; print ''; diff --git a/htdocs/adherents/admin/website.php b/htdocs/adherents/admin/website.php index 08e9f617750..14379166247 100644 --- a/htdocs/adherents/admin/website.php +++ b/htdocs/adherents/admin/website.php @@ -178,7 +178,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) { //print $langs->trans('FollowingLinksArePublic').'
'; print img_picto('', 'globe').' '.$langs->trans('BlankSubscriptionForm').'
'; if (isModEnabled('multicompany')) { - $entity_qr = '?entity='.$conf->entity; + $entity_qr = '?entity='.((int) $conf->entity); } else { $entity_qr = ''; } diff --git a/htdocs/adherents/agenda.php b/htdocs/adherents/agenda.php index e13211fb239..918eaa5d27e 100644 --- a/htdocs/adherents/agenda.php +++ b/htdocs/adherents/agenda.php @@ -64,7 +64,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index c79143ab345..b6f0489108a 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -112,34 +112,9 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); } else { // Confirm delete contact - if ($action == 'delete' && $user->rights->adherent->supprimer) { + if ($action == 'delete' && $user->hasRight('adherent', 'supprimer')) { $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteAdherent"), $langs->trans("ConfirmDeleteAdherent"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php index 14da758457f..1ad9e4ff3d4 100644 --- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php +++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php @@ -128,12 +128,12 @@ if (empty($user->socid)) { echo ''.$langs->trans('Modify').''; } - if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { + if (!$this->control->tpl['user_id'] && $user->hasRight('user', 'user', 'creer')) { echo ''.$langs->trans("CreateDolibarrLogin").''; } - if ($user->rights->adherent->supprimer) { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas, 'delete', $user->rights->adherent->supprimer); + if ($user->hasRight('adherent', 'supprimer')) { + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas, 'delete', $user->hasRight('adherent', 'supprimer')); } echo '
'; diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 56e7868ec5a..f57bb2e312d 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -6,7 +6,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2012-2020 Philippe Grand * Copyright (C) 2015-2018 Alexandre Spangaro - * Copyright (C) 2018-2021 Frédéric France + * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2021 Waël Almoman * * This program is free software; you can redistribute it and/or modify @@ -305,23 +305,19 @@ if (empty($reshook)) { $object->phone = trim(GETPOST("phone", 'alpha')); $object->phone_perso = trim(GETPOST("phone_perso", 'alpha')); $object->phone_mobile = trim(GETPOST("phone_mobile", 'alpha')); - $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); + $object->email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); + $object->url = trim(GETPOST('member_url', 'custom', 0, FILTER_SANITIZE_URL)); $object->socialnetworks = array(); foreach ($socialnetworks as $key => $value) { if (GETPOSTISSET($key) && GETPOST($key, 'alphanohtml') != '') { $object->socialnetworks[$key] = trim(GETPOST($key, 'alphanohtml')); } } - //$object->skype = trim(GETPOST("skype", 'alpha')); - //$object->twitter = trim(GETPOST("twitter", 'alpha')); - //$object->facebook = trim(GETPOST("facebook", 'alpha')); - //$object->linkedin = trim(GETPOST("linkedin", 'alpha')); - $object->birth = $birthdate; + $object->birth = $birthdate; $object->default_lang = GETPOST('default_lang', 'alpha'); - $object->typeid = GETPOST("typeid", 'int'); - //$object->note = trim(GETPOST("comment","alpha")); - $object->morphy = GETPOST("morphy", 'alpha'); + $object->typeid = GETPOST("typeid", 'int'); + //$object->note = trim(GETPOST("comment","alpha")); + $object->morphy = GETPOST("morphy", 'alpha'); if (GETPOST('deletephoto', 'alpha')) { $object->photo = ''; @@ -330,8 +326,8 @@ if (empty($reshook)) { } // Get status and public property - $object->statut = GETPOST("statut", 'alpha'); - $object->public = GETPOST("public", 'alpha'); + $object->statut = GETPOST("statut", 'alpha'); + $object->public = GETPOST("public", 'alpha'); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); @@ -342,7 +338,7 @@ if (empty($reshook)) { // Check if we need to also synchronize user information $nosyncuser = 0; if ($object->user_id) { // If linked to a user - if ($user->id != $object->user_id && empty($user->rights->user->user->creer)) { + if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'creer')) { $nosyncuser = 1; // Disable synchronizing } } @@ -350,7 +346,7 @@ if (empty($reshook)) { // Check if we need to also synchronize password information $nosyncuserpass = 0; if ($object->user_id) { // If linked to a user - if ($user->id != $object->user_id && empty($user->rights->user->user->password)) { + if ($user->id != $object->user_id && !$user->hasRight('user', 'user', 'password')) { $nosyncuserpass = 1; // Disable synchronizing } } @@ -454,7 +450,7 @@ if (empty($reshook)) { // $facebook=GETPOST("member_facebook", 'alpha'); // $linkedin=GETPOST("member_linkedin", 'alpha'); $email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha')); - $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); + $url = trim(GETPOST('url', 'custom', 0, FILTER_SANITIZE_URL)); $login = GETPOST("member_login", 'alphanohtml'); $pass = GETPOST("password", 'none'); // For password, we use 'none' $photo = GETPOST("photo", 'alphanohtml'); @@ -488,11 +484,6 @@ if (empty($reshook)) { } } - // $object->skype = $skype; - // $object->twitter = $twitter; - // $object->facebook = $facebook; - // $object->linkedin = $linkedin; - $object->email = $email; $object->url = $url; $object->login = $login; @@ -565,7 +556,7 @@ if (empty($reshook)) { } if (!empty($object->url) && !isValidUrl($object->url)) { $langs->load("errors"); - setEventMessages('', $langs->trans("ErrorBadUrl", $object->url), 'errors'); + setEventMessages($langs->trans("ErrorBadUrl", $object->url), null, 'errors'); } $public = 0; if (isset($public)) { @@ -659,7 +650,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -731,7 +722,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_CANCELATION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_CANCELATION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -802,7 +793,7 @@ if (empty($reshook)) { $outputlangs->loadLangs(array("main", "members", "companies", "install", "other")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_EXCLUSION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -1046,7 +1037,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Website print ''.$form->editfieldkey('Web', 'member_url', GETPOST('member_url', 'alpha'), $object, 0).''; - print ''.img_picto('', 'globe').' '; + print ''.img_picto('', 'globe').' '; // Address print ''.$langs->trans("Address").''; @@ -1524,7 +1515,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; + $msg = $arraydefaultmessage->content; } $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); @@ -1533,10 +1524,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
'.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
'.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= '
'.$langs->trans("MailRecipient").': '.$object->email.''; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; @@ -1596,10 +1587,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnResiliate()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
('.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= $langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; @@ -1639,7 +1630,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $outputlangs->loadLangs(array("main", "members")); // Get email content from template $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_EXCLUSION; + $labeltouse = getDolGlobalString('ADHERENT_EMAIL_TEMPLATE_EXCLUSION'); if (!empty($labeltouse)) { $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); @@ -1656,10 +1647,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnExclude()), $substitutionarray, $outputlangs); $tmp = $langs->trans("SendingAnEMailToMember"); - $tmp .= '
('.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.', '; + $tmp .= '
('.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').', '; $tmp .= $langs->trans("MailRecipient").': '.$object->email.')'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("Subject").':
'."\n"; $helpcontent .= $subjecttosend."\n"; diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index e9eb00d23f7..5eb3403b825 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -307,7 +307,7 @@ foreach (array_keys($_Avery_Labels) as $codecards) { } asort($arrayoflabels); print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ?GETPOST('model') : (empty($conf->global->ADHERENT_CARD_TYPE) ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1); -print '
'.$langs->trans("Login").': '; +print '
'.$langs->trans("Login").': '; print '
'; print ''; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 4c68b3e91ec..a9db33b9980 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García - * Copyright (C) 2015-2022 Frédéric France + * Copyright (C) 2015-2023 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART @@ -89,9 +89,22 @@ class Adherent extends CommonObject */ public $pass_indatabase_crypted; + /** + * @var string fullname + */ + public $fullname; + + /** + * @var string The civility code, not an integer + */ + public $civility_id; + public $civility_code; + public $civility; + /** * @var string company name * @deprecated + * @see $company */ public $societe; @@ -102,8 +115,14 @@ class Adherent extends CommonObject /** * @var int Thirdparty ID + * @deprecated + * @see $socid */ public $fk_soc; + + /** + * @var int socid + */ public $socid; /** @@ -154,24 +173,28 @@ class Adherent extends CommonObject /** * @var string skype account * @deprecated + * @see $socialnetworks */ public $skype; /** * @var string twitter account * @deprecated + * @see $socialnetworks */ public $twitter; /** * @var string facebook account * @deprecated + * @see $socialnetworks */ public $facebook; /** * @var string linkedin account * @deprecated + * @see $socialnetworks */ public $linkedin; @@ -259,10 +282,19 @@ class Adherent extends CommonObject */ public $type; + /** + * @var int need_subscription + */ public $need_subscription; + /** + * @var int user_id + */ public $user_id; + /** + * @var string user_login + */ public $user_login; public $datefin; @@ -272,6 +304,10 @@ class Adherent extends CommonObject public $first_subscription_date; + public $first_subscription_date_start; + + public $first_subscription_date_end; + public $first_subscription_amount; public $last_subscription_date; @@ -284,6 +320,10 @@ class Adherent extends CommonObject public $subscriptions = array(); + /** + * @var string ip + */ + public $ip; // Fields loaded by fetchPartnerships() from partnership table @@ -425,8 +465,8 @@ class Adherent extends CommonObject // Envoi mail confirmation $from = $conf->email_from; - if (!empty($conf->global->ADHERENT_MAIL_FROM)) { - $from = $conf->global->ADHERENT_MAIL_FROM; + if (!empty(getDolGlobalString('ADHERENT_MAIL_FROM'))) { + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); } $trackid = 'mem'.$this->id; @@ -576,7 +616,7 @@ class Adherent extends CommonObject */ public function create($user, $notrigger = 0) { - global $conf, $langs; + global $conf, $langs, $mysoc; $error = 0; @@ -624,7 +664,22 @@ class Adherent extends CommonObject $id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent"); if ($id > 0) { $this->id = $id; - $this->ref = (string) $id; + if (getDolGlobalString('MEMBER_CODEMEMBER_ADDON') == '') { + // keep old numbering + $this->ref = (string) $id; + } else { + // auto code + $modfile = dol_buildpath('core/modules/member/'.getDolGlobalString('MEMBER_CODEMEMBER_ADDON').'.php', 0); + try { + require_once $modfile; + $modname = getDolGlobalString('MEMBER_CODEMEMBER_ADDON'); + $modCodeMember = new $modname; + $this->ref = $modCodeMember->getNextValue($mysoc, $this); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + $error++; + } + } // Update minor fields $result = $this->update($user, 1, 1, 0, 0, 'add'); // nosync is 1 to avoid update data of user @@ -1505,7 +1560,7 @@ class Adherent extends CommonObject require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; - $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note, c.fk_bank,"; + $sql = "SELECT c.rowid, c.fk_adherent, c.fk_type, c.subscription, c.note as note_public, c.fk_bank,"; $sql .= " c.tms as datem,"; $sql .= " c.datec as datec,"; $sql .= " c.dateadh as dateh,"; @@ -1537,7 +1592,8 @@ class Adherent extends CommonObject $subscription->fk_adherent = $obj->fk_adherent; $subscription->fk_type = $obj->fk_type; $subscription->amount = $obj->subscription; - $subscription->note = $obj->note; + $subscription->note = $obj->note_public; + $subscription->note_public = $obj->note_public; $subscription->fk_bank = $obj->fk_bank; $subscription->datem = $this->db->jdate($obj->datem); $subscription->datec = $this->db->jdate($obj->datec); @@ -2871,8 +2927,8 @@ class Adherent extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -3015,7 +3071,7 @@ class Adherent extends CommonObject $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); - $from = $conf->global->ADHERENT_MAIL_FROM; + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); $to = $adherent->email; $trackid = 'mem'.$adherent->id; @@ -3167,4 +3223,41 @@ class Adherent extends CommonObject return $nbko; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + + $return = '
'; + $return .= '
'; + $return .= ''; + + if (property_exists($this, 'photo') || !empty($this->photo)) { + $return.= Form::showphoto('memberphoto', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + } else { + $return .= img_picto('', 'user'); + } + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'type')) { + $return .= '
'.$this->type.''; + } + if (method_exists($this, 'getmorphylib')) { + $return .= '
'.$this->getmorphylib('', 2).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 6ab65697745..4a3db45ba03 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -129,6 +129,19 @@ class AdherentType extends CommonObject /** @var string string other */ public $other = array(); + /** + * @var string description + */ + public $description; + + /** + * @var string email + */ + public $email; + + /** + * @var array multilangs + */ public $multilangs = array(); @@ -472,7 +485,7 @@ class AdherentType extends CommonObject } /** - * Function that retrieves the status of the member + * Function that retrieves the properties of a membership type * * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK @@ -626,7 +639,7 @@ class AdherentType extends CommonObject $sql .= ' AND ('.$excludefilter.')'; } - dol_syslog(get_class($this)."::listUsersForGroup", LOG_DEBUG); + dol_syslog(get_class($this)."::listMembersForMemberType", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { @@ -927,4 +940,47 @@ class AdherentType extends CommonObject return ''; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs,$user; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if ($user->rights->adherent->configurer) { + $return .= 'ref.'">'.img_edit().''; + } else { + $return .= ' '; + } + if (property_exists($this, 'vote')) { + $return .= '
'.$langs->trans("VoteAllowed").' : '.yn($this->vote).''; + } + if (property_exists($this, 'amount')) { + if (is_null($this->amount) || $this->amount === '') { + $return .= '
'; + } else { + $return .= '
'.$langs->trans("Amount").''; + $return .= ' : '.price($this->amount).''; + } + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 9aa2fe2e8ad..ed2fa05cf51 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -55,7 +55,7 @@ class AdherentStats extends Stats */ public function __construct($db, $socid = 0, $userid = 0) { - global $user, $conf; + global $conf; $this->db = $db; $this->socid = $socid; @@ -87,8 +87,6 @@ class AdherentStats extends Stats */ public function getNbByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -107,8 +105,6 @@ class AdherentStats extends Stats */ public function getNbByYear() { - global $user; - $sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -128,8 +124,6 @@ class AdherentStats extends Stats */ public function getAmountByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -149,8 +143,6 @@ class AdherentStats extends Stats */ public function getAverageByMonth($year) { - global $user; - $sql = "SELECT date_format(p.dateadh,'%m') as dm, avg(p.".$this->field.")"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -170,8 +162,6 @@ class AdherentStats extends Stats */ public function getAllByYear() { - global $user; - $sql = "SELECT date_format(p.dateadh,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql .= " FROM ".$this->from; //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -181,4 +171,82 @@ class AdherentStats extends Stats return $this->_getAllByYear($sql); } + + + + /** + * Return count of member by status group by adh type, total and average + * + * @param int $numberYears Years to scan + * @return array Array with total of draft, pending, uptodate, expired, resiliated for each member tag + */ + public function countMembersByTagAndStatus($numberYears = 2) + { + global $user; + + $now = dol_now(); + $endYear = date('Y'); + $startYear = $endYear - $numberYears; + + $sql = "SELECT c.rowid as fk_categorie, c.label as label"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_DRAFT, "'members_draft'", 'NULL').") as members_draft"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin IS NULL AND t.subscription = '1')", "'members_pending'", 'NULL').") as members_pending"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin >= '".$this->db->idate($now)."' OR t.subscription = 0)", "'members_uptodate'", 'NULL').") as members_uptodate"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_VALIDATED." AND (d.datefin < '".$this->db->idate($now)."' AND t.subscription = 1)", "'members_expired'", 'NULL').") as members_expired"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_EXCLUDED, "'members_excluded'", 'NULL').") as members_excluded"; + $sql .= ", COUNT(".$this->db->ifsql("d.statut = ".Adherent::STATUS_RESILIATED, "'members_resiliated'", 'NULL').") as members_resiliated"; + $sql .= " FROM ".MAIN_DB_PREFIX."categorie as c"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_member as ct ON c.rowid = ct.fk_categorie"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d ON d.rowid = ct.fk_member"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as t ON t.rowid = d.fk_adherent_type"; + $sql .= " WHERE c.entity IN (".getEntity('member_type').")"; + $sql .= " AND d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND t.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.datefin > '".$this->db->idate(dol_get_first_day($startYear))."'"; + $sql .= " AND c.fk_parent = 0"; + $sql .= " GROUP BY c.rowid"; + + dol_syslog("box_members_by_type::select nb of members per type", LOG_DEBUG); + $result = $this->db->query($sql); + + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $MembersCountArray = []; + $totalstatus = array( + 'label' => 'Total', + 'members_draft' => 0, + 'members_pending' => 0, + 'members_uptodate' => 0, + 'members_expired' => 0, + 'members_excluded' => 0, + 'members_resiliated' => 0 + ); + while ($i < $num) { + $objp = $this->db->fetch_object($result); + $MembersCountArray[$objp->fk_categorie] = array( + 'label' => $objp->label, + 'members_draft' => (int) $objp->members_draft, + 'members_pending' => (int) $objp->members_pending, + 'members_uptodate' => (int) $objp->members_uptodate, + 'members_expired' => (int) $objp->members_expired, + 'members_excluded' => (int) $objp->members_excluded, + 'members_resiliated' => (int) $objp->members_resiliated + ); + $totalrow = 0; + foreach ($MembersCountArray[$objp->fk_categorie] as $key=>$nb) { + if ($key!='label') { + $totalrow += $nb; + $totalstatus[$key] += $nb; + } + } + $MembersCountArray[$objp->fk_categorie]['total_adhtype'] = $totalrow; + $i++; + } + $this->db->free($result); + $MembersCountArray['total'] = $totalstatus; + $MembersCountArray['total']['all'] = array_sum($totalstatus); + } + return $MembersCountArray; + } } diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 51ef1153a57..1e1f8db1bbf 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -62,7 +62,7 @@ class Members extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -99,7 +99,7 @@ class Members extends DolibarrApi */ public function getByThirdparty($thirdparty) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -132,7 +132,7 @@ class Members extends DolibarrApi */ public function getByThirdpartyEmail($email) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -171,7 +171,7 @@ class Members extends DolibarrApi */ public function getByThirdpartyBarcode($barcode) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -217,7 +217,7 @@ class Members extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -370,7 +370,7 @@ class Members extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'supprimer')) { throw new RestException(401); } $member = new Adherent($this->db); @@ -464,7 +464,7 @@ class Members extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -495,7 +495,7 @@ class Members extends DolibarrApi */ public function createSubscription($id, $start_date, $end_date, $amount, $label = '') { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 95c514bfedf..e7c039d1038 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -55,7 +55,7 @@ class MembersTypes extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -92,7 +92,7 @@ class MembersTypes extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(401); } @@ -151,7 +151,7 @@ class MembersTypes extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } // Check mandatory fields @@ -176,7 +176,7 @@ class MembersTypes extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } @@ -216,7 +216,7 @@ class MembersTypes extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->adherent->configurer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'configurer')) { throw new RestException(401); } $membertype = new AdherentType($this->db); diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 67484a723fd..dd01ca94027 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -58,7 +58,7 @@ class Subscriptions extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -91,7 +91,7 @@ class Subscriptions extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'lire')) { throw new RestException(401); } @@ -148,7 +148,7 @@ class Subscriptions extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } // Check mandatory fields @@ -206,7 +206,7 @@ class Subscriptions extends DolibarrApi public function delete($id) { // The right to delete a subscription comes with the right to create one. - if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'cotisation', 'creer')) { throw new RestException(401); } $subscription = new Subscription($this->db); diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index b3cfe027197..b5079676603 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -505,4 +505,37 @@ class Subscription extends CommonObject dol_print_error($this->db); } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + + $return .= '
'; + $return .= ''.(property_exists($this, 'fk_adherent')? $this->fk_adherent: $this->ref ).''; + if (property_exists($this, 'dateh') || property_exists($this, 'datef')) { + $return .= '
'.dol_print_date($this->dateh, 'day').' - '.dol_print_date($this->datef, 'day').''; + } + + if (property_exists($this, 'fk_bank')) { + $return .= '
'.$this->fk_bank.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 4517bee15c6..d3aa8cc2211 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -80,7 +80,7 @@ if ($id > 0 || !empty($ref)) { // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $$user->hasRight('user', 'self', 'creer')) + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); diff --git a/htdocs/adherents/htpasswd.php b/htdocs/adherents/htpasswd.php index a97a0a74d28..a36f8092add 100644 --- a/htdocs/adherents/htpasswd.php +++ b/htdocs/adherents/htpasswd.php @@ -37,7 +37,7 @@ $sortorder = GETPOST('sortorder', 'aZ09'); if (!isModEnabled('adherent')) { accessforbidden(); } -if (empty($user->rights->adherent->export)) { +if (!$user->hasRight('adherent', 'export')) { accessforbidden(); } diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 7f09bccb3d3..83b7e5f3764 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -51,14 +51,14 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); // Define variables to know what current user can do on users - $canadduser = (!empty($user->admin) || !empty($user->rights->user->user->creer)); + $canadduser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer')); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member $caneditfielduser = ((($user->id == $object->user_id) && !empty($user->rights->user->self->creer)) - || (($user->id != $object->user_id) && !empty($user->rights->user->user->creer))); + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && !empty($user->rights->user->user->password))); + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); } } diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index c2b81860210..2e04aba9167 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -30,9 +30,9 @@ // Load Dolibarr environment require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -41,46 +41,51 @@ $langs->loadLangs(array("members", "companies")); // Get parameters -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); -$confirm = GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'memberslist'; // To manage different context of search - +$backtopage = GETPOST('backtopage', 'alpha'); +$optioncss = GETPOST('optioncss', 'aZ'); +$mode = GETPOST('mode', 'alpha'); // Search fields -$search = GETPOST("search", 'alpha'); -$search_ref = GETPOST("search_ref", 'alpha'); -$search_lastname = GETPOST("search_lastname", 'alpha'); -$search_firstname = GETPOST("search_firstname", 'alpha'); -$search_gender = GETPOST("search_gender", 'alpha'); -$search_civility = GETPOST("search_civility", 'alpha'); -$search_company = GETPOST('search_company', 'alphanohtml'); -$search_login = GETPOST("search_login", 'alpha'); -$search_address = GETPOST("search_address", 'alpha'); -$search_zip = GETPOST("search_zip", 'alpha'); -$search_town = GETPOST("search_town", 'alpha'); -$search_state = GETPOST("search_state", 'alpha'); -$search_country = GETPOST("search_country", 'alpha'); -$search_phone = GETPOST("search_phone", 'alpha'); +$search = GETPOST("search", 'alpha'); +$search_ref = GETPOST("search_ref", 'alpha'); +$search_lastname = GETPOST("search_lastname", 'alpha'); +$search_firstname = GETPOST("search_firstname", 'alpha'); +$search_gender = GETPOST("search_gender", 'alpha'); +$search_civility = GETPOST("search_civility", 'alpha'); +$search_company = GETPOST('search_company', 'alphanohtml'); +$search_login = GETPOST("search_login", 'alpha'); +$search_address = GETPOST("search_address", 'alpha'); +$search_zip = GETPOST("search_zip", 'alpha'); +$search_town = GETPOST("search_town", 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); // county / departement / federal state +$search_country = GETPOST("search_country", 'alpha'); +$search_phone = GETPOST("search_phone", 'alpha'); $search_phone_perso = GETPOST("search_phone_perso", 'alpha'); $search_phone_mobile = GETPOST("search_phone_mobile", 'alpha'); -$search_type = GETPOST("search_type", 'alpha'); -$search_email = GETPOST("search_email", 'alpha'); -$search_categ = GETPOST("search_categ", 'int'); -$search_filter = GETPOST("search_filter", 'alpha'); -$search_status = GETPOST("search_status", 'intcomma'); -$search_morphy = GETPOST("search_morphy", 'alpha'); -$search_import_key = trim(GETPOST("search_import_key", "alpha")); -$catid = GETPOST("catid", 'int'); -$optioncss = GETPOST('optioncss', 'alpha'); -$socid = GETPOST('socid', 'int'); +$search_type = GETPOST("search_type", 'alpha'); +$search_email = GETPOST("search_email", 'alpha'); +$search_categ = GETPOST("search_categ", 'int'); +$search_morphy = GETPOST("search_morphy", 'alpha'); +$search_import_key = trim(GETPOST("search_import_key", 'alpha')); + +$catid = GETPOST("catid", 'int'); +$socid = GETPOST('socid', 'int'); + +$search_filter = GETPOST("search_filter", 'alpha'); +$search_status = GETPOST("search_status", 'intcomma'); // statut $filter = GETPOST("filter", 'alpha'); if ($filter) { $search_filter = $filter; // For backward compatibility } + $statut = GETPOST("statut", 'alpha'); if ($statut != '') { $search_status = $statut; // For backward compatibility @@ -92,6 +97,7 @@ if ($search_status < -2) { $search_status = ''; } +// Pagination parameters $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -126,7 +132,6 @@ $fieldstosearchall = array( 'd.login'=>'Login', 'd.lastname'=>'Lastname', 'd.firstname'=>'Firstname', - 'd.login'=>'Login', 'd.societe'=>"Company", 'd.email'=>'EMail', 'd.address'=>'Address', @@ -141,6 +146,7 @@ $fieldstosearchall = array( if ($db->type == 'pgsql') { unset($fieldstosearchall['d.rowid']); } + $arrayfields = array( 'd.ref'=>array('label'=>"Ref", 'checked'=>1), 'd.civility'=>array('label'=>"Civility", 'checked'=>0), @@ -169,6 +175,7 @@ $arrayfields = array( 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), 'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -262,7 +269,7 @@ if (empty($reshook)) { } // Create external user - if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->rights->user->user->creer) { + if ($massaction == 'createexternaluser' && $user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) { $tmpmember = new Adherent($db); $error = 0; $nbcreated = 0; @@ -317,7 +324,11 @@ $formother = new FormOther($db); $membertypestatic = new AdherentType($db); $memberstatic = new Adherent($db); -$title = $langs->trans("Members"); +// Page Header +$title = $langs->trans("Members")." - ".$langs->trans("List");; +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros|DE:Modul_Mitglieder'; +llxHeader('', $title, $help_url); + $now = dol_now(); @@ -335,12 +346,14 @@ $sql .= " s.nom,"; $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,"; $sql .= " t.libelle as type, t.subscription,"; $sql .= " state.code_departement as state_code, state.nom as state_name,"; + // 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.', ' : ''); } } + // Add fields from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook @@ -349,13 +362,16 @@ $sql = preg_replace('/,\s*$/', '', $sql); $sqlfields = $sql; // $sql fields to remove for count total -$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; +// SQL Aliase adherent +$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; // maybe better to use ad (adh) instead od d if (!empty($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 (d.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)"; + +// SQL Aliase adherent_type $sql .= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " WHERE d.fk_adherent_type = t.rowid"; @@ -525,8 +541,6 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; -llxHeader('', $title, $help_url); if ($search_type > 0) { $membertype = new AdherentType($db); @@ -534,7 +548,11 @@ if ($search_type > 0) { $title .= " (".$membertype->label.")"; } +// $parameters $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -610,6 +628,7 @@ if ($search_type > 0) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -636,6 +655,8 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->hasRight('adherent', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); } @@ -650,6 +671,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -698,6 +721,7 @@ print ''; + // Action column if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print ''; } + // Line numbering if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print ''; @@ -716,32 +741,45 @@ if (!empty($arrayfields['d.ref']['checked'])) { print ''; print ''; } + +// Civility if (!empty($arrayfields['d.civility']['checked'])) { print ''; } + +// First Name if (!empty($arrayfields['d.firstname']['checked'])) { print ''; } + +// Last Name if (!empty($arrayfields['d.lastname']['checked'])) { print ''; } + +// Gender if (!empty($arrayfields['d.gender']['checked'])) { print ''; } + +// Company if (!empty($arrayfields['d.company']['checked'])) { print ''; } + +// Login if (!empty($arrayfields['d.login']['checked'])) { print ''; } + // Nature if (!empty($arrayfields['d.morphy']['checked'])) { print ''; } + +// Member Type if (!empty($arrayfields['t.libelle']['checked'])) { print ''; } @@ -759,51 +799,62 @@ if (!empty($arrayfields['t.libelle']['checked'])) { print ''; } +// Address - Street if (!empty($arrayfields['d.address']['checked'])) { print ''; } +// ZIP if (!empty($arrayfields['d.zip']['checked'])) { print ''; } + +// Town/City if (!empty($arrayfields['d.town']['checked'])) { print ''; } -// State + +// State / County / Departement if (!empty($arrayfields['state.nom']['checked'])) { print ''; } + // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } + // Phone pro if (!empty($arrayfields['d.phone']['checked'])) { print ''; } + // Phone perso if (!empty($arrayfields['d.phone_perso']['checked'])) { print ''; + print ''; } + // Phone mobile if (!empty($arrayfields['d.phone_mobile']['checked'])) { print ''; } + // Email if (!empty($arrayfields['d.email']['checked'])) { print ''; } + // End of subscription date if (!empty($arrayfields['d.datefin']['checked'])) { print ''; } + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; @@ -819,38 +871,45 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation if (!empty($arrayfields['d.datec']['checked'])) { print ''; } + // Birthday if (!empty($arrayfields['d.birth']['checked'])) { print ''; } + // Date modification if (!empty($arrayfields['d.tms']['checked'])) { print ''; } + // Status if (!empty($arrayfields['d.statut']['checked'])) { - print ''; } + +// Import Key if (!empty($arrayfields['d.import_key']['checked'])) { print ''; } + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { // Action column print ''; - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - - if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Civility - if (!empty($arrayfields['d.civility']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Gender - if (!empty($arrayfields['d.gender']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Company - if (!empty($arrayfields['d.company']['checked'])) { - print '\n"; - } - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Nature (Moral/Physical) - if (!empty($arrayfields['d.morphy']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type label - if (!empty($arrayfields['t.libelle']['checked'])) { $membertypestatic->id = $obj->type_id; $membertypestatic->label = $obj->type; - print ''; - if (!$i) { - $totalarray['nbfield']++; + $memberstatic->type = $membertypestatic->label; + $memberstatic->photo = $obj->photo; + // Output Kanban + print $memberstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } - // Address - if (!empty($arrayfields['d.address']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['d.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['d.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - $tmparray = getCountry($obj->country, 'all'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone pro - if (!empty($arrayfields['d.phone']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone perso - if (!empty($arrayfields['d.phone_perso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Phone mobile - if (!empty($arrayfields['d.phone_mobile']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // EMail - if (!empty($arrayfields['d.email']['checked'])) { - print '\n"; - } - // End of subscription date - $datefin = $db->jdate($obj->datefin); - if (!empty($arrayfields['d.datefin']['checked'])) { - print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + // Technical ID + if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Civility + if (!empty($arrayfields['d.civility']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Gender + if (!empty($arrayfields['d.gender']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Company + if (!empty($arrayfields['d.company']['checked'])) { + print '\n"; + } + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Nature (Moral/Physical) + if (!empty($arrayfields['d.morphy']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type label + if (!empty($arrayfields['t.libelle']['checked'])) { + $membertypestatic->id = $obj->type_id; + $membertypestatic->label = $obj->type; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Address + if (!empty($arrayfields['d.address']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['d.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['d.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State / County / Departement + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + $tmparray = getCountry($obj->country, 'all'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone pro + if (!empty($arrayfields['d.phone']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone perso + if (!empty($arrayfields['d.phone_perso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Phone mobile + if (!empty($arrayfields['d.phone_mobile']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // EMail + if (!empty($arrayfields['d.email']['checked'])) { + print '\n"; + } + // End of subscription date + $datefin = $db->jdate($obj->datefin); + if (!empty($arrayfields['d.datefin']['checked'])) { + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['d.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['d.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Birth - if (!empty($arrayfields['d.birth']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['d.statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['d.import_key']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + // Date modification + if (!empty($arrayfields['d.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['d.statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['d.import_key']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } - print ''."\n"; + print ''."\n"; + } $i++; } diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php index 805a3137226..3664187b34e 100644 --- a/htdocs/adherents/partnership.php +++ b/htdocs/adherents/partnership.php @@ -76,13 +76,13 @@ foreach ($object->fields as $key => $val) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php -$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('partnership', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('partnership', 'write'); // Used by the include of actions_dellink.inc.php +$usercanclose = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 93b57a630e1..8c423d53029 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -151,9 +151,9 @@ if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'ye } } -if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->rights->user->user->creer)) { +if (empty($reshook) && $action == 'setuserid' && ($user->rights->user->self->creer || $user->hasRight('user', 'user', 'creer'))) { $error = 0; - if (empty($user->rights->user->user->creer)) { // If can edit only itself user, we can link to itself only + if (!$user->hasRight('user', 'user', 'creer')) { // If can edit only itself user, we can link to itself only if (GETPOST("userid", 'int') != $user->id && GETPOST("userid", 'int') != $object->user_id) { $error++; setEventMessages($langs->trans("ErrorUserPermissionAllowsToLinksToItselfOnly"), null, 'errors'); @@ -201,7 +201,7 @@ if (empty($reshook) && $action == 'setsocid') { } } -if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && !$cancel) { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) { $error = 0; $langs->load("banks"); @@ -674,7 +674,7 @@ if ($rowid > 0) { */ // Button to create a new subscription if member no draft (-1) neither resiliated (0) neither excluded (-2) - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { if ($action != 'addsubscription' && $action != 'create_thirdparty') { print '
'; @@ -814,7 +814,7 @@ if ($rowid > 0) { /* * Add new subscription form */ - if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->rights->adherent->cotisation->creer) { + if (($action == 'addsubscription' || $action == 'create_thirdparty') && $user->hasRight('adherent', 'cotisation', 'creer')) { print '
'; print load_fiche_titre($langs->trans("NewCotisation")); @@ -1142,7 +1142,7 @@ if ($rowid > 0) { $tmp = 'global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; $helpcontent = ''; - $helpcontent .= ''.$langs->trans("MailFrom").': '.$conf->global->ADHERENT_MAIL_FROM.'
'."\n"; + $helpcontent .= ''.$langs->trans("MailFrom").': '.getDolGlobalString('ADHERENT_MAIL_FROM').'
'."\n"; $helpcontent .= ''.$langs->trans("MailRecipient").': '.$object->email.'
'."\n"; $helpcontent .= ''.$langs->trans("MailTopic").':
'."\n"; if ($subjecttosend) { diff --git a/htdocs/adherents/subscription/card.php b/htdocs/adherents/subscription/card.php index 83f1a01441c..ea47ffc9362 100644 --- a/htdocs/adherents/subscription/card.php +++ b/htdocs/adherents/subscription/card.php @@ -49,13 +49,13 @@ $note = GETPOST('note', 'alpha'); $typeid = (int) GETPOST('typeid', 'int'); $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); -if (empty($user->rights->adherent->cotisation->lire)) { +if (!$user->hasRight('adherent', 'cotisation', 'lire')) { accessforbidden(); } -$permissionnote = $user->rights->adherent->cotisation->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->adherent->cotisation->creer; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->adherent->cotisation->creer; // Used by the include of actions_lineupdonw.inc.php +$permissionnote = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->hasRight('adherent', 'cotisation', 'creer'); // Used by the include of actions_lineupdonw.inc.php $hookmanager->initHooks(array('subscriptioncard', 'globalcard')); @@ -78,7 +78,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, n //include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once -if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cancel) { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'update' && !$cancel) { // Load current object $result = $object->fetch($rowid); if ($result > 0) { @@ -109,8 +109,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance $object->dateh = dol_mktime(GETPOST('datesubhour', 'int'), GETPOST('datesubmin', 'int'), 0, GETPOST('datesubmonth', 'int'), GETPOST('datesubday', 'int'), GETPOST('datesubyear', 'int')); $object->datef = dol_mktime(GETPOST('datesubendhour', 'int'), GETPOST('datesubendmin', 'int'), 0, GETPOST('datesubendmonth', 'int'), GETPOST('datesubendday', 'int'), GETPOST('datesubendyear', 'int')); $object->fk_type = $typeid; - $object->note = $note; + $object->note_public = $note; $object->note_private = $note; + $object->amount = $amount; $result = $object->update($user); @@ -140,7 +141,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->adherent->cotisation->creer) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('adherent', 'cotisation', 'creer')) { $result = $object->fetch($rowid); $result = $object->delete($user); if ($result > 0) { @@ -166,7 +167,7 @@ llxHeader('', $langs->trans("SubscriptionCard"), $help_url); dol_htmloutput_errors($errmsg); -if ($user->rights->adherent->cotisation->creer && $action == 'edit') { +if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'edit') { /******************************************** * * Subscription card in edit mode @@ -350,7 +351,7 @@ if ($rowid && $action != 'edit') { */ print '
'; - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { if (!empty($bankline->rappro)) { print '"; } else { @@ -359,7 +360,7 @@ if ($rowid && $action != 'edit') { } // Delete - if ($user->rights->adherent->cotisation->creer) { + if ($user->hasRight('adherent', 'cotisation', 'creer')) { print '\n"; } diff --git a/htdocs/adherents/subscription/info.php b/htdocs/adherents/subscription/info.php index 5faf1d31760..14afbafca50 100644 --- a/htdocs/adherents/subscription/info.php +++ b/htdocs/adherents/subscription/info.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "members", "bills", "users")); -if (empty($user->rights->adherent->lire)) { +if (!$user->hasRight('adherent', 'lire')) { accessforbidden(); } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 1523bd4ee90..3c17fc64852 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -37,6 +37,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'subscriptionlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); + $statut = (GETPOSTISSET("statut") ?GETPOST("statut", "alpha") : 1); $search_ref = GETPOST('search_ref', 'alpha'); @@ -242,17 +244,20 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; -llxHeader('', $langs->trans("ListOfSubscriptions"), $help_url); - -$i = 0; - -$title = $langs->trans("ListOfSubscriptions"); +$title = $langs->trans("Subscriptions"); if (!empty($date_select)) { $title .= ' ('.$langs->trans("Year").' '.$date_select.')'; } +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('', $title, $help_url); + +$i = 0; + $param = ''; +if (!empty($mode)) { + $param .='&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -291,14 +296,17 @@ $arrayofmassactions = array( //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); -//if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); +//if ($user->hasRight('adherent', 'supprimer')) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; -if ($user->rights->adherent->cotisation->creer) { +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + +if ($user->hasRight('adherent', 'cotisation', 'creer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); } @@ -313,6 +321,8 @@ print ''; print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $subscription->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -507,143 +517,166 @@ while ($i < min($num, $limit)) { $adherent->need_subscription = $adht->subscription; - print '
'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type - if (!empty($arrayfields['d.fk_type']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Lastname - if (!empty($arrayfields['d.lastname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Firstname - if (!empty($arrayfields['d.firstname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Login - if (!empty($arrayfields['d.login']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['t.libelle']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Banque - if (!empty($arrayfields['d.bank']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; + // Output Kanban + print $subscription->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Date start - if (!empty($arrayfields['c.dateadh']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end - if (!empty($arrayfields['c.datef']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['d.fk_type']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Price - if (!empty($arrayfields['d.amount']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Lastname + if (!empty($arrayfields['d.lastname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + // Firstname + if (!empty($arrayfields['d.firstname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (empty($totalarray['val']['d.amount'])) { - $totalarray['val']['d.amount'] = $obj->subscription; - } else { - $totalarray['val']['d.amount'] += $obj->subscription; + + // Login + if (!empty($arrayfields['d.login']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['t.libelle']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Banque + if (!empty($arrayfields['d.bank']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date start + if (!empty($arrayfields['c.dateadh']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date end + if (!empty($arrayfields['c.datef']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Price + if (!empty($arrayfields['d.amount']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.amount'; + } + if (empty($totalarray['val']['d.amount'])) { + $totalarray['val']['d.amount'] = $obj->subscription; + } else { + $totalarray['val']['d.amount'] += $obj->subscription; + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + print ''; if (!$i) { $totalarray['nbfield']++; } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + print "\n"; + } $i++; } diff --git a/htdocs/adherents/tpl/linkedobjectblock.tpl.php b/htdocs/adherents/tpl/linkedobjectblock.tpl.php index 5928b706a8e..d4efa349202 100644 --- a/htdocs/adherents/tpl/linkedobjectblock.tpl.php +++ b/htdocs/adherents/tpl/linkedobjectblock.tpl.php @@ -39,7 +39,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { echo ''; echo ''; echo ''; - print ''; - print ''; - print ''; + } } else { - print $langs->trans("MorAndPhy"); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($user->rights->adherent->configurer) { + print ''; + } else { + print ''; + } + print ""; } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($user->rights->adherent->configurer) { - print ''; - } else { - print ''; - } - print ""; $i++; } diff --git a/htdocs/adherents/type_translation.php b/htdocs/adherents/type_translation.php index 9539250cb44..85b346b4225 100644 --- a/htdocs/adherents/type_translation.php +++ b/htdocs/adherents/type_translation.php @@ -71,7 +71,7 @@ if ($action == 'delete' && GETPOST('langtodelete', 'alpha')) { } // Add translation -if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -99,7 +99,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $user->rights->ad } // Edit translation -if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $current_lang = $langs->getDefaultLang(); @@ -125,7 +125,7 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $user->rights->a } // Delete translation -if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->rights->adherent->configurer) { +if ($action == 'vdelete' && $cancel != $langs->trans("Cancel") && $user->hasRight('adherent', 'configurer')) { $object = new AdherentType($db); $object->fetch($id); $langtodelete = GETPOST('langdel', 'alpha'); diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 1b5a0e5d0fe..618f2d50ffa 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -42,14 +42,14 @@ if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); // Define variables to know what current user can do on users - $canadduser = ($user->admin || $user->rights->user->user->creer); + $canadduser = ($user->admin || $user->hasRight('user', 'user', 'creer')); // Define variables to know what current user can do on properties of user linked to edited member if ($object->user_id) { // $User is the user who edits, $object->user_id is the id of the related user in the edited member - $caneditfielduser = ((($user->id == $object->user_id) && $user->rights->user->self->creer) - || (($user->id != $object->user_id) && $user->rights->user->user->creer)); - $caneditpassworduser = ((($user->id == $object->user_id) && $user->rights->user->self->password) - || (($user->id != $object->user_id) && $user->rights->user->user->password)); + $caneditfielduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'creer')) + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'creer'))); + $caneditpassworduser = ((($user->id == $object->user_id) && $user->hasRight('user', 'self', 'password')) + || (($user->id != $object->user_id) && $user->hasRight('user', 'user', 'password'))); } } @@ -122,18 +122,23 @@ if ($company->id) { } elseif (empty(trim($object->email))) { // when adherent e-mail is empty, use only company e-mail $v->setEmail($company->email); - } elseif (strtolower(end(explode("@", $object->email))) == strtolower(end(explode("@", $company->email)))) { - // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) - $v->setEmail($object->email); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($company->email, 'INTERNET'); } else { - // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) - $v->setEmail($company->email); + $tmpobject = explode("@", trim($object->email)); + $tmpcompany = explode("@", trim($company->email)); - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($object->email, 'INTERNET'); + if (strtolower(end($tmpobject)) == strtolower(end($tmpcompany))) { + // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) + $v->setEmail($object->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($company->email, 'INTERNET'); + } else { + // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) + $v->setEmail($company->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($object->email, 'INTERNET'); + } } // Si adherent lie a un tiers non de type "particulier" diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 7b057a0693c..aef46db26ef 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -54,6 +54,9 @@ $type = 'action'; * Actions */ +$error = 0; +$errors = array(); + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $reg = array(); @@ -193,10 +196,9 @@ print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); /* - * Documents models for supplier orders + * Miscellaneous */ - // Define array def of models $def = array(); @@ -308,8 +310,11 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { } } print '
'; @@ -705,6 +729,7 @@ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print $searchpicto; print ' '; print ''; print ''; print ''; $arraygender = array('man'=>$langs->trans("Genderman"), 'woman'=>$langs->trans("Genderwoman"), 'other'=>$langs->trans("Genderother")); print $form->selectarray('search_gender', $arraygender, $search_gender, 1); print ''; print ''; print ''; @@ -749,6 +787,8 @@ if (!empty($arrayfields['d.morphy']['checked'])) { print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100'); print ''; print ''; print ''; print ''; print ''; print ''; print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); print ''; print ''; - print ''; print ''; print ''; @@ -812,6 +863,7 @@ if (!empty($arrayfields['d.datefin']['checked'])) { print $form->selectarray('search_filter', $selectarray, $search_filter); print ''; print ''; print ''; print ''; + print ''; $liststatus = array( Adherent::STATUS_DRAFT => $langs->trans("Draft"), Adherent::STATUS_VALIDATED => $langs->trans("Validated"), Adherent::STATUS_RESILIATED => $langs->trans("MemberStatusResiliatedShort"), Adherent::STATUS_EXCLUDED =>$langs->trans("MemberStatusExcludedShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -3, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; print ''; print ''; @@ -931,6 +990,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + if (!empty($arrayfields['d.datec']['checked'])) { print_liste_field_titre($arrayfields['d.datec']['label'], $_SERVER["PHP_SELF"], "d.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); } @@ -988,276 +1048,292 @@ while ($i < min($num, $limit)) { } $memberstatic->company = $companyname; - print '
'; - 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 ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - print '
'.$obj->rowid.'"; - print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); - print ""; - print $obj->civility; - print "'; - print $memberstatic->getNomUrl(0, 0, 'card', 'firstname'); - //print $obj->firstname; - print "'; - print $memberstatic->getNomUrl(0, 0, 'card', 'lastname'); - //print $obj->lastname; - print "'; - if ($obj->gender) { - print $langs->trans("Gender".$obj->gender); - } - print ''; - print $companynametoshow; - print "'.$obj->login."'; - print $memberstatic->getmorphylib('', 2); - print "'; - print $membertypestatic->getNomUrl(1, 32); - print '
'; - print $obj->address; - print ''; - print $obj->zip; - print ''; - print $obj->town; - print '".$obj->state_name."'; - print dol_escape_htmltag($tmparray['label']); - print ''; - print $obj->phone; - print ''; - print $obj->phone_perso; - print ''; - print $obj->phone_mobile; - print ''; - print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1); - print "'; - if ($datefin) { - print dol_print_date($datefin, 'day'); - if ($memberstatic->hasDelay()) { - $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; - print " ".img_warning($langs->trans("SubscriptionLate").$textlate); + } else { + print '
'; + 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 ''; } - } else { - if (!empty($obj->subscription)) { - print ''.$langs->trans("SubscriptionNotReceived").''; - if ($obj->statut > 0) { - print " ".img_warning(); + print ''.$obj->rowid.'"; + print $memberstatic->getNomUrl(-1, 0, 'card', 'ref', '', -1, 0, 1); + print ""; + print $obj->civility; + print "'; + print $memberstatic->getNomUrl(0, 0, 'card', 'firstname'); + //print $obj->firstname; + print "'; + print $memberstatic->getNomUrl(0, 0, 'card', 'lastname'); + //print $obj->lastname; + print "'; + if ($obj->gender) { + print $langs->trans("Gender".$obj->gender); + } + print ''; + print $companynametoshow; + print "'.$obj->login."'; + print $memberstatic->getmorphylib('', 2); + print "'; + print $membertypestatic->getNomUrl(1, 32); + print ''; + print $obj->address; + print ''; + print $obj->zip; + print ''; + print $obj->town; + print '".$obj->state_name."'; + print dol_escape_htmltag($tmparray['label']); + print ''; + print $obj->phone; + print ''; + print $obj->phone_perso; + print ''; + print $obj->phone_mobile; + print ''; + print dol_print_email($obj->email, 0, 0, 1, 64, 1, 1); + print "'; + if ($datefin) { + print dol_print_date($datefin, 'day'); + if ($memberstatic->hasDelay()) { + $textlate = ' ('.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24) >= 0 ? '+' : '').ceil($conf->adherent->subscription->warning_delay / 60 / 60 / 24).' '.$langs->trans("days").')'; + print " ".img_warning($langs->trans("SubscriptionLate").$textlate); } } else { - print ' '; + if (!empty($obj->subscription)) { + print ''.$langs->trans("SubscriptionNotReceived").''; + if ($obj->statut > 0) { + print " ".img_warning(); + } + } else { + print ' '; + } + } + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); - print ''; - print dol_escape_htmltag($obj->import_key); - print "'; - 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; + // Birth + if (!empty($arrayfields['d.birth']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->birth), 'day', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print $memberstatic->LibStatut($obj->statut, $obj->subscription, $datefin, 5); + print ''; + print dol_escape_htmltag($obj->import_key); + print "'; + 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 ''; + } + print '
'; + print '
'; + } - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print '
'.$subscription->getNomUrl(1).''; - if ($typeid > 0) { - print $adht->getNomUrl(1); - } - print ''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''.$adherent->firstname.''.$adherent->login.''; - print $obj->note; - print ''; + //fetch informations needs on this mode + $subscription->fk_adherent = $adherent->getNomUrl(1); + $subscription->fk_type = $adht->getNomUrl(1); + $subscription->amount = $obj->subscription; if ($obj->fk_account > 0) { $accountstatic->id = $obj->fk_account; $accountstatic->fetch($obj->fk_account); - //$accountstatic->label=$obj->label; - print $accountstatic->getNomUrl(1); + $subscription->fk_bank = $accountstatic->getNomUrl(1); } - print "
'.dol_print_date($db->jdate($obj->dateadh), 'day')."'.$subscription->getNomUrl(1).''.dol_print_date($db->jdate($obj->datef), 'day')."'; + if ($typeid > 0) { + print $adht->getNomUrl(1); + } + print ''.price($obj->subscription).''.$adherent->getNomUrl(-1, 0, 'card', 'lastname').''.$adherent->firstname.''.$adherent->login.''; + print $obj->note; + print ''; + if ($obj->fk_account > 0) { + $accountstatic->id = $obj->fk_account; + $accountstatic->fetch($obj->fk_account); + //$accountstatic->label=$obj->label; + print $accountstatic->getNomUrl(1); + } + print "'.dol_print_date($db->jdate($obj->dateadh), 'day')."'.dol_print_date($db->jdate($obj->datef), 'day')."'.price($obj->subscription).''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + 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->crowid, $arrayofselected)) { + $selected = 1; + } + print ''; } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - 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->crowid, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.dol_print_date($objectlink->dateh, 'day').''; - if ($user->rights->adherent->lire) { + if ($user->hasRight('adherent', 'lire')) { $total = $total + $objectlink->amount; echo price($objectlink->amount); } diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 962624db428..f516efdd819 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -44,6 +44,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); +$mode = GETPOST('mode', 'alopha'); $sall = GETPOST("sall", "alpha"); $filter = GETPOST("filter", 'alpha'); @@ -171,7 +172,7 @@ if ($action == 'add' && $user->hasRight('adherent', 'configurer')) { } } -if ($action == 'update' && $user->rights->adherent->configurer) { +if ($action == 'update' && $user->hasRight('adherent', 'configurer')) { $object->fetch($rowid); $object->oldcopy = dol_clone($object); @@ -207,7 +208,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) { exit; } -if ($action == 'confirm_delete' && !empty($user->rights->adherent->configurer)) { +if ($action == 'confirm_delete' && $user->hasRight('adherent', 'configurer')) { $object->fetch($rowid); $res = $object->delete(); @@ -249,6 +250,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode'.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } @@ -257,7 +261,11 @@ if (!$rowid && $action != 'create' && $action != 'edit') { } $newcardbutton = ''; - if ($user->rights->adherent->configurer) { + + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + + if ($user->hasRight('adherent', 'configurer')) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create'); } @@ -270,6 +278,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MembersTypes"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'members', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -292,7 +302,13 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype = new AdherentType($db); - while ($i < $num) { + $i = 0; + /*$savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0;*/ + + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { $objp = $db->fetch_object($result); $membertype->id = $objp->rowid; @@ -303,32 +319,46 @@ if (!$rowid && $action != 'create' && $action != 'edit') { $membertype->amount = $objp->amount; $membertype->caneditamount = $objp->caneditamount; - print '
'; - print $membertype->getNomUrl(1); - //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' - print ''.dol_escape_htmltag($objp->label).''; - if ($objp->morphy == 'phy') { - print $langs->trans("Physical"); - } elseif ($objp->morphy == 'mor') { - print $langs->trans("Moral"); + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + //output kanban + $membertype->label = $objp->label; + print $membertype->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + print $membertype->getNomUrl(1); + //'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.' + print ''.dol_escape_htmltag($objp->label).''; + if ($objp->morphy == 'phy') { + print $langs->trans("Physical"); + } elseif ($objp->morphy == 'mor') { + print $langs->trans("Moral"); + } else { + print $langs->trans("MorAndPhy"); + } + print ''.yn($objp->subscription).''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''.yn($objp->caneditamount).''.yn($objp->vote).''.$membertype->getLibStatut(5).'rowid.'">'.img_edit().' 
'.yn($objp->subscription).''.(is_null($objp->amount) || $objp->amount === '' ? '' : price($objp->amount)).''.yn($objp->caneditamount).''.yn($objp->vote).''.$membertype->getLibStatut(5).'rowid.'">'.img_edit().' 

'; + + print load_fiche_titre($langs->trans('MiscellaneousOptions'), '', ''); } + print '
'; print ''; print ''; @@ -368,7 +373,7 @@ if (!is_array($result) && $result < 0) { } elseif (count($result) > 0) { $defval = reset($result)->value; } -$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200'); +$formactions->form_select_status_action('agenda', $defval, 1, "AGENDA_EVENT_DEFAULT_STATUS", 0, 1, 'maxwidth200 onrightofpage'); print ''."\n"; // AGENDA_DEFAULT_FILTER_TYPE @@ -395,13 +400,12 @@ print ''."\n"; print ''; -print dol_get_fiche_end(); - print $form->buttonsSaveCancel("Save", ''); print '
'; -print "
"; + +print dol_get_fiche_end(); // End of page llxFooter(); diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 76c717b669d..42967b4f275 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -150,7 +150,6 @@ $linkback = 'trans("Agenda"), -1, 'action'); diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index 96dd7affdba..176816c0f88 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -52,7 +52,7 @@ if ($action == 'setbarcodeproducton') { $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_product_standard' && empty($conf->global->BARCODE_STANDARD_PRODUCT_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_PRODUCT_MASK", '04{0000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodeproductoff') { $res = dolibarr_del_const($db, "BARCODE_PRODUCT_ADDON_NUM", $conf->entity); @@ -62,7 +62,7 @@ if ($action == 'setbarcodethirdpartyon') { $barcodenumberingmodule = GETPOST('value', 'alpha'); $res = dolibarr_set_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); if ($barcodenumberingmodule == 'mod_barcode_thirdparty_standard' && empty($conf->global->BARCODE_STANDARD_THIRDPARTY_MASK)) { - $res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '020{000000000}', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "BARCODE_STANDARD_THIRDPARTY_MASK", '04{0000000000}', 'chaine', 0, '', $conf->entity); } } elseif ($action == 'setbarcodethirdpartyoff') { $res = dolibarr_del_const($db, "BARCODE_THIRDPARTY_ADDON_NUM", $conf->entity); diff --git a/htdocs/admin/bom.php b/htdocs/admin/bom.php index a35aef780d2..57b4b5aad06 100644 --- a/htdocs/admin/bom.php +++ b/htdocs/admin/bom.php @@ -51,10 +51,10 @@ $type = 'bom'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstbom = GETPOST('maskconstBom', 'alpha'); + $maskconstbom = GETPOST('maskconstBom', 'aZ09'); $maskbom = GETPOST('maskBom', 'alpha'); - if ($maskconstbom) { + if ($maskconstbom && preg_match('/_MASK$/', $maskconstbom)) { $res = dolibarr_set_const($db, $maskconstbom, $maskbom, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/chequereceipts.php b/htdocs/admin/chequereceipts.php index cf93155b814..77994debadb 100644 --- a/htdocs/admin/chequereceipts.php +++ b/htdocs/admin/chequereceipts.php @@ -54,9 +54,9 @@ if (empty($conf->global->CHEQUERECEIPTS_ADDON)) { */ if ($action == 'updateMask') { - $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'alpha'); + $maskconstchequereceipts = GETPOST('maskconstchequereceipts', 'aZ09'); $maskchequereceipts = GETPOST('maskchequereceipts', 'alpha'); - if ($maskconstchequereceipts) { + if ($maskconstchequereceipts && preg_match('/_MASK$/', $maskconstchequereceipts)) { $res = dolibarr_set_const($db, $maskconstchequereceipts, $maskchequereceipts, 'chaine', 0, '', $conf->entity); } @@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir) { print ''; print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->CHEQUERECEIPTS_ADDON.'.php' == $file) { // If module is the one used, we show existing errors + if (getDolGlobalString('CHEQUERECEIPTS_ADDON').'.php' == $file) { // If module is the one used, we show existing errors if (!empty($module->error)) { dol_htmloutput_mesg($module->error, '', 'error', 1); } diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 34a5e281fac..b366ea928ef 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -61,10 +61,10 @@ $type = 'order'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); } @@ -117,7 +117,7 @@ if ($action == 'updateMask') { } elseif ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) { - if ($conf->global->COMMANDE_ADDON_PDF == "$value") { + if (getDolGlobalString('COMMANDE_ADDON_PDF') == $value) { dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity); } } @@ -461,7 +461,7 @@ foreach ($dirmodels as $reldir) { // Default print ''; - if ($conf->global->COMMANDE_ADDON_PDF == $name) { + if (getDolGlobalString('COMMANDE_ADDON_PDF') == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir).'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index d6760ef45e8..7b2708e1906 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -195,7 +195,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_PROFID6", GETPOST("MAIN_INFO_PROFID6", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_TVAINTRA", GETPOST("tva", 'alphanohtml'), 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("object", 'alphanohtml'), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_INFO_SOCIETE_OBJECT", GETPOST("socialobject", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START", GETPOST("SOCIETE_FISCAL_MONTH_START", 'int'), 'chaine', 0, '', $conf->entity); @@ -676,8 +676,8 @@ print ''; -print ''; +print ''; +print ''; print ''; print ''; diff --git a/htdocs/admin/company_socialnetworks.php b/htdocs/admin/company_socialnetworks.php index e9171431187..fb496c1dce1 100644 --- a/htdocs/admin/company_socialnetworks.php +++ b/htdocs/admin/company_socialnetworks.php @@ -84,6 +84,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))) { * View */ +$form = new Form($db); + $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; llxHeader('', $langs->trans("Setup"), $wikihelp); diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 48247bf0b8e..c5a4d1a3463 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error=0; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstcontract', 'alpha'); + $maskconst = GETPOST('maskconstcontract', 'aZ09'); $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 59c826413aa..55259ecfff3 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -325,7 +325,7 @@ if (empty($conf->global->MAIN_DISABLE_METEO) || $conf->global->MAIN_DISABLE_METE if (!empty($conf->global->MAIN_METEO_LEVEL0)) { $level0 = $conf->global->MAIN_METEO_LEVEL0; } - $level1 = $offset + 1 * $cursor; + $level1 = $offset + $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) { $level1 = $conf->global->MAIN_METEO_LEVEL1; } @@ -459,7 +459,7 @@ if ($action == 'edit') { print ''; } else { print '

'; } diff --git a/htdocs/admin/delivery.php b/htdocs/admin/delivery.php index a1fef4091ce..9094762f68d 100644 --- a/htdocs/admin/delivery.php +++ b/htdocs/admin/delivery.php @@ -90,9 +90,9 @@ if ($action == 'activate_delivery') { } if ($action == 'updateMask') { - $maskconstdelivery = GETPOST('maskconstdelivery', 'alpha'); + $maskconstdelivery = GETPOST('maskconstdelivery', 'aZ09'); $maskdelivery = GETPOST('maskdelivery', 'alpha'); - if ($maskconstdelivery) { + if ($maskconstdelivery && preg_match('/_MASK$/', $maskconstdelivery)) { $res = dolibarr_set_const($db, $maskconstdelivery, $maskdelivery, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index d928931c9ab..8b63c5842ba 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1944,7 +1944,7 @@ if ($id > 0) { //var_dump($fieldlist); $class = ''; $showfield = 1; - $valuetoshow = empty($obj->{$value}) ? '' : $obj->{$value}; + $valuetoshow = empty($obj->$value) ? '' : $obj->$value; $titletoshow = ''; if ($value == 'entity') { @@ -1985,76 +1985,76 @@ if ($id > 0) { } elseif ($value == 'libelle_facture') { $langs->load("bills"); $key = $langs->trans("PaymentCondition".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = nl2br($valuetoshow); } elseif ($value == 'label' && $tabname[$id] == 'c_country') { $key = $langs->trans("Country".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_availability') { $langs->load("propal"); $key = $langs->trans("AvailabilityType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "AvailabilityType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_actioncomm') { $key = $langs->trans("Action".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Action".strtoupper($obj->code) ? $key : $obj->$value); } elseif (!empty($obj->code_iso) && $value == 'label' && $tabname[$id] == 'c_currencies') { $key = $langs->trans("Currency".strtoupper($obj->code_iso)); - $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code_iso && $key != "Currency".strtoupper($obj->code_iso) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_typent') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_prospectlevel') { $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_civility') { $key = $langs->trans("Civility".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "Civility".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_type_contact') { $langs->load('agenda'); $key = $langs->trans("TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "TypeContact_".$obj->element."_".$obj->source."_".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') { $langs->load("bills"); $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') { $langs->load("bills"); $key = $langs->trans("PaymentType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "PaymentType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'type' && $tabname[$id] == 'c_paiement') { $payment_type_list = array(0=>$langs->trans('PaymentTypeCustomer'), 1=>$langs->trans('PaymentTypeSupplier'), 2=>$langs->trans('PaymentTypeBoth')); $valuetoshow = $payment_type_list[$valuetoshow]; } elseif ($value == 'label' && $tabname[$id] == 'c_input_reason') { $key = $langs->trans("DemandReasonType".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "DemandReasonType".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_input_method') { $langs->load("orders"); $key = $langs->trans($obj->code); - $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->{$value}; + $valuetoshow = ($obj->code && $key != $obj->code) ? $key : $obj->$value; } elseif ($value == 'libelle' && $tabname[$id] == 'c_shipment_mode') { $langs->load("sendings"); $key = $langs->trans("SendingMethod".strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != "SendingMethod".strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'libelle' && $tabname[$id] == 'c_paper_format') { $key = $langs->trans('PaperFormat'.strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'PaperFormat'.strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'label' && $tabname[$id] == 'c_type_fees') { $langs->load('trips'); $key = $langs->trans(strtoupper($obj->code)); - $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != strtoupper($obj->code) ? $key : $obj->$value); } elseif ($value == 'region_id' || $value == 'country_id') { $showfield = 0; } elseif ($value == 'unicode') { $valuetoshow = $langs->getCurrencySymbol($obj->code, 1); } elseif ($value == 'label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif ($value == 'short_label' && $tabname[GETPOST("id", 'int')] == 'c_units') { $langs->load("products"); - $valuetoshow = $langs->trans($obj->{$value}); + $valuetoshow = $langs->trans($obj->$value); } elseif (($value == 'unit') && ($tabname[$id] == 'c_paper_format')) { $key = $langs->trans('SizeUnit'.strtolower($obj->unit)); - $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->{$value}); + $valuetoshow = ($obj->code && $key != 'SizeUnit'.strtolower($obj->unit) ? $key : $obj->$value); } elseif ($value == 'localtax1' || $value == 'localtax2') { $class = "center"; } elseif ($value == 'localtax1_type') { @@ -2357,7 +2357,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') foreach ($fieldlist as $field => $value) { if ($value == 'entity') { - $withentity = $obj->{$value}; + $withentity = $obj->$value; continue; } @@ -2510,11 +2510,11 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif ($value == 'block_if_negative') { print ''; - print $form->selectyesno("block_if_negative", (!empty($obj->{$value}) ? $obj->{$value}:''), 1); + print $form->selectyesno("block_if_negative", (empty($obj->block_if_negative) ? '' : $obj->block_if_negative), 1); print ''; } elseif ($value == 'type_duration') { print ''; - print $form->selectTypeDuration('', $obj->{$value}, array('i','h')); + print $form->selectTypeDuration('', (empty($obj->type_duration) ? '' : $obj->type_duration), array('i','h')); print ''; } else { $fieldValue = isset($obj->{$value}) ? $obj->{$value}: ''; diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 3e0c2378742..4b5ccbb133e 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); +$action = GETPOST('action', 'aZ09'); + if (!$user->admin) { accessforbidden(); } @@ -41,6 +43,7 @@ if (!$user->admin) { */ // set +$reg = array(); if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { @@ -67,6 +70,8 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { * View */ +$form = new Form($db); + $help_url = ''; llxHeader('', $langs->trans("ECMSetup"), $help_url); @@ -81,26 +86,21 @@ print dol_get_fiche_head($head, 'ecm', '', -1, ''); print ''; print ''; print ''; -print ''; -print ''."\n"; +print ''."\n"; print ''; -$form = new Form($db); - // Mail required for members print ''; print ''; -print ''; - -print ''; diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 8dfafb19b63..034997b1716 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -387,7 +387,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref = '
'; $morehtmlref .= '
'; - $morehtml = $langs->trans("NbOfEmailsInInbox").' : '; + $morehtml = ''; $sourcedir = $object->source_directory; $targetdir = ($object->target_directory ? $object->target_directory : ''); // Can be '[Gmail]/Trash' or 'mytag' @@ -404,6 +404,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $connectstringserver = $object->getConnectStringIMAP($usessl); if ($action == 'scan') { + $nbemail = ''; if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if ($object->acces_type == 1) { // Mode OAUth2 with PHP-IMAP @@ -493,7 +494,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $f = $client->getFolders(false, $object->source_directory); $nbemail = $f[0]->examine()["exists"]; - $morehtml .= $nbemail; } else { try { if ($sourcedir) { @@ -525,15 +525,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!$connection) { - $morehtml .= 'Failed to open IMAP connection '.$connectstringsource; + $nbemail .= 'Failed to open IMAP connection '.$connectstringsource; if (function_exists('imap_last_error')) { - $morehtml .= '
'.imap_last_error(); + $nbemail .= '
'.imap_last_error(); } dol_syslog("Error ".$morehtml, LOG_WARNING); //var_dump(imap_errors()) } else { dol_syslog("Imap connected. Now we call imap_num_msg()"); - $morehtml .= imap_num_msg($connection); + $nbemail .= imap_num_msg($connection); } if ($connection) { @@ -541,12 +541,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea imap_close($connection); } } - } else { - $morehtml .= ''.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").''; } - $morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver); + $morehtml .= $form->textwithpicto($langs->trans("NbOfEmailsInInbox"), 'connect string '.$connectstringserver).': '; + + $morehtml .= ($nbemail != '' ? $nbemail : '?'); + + $morehtml .= '   '.img_picto('', 'refresh', 'class="paddingrightonly"').$langs->trans("Refresh").''; } else { + $morehtml .= $langs->trans("NbOfEmailsInInbox").': '; $morehtml .= 'IMAP functions not available on your PHP. '; } @@ -668,6 +671,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $arrayoftypes = array( 'loadthirdparty' => $langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty' => $langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), + 'loadandcreatecontact' => $langs->trans('LoadContactFromEmailOrCreate', $langs->transnoentities("Email")), 'recordjoinpiece' => 'AttachJoinedDocumentsToObject', 'recordevent' => 'RecordEvent' ); diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 3be38cca113..fb09143412f 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -601,13 +601,17 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; if ($key == 'status') { print $object->getLibStatut(5); + } elseif ($key == 'lastresult') { + print '
'; + print $object->showOutputField($val, $key, $object->$key, ''); + print '
'; } elseif ($key == 'rowid') { print $object->showOutputField($val, $key, $object->id, ''); } else { diff --git a/htdocs/admin/eventorganization.php b/htdocs/admin/eventorganization.php index cc9b8d7bca8..0d10602b1c4 100644 --- a/htdocs/admin/eventorganization.php +++ b/htdocs/admin/eventorganization.php @@ -83,15 +83,13 @@ if ($cancel) { $action =''; } -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 485ce901e5c..1db6a9cc9d6 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -62,9 +62,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstexpedition', 'alpha'); + $maskconst = GETPOST('maskconstexpedition', 'aZ09'); $maskvalue = GETPOST('maskexpedition', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/expensereport.php b/htdocs/admin/expensereport.php index 8c20b493105..25bef9fde22 100644 --- a/htdocs/admin/expensereport.php +++ b/htdocs/admin/expensereport.php @@ -58,9 +58,9 @@ $type = 'expensereport'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index bbeb25371b9..a364b17cc4b 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -58,24 +58,24 @@ $type = 'invoice'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstreplacement = GETPOST('maskconstreplacement', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK_/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstreplacement) { + if ($maskconstreplacement && preg_match('/_MASK_/', $maskconstreplacement)) { $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK_/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK_/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index b6ce3d8b9a5..5a5c2f25c0e 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -165,14 +165,14 @@ if (empty($conf->use_javascript_ajax)) { $constante = 'FCKEDITOR_ENABLE_'.$const; print ''."\n"; print '
'; - print ''; + print ''; print ''; - print ''; print ''; print ''; - print ''; print ''; print ''; @@ -306,7 +355,7 @@ if (count($listinsetup) > 0) { if ($keyforsupportedoauth2array == 'OAUTH_OTHER_NAME') { print ''; print ''; - print ''; print ''; print ''; diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index f798995d525..9a0532880cd 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -213,7 +213,13 @@ if ($mode == 'setup' && $user->admin) { $urltocheckperms = ''; } - $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + if ($urltorenew) { + $urltorenew .= '&keyforprovider='.urlencode($keyforprovider); + } + if ($urltodelete) { + $urltodelete .= '&keyforprovider='.urlencode($keyforprovider); + } + // Show value of token $tokenobj = null; diff --git a/htdocs/admin/payment.php b/htdocs/admin/payment.php index 59da712b266..7b0d0acbf06 100644 --- a/htdocs/admin/payment.php +++ b/htdocs/admin/payment.php @@ -51,9 +51,9 @@ if (empty($conf->global->PAYMENT_ADDON)) { */ if ($action == 'updateMask') { - $maskconstpayment = GETPOST('maskconstpayment', 'alpha'); + $maskconstpayment = GETPOST('maskconstpayment', 'aZ09'); $maskpayment = GETPOST('maskpayment', 'alpha'); - if ($maskconstpayment) { + if ($maskconstpayment && preg_match('/_MASK$/', $maskconstpayment)) { $res = dolibarr_set_const($db, $maskconstpayment, $maskpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index ef20ab6e205..42c766d1a22 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -227,7 +227,7 @@ if ($result) { // Tick if ($obj->bydefault == 1) { print '\n\n"; $found++; -//if (!empty($conf->expedition->enabled)) +//if (isModEnabled('expedition')) //{ print ''; diff --git a/htdocs/admin/stocktransfer.php b/htdocs/admin/stocktransfer.php index 3bcd00c1fe8..02c73bb2a76 100644 --- a/htdocs/admin/stocktransfer.php +++ b/htdocs/admin/stocktransfer.php @@ -64,10 +64,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconststocktransfer = GETPOST('maskconststocktransfer', 'alpha'); + $maskconststocktransfer = GETPOST('maskconststocktransfer', 'aZ09'); $maskstocktransfer = GETPOST('maskStockTransfer', 'alpha'); - if ($maskconststocktransfer) { + if ($maskconststocktransfer && preg_match('/_MASK$/', $maskconststocktransfer)) { $res = dolibarr_set_const($db, $maskconststocktransfer, $maskstocktransfer, 'chaine', 0, '', $conf->entity); if ($res <= 0) $error++; } diff --git a/htdocs/admin/supplier_invoice.php b/htdocs/admin/supplier_invoice.php index 3524111c96e..bbb97e293fe 100644 --- a/htdocs/admin/supplier_invoice.php +++ b/htdocs/admin/supplier_invoice.php @@ -38,10 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "orders")); -if (!$user->admin) { - accessforbidden(); -} - $type = GETPOST('type', 'alpha'); $value = GETPOST('value', 'alpha'); $action = GETPOST('action', 'aZ09'); @@ -52,26 +48,34 @@ $scandir = GETPOST('scan_dir', 'alpha'); $specimenthirdparty = new Societe($db); $specimenthirdparty->initAsSpecimen(); +$error = 0; + +if (!$user->admin) { + accessforbidden(); +} + /* * Actions */ +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + if ($action == 'updateMask') { - $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); - $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); - $maskconstdeposit = GETPOST('maskconstdeposit', 'alpha'); + $maskconstinvoice = GETPOST('maskconstinvoice', 'aZ09'); + $maskconstcredit = GETPOST('maskconstcredit', 'aZ09'); + $maskconstdeposit = GETPOST('maskconstdeposit', 'aZ09'); $maskinvoice = GETPOST('maskinvoice', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) { + if ($maskconstinvoice && preg_match('/_MASK$/', $maskconstinvoice)) { $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); } - if ($maskconstcredit) { + if ($maskconstcredit && preg_match('/_MASK$/', $maskconstcredit)) { $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); } - if ($maskconstdeposit) { + if ($maskconstdeposit && preg_match('/_MASK$/', $maskconstdeposit)) { $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index bb1b94d4385..abee8200cef 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -61,10 +61,10 @@ $specimenthirdparty->initAsSpecimen(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconstorder = GETPOST('maskconstorder', 'aZ09'); $maskvalue = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { + if ($maskconstorder && preg_match('/_MASK$/', $maskconstorder)) { $res = dolibarr_set_const($db, $maskconstorder, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_payment.php b/htdocs/admin/supplier_payment.php index 86fcccfb8f2..ac00e4846ac 100644 --- a/htdocs/admin/supplier_payment.php +++ b/htdocs/admin/supplier_payment.php @@ -52,9 +52,9 @@ $type = 'supplier_payment'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'alpha'); + $maskconstsupplierpayment = GETPOST('maskconstsupplierpayment', 'aZ09'); $masksupplierpayment = GETPOST('masksupplierpayment', 'alpha'); - if ($maskconstsupplierpayment) { + if ($maskconstsupplierpayment && preg_match('/_MASK$/', $maskconstsupplierpayment)) { $res = dolibarr_set_const($db, $maskconstsupplierpayment, $masksupplierpayment, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 993e19fc796..62be111449d 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -55,9 +55,9 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'alpha'); + $maskconstsupplier_proposal = GETPOST('maskconstsupplier_proposal', 'aZ09'); $masksupplier_proposal = GETPOST('masksupplier_proposal', 'alpha'); - if ($maskconstsupplier_proposal) { + if ($maskconstsupplier_proposal && preg_match('/_MASK$/', $maskconstsupplier_proposal)) { $res = dolibarr_set_const($db, $maskconstsupplier_proposal, $masksupplier_proposal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index 71f7fd7f875..cf07dd49539 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -115,9 +115,6 @@ if ($action == 'set') { // Check configuration foreach ($activeModules as $modulename) { - /** - * @var LogHandler - */ $module = new $modulename; $error = $module->checkConfiguration(); } diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 8cd1ad3d597..fd983a10924 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -113,7 +113,8 @@ if (!count($listofvars) && !count($listofstatus)) { if ($key != $param) { continue; } - $val2 = ${$val['var']}; + $tmpvar = $val['var']; + $val2 = ${$tmpvar}; $text = 'Should be in line with value of param '.$val['var'].' thas is '.($val2 ? $val2 : "'' (=".$val['valifempty'].")").''; $show = 1; } diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 4a55c1a1160..afe5d4d3520 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -264,7 +264,7 @@ $daylight = round($c - $b); $val = ($a >= 0 ? '+' : '').$a; $val .= ' ('.($a == 'unknown' ? 'unknown' : ($a >= 0 ? '+' : '').($a * 3600)).')'; $val .= '       '.getServerTimeZoneString(); -$val .= '       '.$langs->trans("DaylingSavingTime").': '.($daylight === 'unknown' ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); +$val .= '       '.$langs->trans("DaylingSavingTime").': '.(is_null($daylight) ? 'unknown' : ($a == $c ?yn($daylight) : yn(0).($daylight ? '     ('.$langs->trans('YesInSummer').')' : ''))); print $form->textwithtooltip($val, $txt, 2, 1, img_info('')); print ''."\n"; // value defined in http://fr3.php.net/manual/en/timezones.europe.php print ''."\n"; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 7d8233cdc0a..36904cba63d 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -100,11 +100,11 @@ if (empty($xmlremote)) { } if ($xmlremote && !preg_match('/^https?:\/\//', $xmlremote)) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), '', 'errors'); + setEventMessages($langs->trans("ErrorURLMustStartWithHttp", $xmlremote), null, 'errors'); $error++; } elseif ($xmlremote && !preg_match('/\.xml$/', $xmlremote)) { $langs->load("errors"); - setEventMessages($langs->trans("ErrorURLMustEndWith", $xmlremote, '.xml'), '', 'errors'); + setEventMessages($langs->trans("ErrorURLMustEndWith", $xmlremote, '.xml'), null, 'errors'); $error++; } diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index c2ad387d955..6ea79cf00eb 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -241,7 +241,7 @@ if ($arrayfields['version']['checked']) { } if ($arrayfields['id']['checked']) { print ''; } if ($arrayfields['permission']['checked']) { diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index 6d7ef8f1863..cc9ab7658db 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -50,8 +50,13 @@ llxHeader(); print load_fiche_titre($langs->trans("PerfDolibarr"), '', 'title_setup'); -print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
'; - +print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').''; +print '     '; +print ''; +print img_picto($langs->trans("Reload"), 'refresh').' '; +print $langs->trans("Reload"); +print ''; +print '
'; print '
'; print '
'; @@ -198,7 +203,7 @@ jQuery(document).ready(function() { compphpstring=getphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compphpstring);*/ - if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1)) + if (compphpstring == null || (compphpstring.indexOf("gzip") == -1 && compphpstring.indexOf("deflate") == -1 && compphpstring.indexOf("br") == -1)) { jQuery("#httpcompphpok").hide(); jQuery("#httpcompphpko").show(); @@ -238,7 +243,7 @@ jQuery(document).ready(function() { compcssstring=getcssurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getcssurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compcssstring);*/ - if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1)) + if (compcssstring == null || (compcssstring.indexOf("gzip") == -1 && compcssstring.indexOf("deflate") == -1 && compcssstring.indexOf("br") == -1)) { jQuery("#httpcompcssok").hide(); jQuery("#httpcompcssko").show(); @@ -278,7 +283,7 @@ jQuery(document).ready(function() { compcssphpstring=getcssphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getcssphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compcssphpstring);*/ - if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1)) + if (compcssphpstring == null || (compcssphpstring.indexOf("gzip") == -1 && compcssphpstring.indexOf("deflate") == -1 && compcssphpstring.indexOf("br") == -1)) { jQuery("#httpcompcssphpok").hide(); jQuery("#httpcompcssphpko").show(); @@ -318,7 +323,7 @@ jQuery(document).ready(function() { compimgstring=getimgurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getimgurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compimgstring);*/ - if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1)) + if (compimgstring == null || (compimgstring.indexOf("gzip") == -1 && compimgstring.indexOf("deflate") == -1 && compimgstring.indexOf("br") == -1)) { jQuery("#httpcompimgok").hide(); jQuery("#httpcompimgko").show(); @@ -358,7 +363,7 @@ jQuery(document).ready(function() { compjsstring=getjsurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'js:\'+getjsurl.getAllResponseHeaders()); */ /*alert(\'js:\'+compjsstring);*/ - if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1)) + if (compjsstring == null || (compjsstring.indexOf("gzip") == -1 && compjsstring.indexOf("deflate") == -1 && compjsstring.indexOf("br") == -1)) { jQuery("#httpcompjsok").hide(); jQuery("#httpcompjsko").show(); @@ -398,7 +403,7 @@ jQuery(document).ready(function() { compjsphpstring=getjsphpurl.getResponseHeader(\'Content-Encoding\'); /* alert(\'php:\'+getjsphpurl.getAllResponseHeaders()); */ /*alert(\'php:\'+compjsphpstring);*/ - if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1)) + if (compjsphpstring == null || (compjsphpstring.indexOf("gzip") == -1 && compjsphpstring.indexOf("deflate") == -1 && compjsphpstring.indexOf("br") == -1)) { jQuery("#httpcompjsphpok").hide(); jQuery("#httpcompjsphpko").show(); diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index f8f47baebf9..a8a6f345781 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -41,7 +41,7 @@ if (GETPOST('action', 'aZ09') == 'donothing') { exit; } -$execmethod = empty($conf->global->MAIN_EXEC_USE_POPEN) ? 1 : $conf->global->MAIN_EXEC_USE_POPEN; +$execmethod = getDolGlobalInt('MAIN_EXEC_USE_POPEN', 1); /* @@ -52,7 +52,13 @@ llxHeader(); print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); -print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').' ('.$langs->trans("Reload").')
'; +print ''.$langs->trans("YouMayFindSecurityAdviceHere", 'hhttps://wiki.dolibarr.org/index.php/Security_information').''; +print '     '; +print ''; +print img_picto($langs->trans("Reload"), 'refresh').' '; +print $langs->trans("Reload"); +print ''; +print '
'; print '
'; print load_fiche_titre($langs->trans("PHPSetup"), '', 'folder'); @@ -487,7 +493,7 @@ if (empty($conf->api->enabled) && empty($conf->webservices->enabled)) { print '
'; } if (!empty($conf->api->enabled)) { - print 'API_ENDPOINT_RULES = '.(empty($conf->global->API_ENDPOINT_RULES) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)' : $conf->global->API_ENDPOINT_RULES)."
\n"; + print 'API_ENDPOINT_RULES = '.getDolGlobalString('API_ENDPOINT_RULES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Example").': login:0,users:0,setup:1,status:1,tickets:1,...)')."
\n"; print '
'; } } @@ -501,19 +507,19 @@ print '
'; print load_fiche_titre($langs->trans("OtherSetup"), '', 'folder'); -print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).'   ('.$langs->trans("Recommended").': 0)
'; +print 'MAIN_ALLOW_SVG_FILES_AS_IMAGES = '.getDolGlobalString('MAIN_ALLOW_SVG_FILES_AS_IMAGES', '0').'   ('.$langs->trans("Recommended").': 0)
'; print '
'; -print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).'   ('.$langs->trans("Recommended").': 1)
'; +print 'MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE = '.getDolGlobalString('MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': 1)
'; print '
'; //print ''.$langs->trans("PasswordEncryption").': '; -print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_HASH_ALGO)."   "; +print 'MAIN_SECURITY_HASH_ALGO = '.getDolGlobalString('MAIN_SECURITY_HASH_ALGO', ''.$langs->trans("Undefined").'')."   "; if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { print '     If unset: \'md5\''; } if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') { - print '
MAIN_SECURITY_SALT = '.(empty($conf->global->MAIN_SECURITY_SALT) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_SALT).'
'; + print '
MAIN_SECURITY_SALT = '.getDolGlobalString('MAIN_SECURITY_SALT', ''.$langs->trans("Undefined").'').'
'; } else { print '('.$langs->trans("Recommended").': password_hash)'; print '
'; @@ -528,10 +534,10 @@ if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') { } print '
'; -print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."
"; +print 'MAIN_SECURITY_ANTI_SSRF_SERVER_IP = '.getDolGlobalString('MAIN_SECURITY_ANTI_SSRF_SERVER_IP', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)')."
"; print '
'; -print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.(empty($conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_CSRF_WITH_TOKEN).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; +print 'MAIN_SECURITY_CSRF_WITH_TOKEN = '.getDolGlobalString('MAIN_SECURITY_CSRF_WITH_TOKEN', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 2)'."
"; print '
'; print '
'; @@ -559,31 +565,32 @@ if ($execmethod == 2) { print '
'; print '
'; -print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."
"; +print 'MAIN_RESTRICTHTML_ONLY_VALID_HTML = '.getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; print '
'; -print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."
"; +print 'MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES = '.getDolGlobalString('MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': 1)')."
"; print '
'; -print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)."
"; +print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.getDolGlobalString('MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL', ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)')."
"; print '
'; -print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; +print 'MAIN_SECURITY_FORCECSP = '.getDolGlobalString('MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; print '
'; -print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; +print 'MAIN_SECURITY_FORCERP = '.getDolGlobalString('MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP', ''.$langs->trans("Undefined").''); +print '   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCERP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCERP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCESTS) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCESTS).'   ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCESTS = '.getDolGlobalString('>WEBSITE_MAIN_SECURITY_FORCESTS', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"max-age=31536000; includeSubDomains\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCEPP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCEPP).'   ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCEPP = '.getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCEPP', ''.$langs->trans("Undefined").'').'   ('.$langs->trans("Example").": \"camera: 'none'; microphone: 'none';\")
"; print '
'; print '
'; @@ -598,16 +605,13 @@ print ''; print '
'; $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/fail2ban/filter.d/'; print '- Login process (see fail2ban example on GitHub)
'; -print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see fail2ban example on GitHub)
'; +print '- '.DOL_URL_ROOT.'/passwordforgotten.php (see fail2ban example on GitHub)
'; print '- '.DOL_URL_ROOT.'/public/* (see fail2ban example on GitHub)
'; print '
'; $urlexamplebase = 'https://github.com/Dolibarr/dolibarr/blob/develop/dev/setup/apache/'; print '- You can also protect the application using a HTTP Basic authentication layer (see apache2 virtualhost example on GitHub)
'; - - - // End of page llxFooter(); $db->close(); diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 9cebbc3b36d..6a6201642ee 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -47,7 +47,7 @@ $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; $error = 0; - +$reg = array(); /* * Actions @@ -56,10 +56,10 @@ $error = 0; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstticket = GETPOST('maskconstticket', 'alpha'); + $maskconstticket = GETPOST('maskconstticket', 'aZ09'); $maskticket = GETPOST('maskticket', 'alpha'); - if ($maskconstticket) { + if ($maskconstticket && preg_match('/_MASK$/', $maskconstticket)) { $res = dolibarr_set_const($db, $maskconstticket, $maskticket, 'chaine', 0, '', $conf->entity); } @@ -484,7 +484,7 @@ foreach ($dirmodels as $reldir) { // Preview print ''; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print ''; print '"; print ''; print ''; } diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 3c348d71a12..d8fb57b49f5 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -84,7 +84,7 @@ $tablib[1] = "Websites"; // Requests to extract data $tabsql = array(); -$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')'; +$tabsql[1] = "SELECT f.rowid as rowid, f.entity, f.ref, f.description, f.virtualhost, f.position, f.status, f.date_creation, f.lastaccess, f.pageviews_previous_month, f.pageviews_total FROM ".MAIN_DB_PREFIX.'website as f WHERE f.entity IN ('.getEntity('website').')'; // Criteria to sort dictionaries $tabsqlsort = array(); @@ -92,7 +92,7 @@ $tabsqlsort[1] = "ref ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[1] = "ref,description,virtualhost,position,date_creation"; +$tabfield[1] = "ref,description,virtualhost,position,date_creation,lastaccess,pageviews_previous_month,pageviews_total"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue = array(); @@ -186,7 +186,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $sql .= $tabrowid[$id].","; } $sql .= $tabfieldinsert[$id]; - $sql .= ",status)"; + $sql .= ", status, date_creation)"; $sql .= " VALUES("; // List of values @@ -211,7 +211,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { } $i++; } - $sql .= ",1)"; + $sql .= ", 1, '".$db->idate(dol_now())."')"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); @@ -441,12 +441,10 @@ if ($id) { // Form to add a new line if ($tabname[$id]) { - $fieldlist = explode(',', $tabfield[$id]); - // Line for title print ''; foreach ($fieldlist as $field => $value) { - if ($fieldlist[$field] == 'date_creation') { + if (in_array($fieldlist[$field], array('date_creation', 'lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) { continue; } @@ -522,6 +520,7 @@ if ($id) { print ''; print ''; + print '
'; print '
'.$langs->trans("Description").' '.$langs->trans("Value").''.$langs->trans("Value").'
'.$langs->trans("ECMAutoTree").' '; +print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('ECM_AUTO_TREE_ENABLED'); + print ajax_constantonoff('ECM_AUTO_TREE_HIDEN', null, null, 1); } else { - if (empty($conf->global->ECM_AUTO_TREE_ENABLED)) { - print ''.img_picto($langs->trans("Disabled"), 'off').''; - } elseif (!empty($conf->global->USER_MAIL_REQUIRED)) { - print ''.img_picto($langs->trans("Enabled"), 'on').''; + if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; } } print '
'.img_object("", $picto[$const]).''.img_object("", $picto[$const]).''; print $langs->trans($desc); if ($const == 'DETAILS') { print '
'.$langs->trans("FCKeditorForProductDetails2").''; } print '
'; + print ''; $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index cf637d37329..2e331b3cc80 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -58,9 +58,9 @@ $type = 'ficheinter'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index 9a60c6b9b84..b85e257c69e 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -58,9 +58,9 @@ if (empty($conf->global->HOLIDAY_ADDON)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstholiday', 'alpha'); + $maskconst = GETPOST('maskconstholiday', 'aZ09'); $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 838e9bf9a0b..14d6e8b175f 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -53,7 +53,7 @@ $label = GETPOST('label', 'alpha'); $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php $scandir = GETPOST('scan_dir', 'alpha'); -$type = 'myobject'; +$type = 'evaluation'; $arrayofparameters = array( 'HRM_MAXRANK'=>array('type'=>'integer','enabled'=>1), @@ -70,9 +70,7 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'update') { $max_rank = GETPOST('HRM_MAXRANK', 'int'); @@ -91,11 +89,11 @@ if ($action == 'update') { } } } elseif ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskorder = GETPOST('maskorder', 'alpha'); + $maskconst = GETPOST('maskconstEvaluation', 'aZ09'); + $maskvalue = GETPOST('maskEvaluation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -210,10 +208,10 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "hrm" $moduledir = 'hrm'; $myTmpObjects = array(); -$myTmpObjects['evaluation'] = array('includerefgeneration'=>1, 'includedocgeneration'=>0); +$myTmpObjects['evaluation'] = array('label'=>'Evaluation', 'includerefgeneration'=>1, 'includedocgeneration'=>0); foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { - if ($myTmpObjectKey == 'MyObject') { + if ($myTmpObjectKey != $type) { continue; } if ($myTmpObjectArray['includerefgeneration']) { @@ -222,7 +220,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { */ $setupnotempty++; - print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', ''); + print load_fiche_titre($langs->trans("NumberingModules").' ('.$myTmpObjectArray['label'].')', '', ''); print ''; print ''; @@ -493,16 +491,16 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'integer') { - print '' . "\n"; + print '' . "\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -577,9 +575,9 @@ if ($action == 'edit') { print ''; } diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 95f57d5dfc5..a73b899dd00 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -416,7 +416,7 @@ if ($action != 'create') { print ''; print ''; + print ''; print ''; foreach ($fieldlist as $field => $value) { - if ($value == 'label') { + if ($value == 'module') { + print ''; + } elseif ($value == 'label') { print ''; } elseif ($value == 'lang') { print ''; } elseif ($value == 'fk_user') { print ''; } elseif ($value == 'topic') { print ''; @@ -958,6 +971,9 @@ foreach ($fieldlist as $field => $value) { */ $valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate + if ($fieldlist[$field] == 'module') { + $align = 'tdoverflowmax100'; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -1000,11 +1016,15 @@ foreach ($fieldlist as $field => $value) { $valuetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, '', $forcenowrap); // Tooltip on hover } } - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), $param, "align=".$align, $sortfield, $sortorder); + $sortfieldtouse = ($sortable ? $fieldlist[$field] : ''); + if ($sortfieldtouse == 'type_template') { + $sortfieldtouse.= ',label'; + } + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], $sortfieldtouse, ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, $align.' '); } } -print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, 'align="center"', $sortfield, $sortorder); +print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page ? 'page='.$page.'&' : ''), $param, '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print ''; @@ -1052,7 +1072,7 @@ if ($num) { if ($showfield) { // Show line for topic, joinfiles and content print ''; - print ''; + } elseif ($value == 'fk_user') { print ''; } elseif ($context == 'add' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index e18e65e47a0..1af4b25bb27 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -372,13 +372,13 @@ if ($mode == 'feature') { if (count($objMod->depends)) { $text .= join(',', $objMod->depends); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '
'.$langs->trans("RequiredBy").': '; if (count($objMod->requiredby)) { $text .= join(',', $objMod->requiredby); } else { - $text .= $langs->trans("None"); + $text .= ''.$langs->trans("None").''; } $text .= '

'; @@ -395,7 +395,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -408,7 +408,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -418,7 +418,7 @@ if ($mode == 'feature') { if (dol_is_file($filedata)) { $text .= $langs->trans("Yes").' ('.$moduledir.'/sql/data.sql)'; } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -437,7 +437,7 @@ if ($mode == 'feature') { } } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -446,7 +446,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['models']) && $objMod->module_parts['models']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -455,7 +455,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['substitutions']) && $objMod->module_parts['substitutions']) { $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -468,7 +468,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -498,11 +498,14 @@ if ($mode == 'feature') { if (isset($objMod->boxes) && is_array($objMod->boxes) && count($objMod->boxes)) { $i = 0; foreach ($objMod->boxes as $val) { - $text .= ($i ? ', ' : '').($val['file'] ? $val['file'] : $val[0]); + $boxstring = (empty($val['file']) ? (empty($val[0]) ? '' : $val[0]) : $val['file']); + if ($boxstring) { + $text .= ($i ? ', ' : '').$boxstring; + } $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -531,7 +534,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -544,7 +547,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -553,7 +556,7 @@ if ($mode == 'feature') { if (isset($objMod->menu) && !empty($objMod->menu)) { // objMod can be an array or just an int 1 $text .= $langs->trans("Yes"); } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -566,7 +569,7 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; @@ -579,13 +582,13 @@ if ($mode == 'feature') { $i++; } } else { - $text .= $langs->trans("No"); + $text .= ''.$langs->trans("No").''; } $text .= '
'; $text .= '
'.$langs->trans("AddOtherPagesOrServices").': '; - $text .= $langs->trans("DetectionNotPossible"); + $text .= ''.$langs->trans("DetectionNotPossible").''; } @@ -594,7 +597,7 @@ if ($mode == 'changelog') { if ($changelog) { $text .= '
'.$changelog.'
'; } else { - $text .= '
'.$langs->trans("NotAvailable").'
'; + $text .= '
'.$langs->trans("NotAvailable").'
'; } } diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index bd6a238c0f0..6e0d90499d4 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -65,9 +65,9 @@ $search_version = GETPOST('search_version', 'alpha'); // For dolistore search $options = array(); $options['per_page'] = 20; -$options['categorie'] = ((GETPOST('categorie', 'int') ?GETPOST('categorie', 'int') : 0) + 0); -$options['start'] = ((GETPOST('start', 'int') ?GETPOST('start', 'int') : 0) + 0); -$options['end'] = ((GETPOST('end', 'int') ?GETPOST('end', 'int') : 0) + 0); +$options['categorie'] = ((int) (GETPOST('categorie', 'int') ? GETPOST('categorie', 'int') : 0)); +$options['start'] = ((int) (GETPOST('start', 'int') ?GETPOST('start', 'int') : 0)); +$options['end'] = ((int) (GETPOST('end', 'int') ?GETPOST('end', 'int') : 0)); $options['search'] = GETPOST('search_keyword', 'alpha'); $dolistore = new Dolistore(false); @@ -282,10 +282,39 @@ if ($action == 'set' && $user->admin) { } header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); exit; +} elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') { + $result = unActivateModule($value, 0); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if ($result) { + setEventMessages($result, null, 'errors'); + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); + } + $resarray = activateModule($value, 0, 1); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + if (!empty($resarray['errors'])) { + setEventMessages('', $resarray['errors'], 'errors'); + } else { + if ($resarray['nbperms'] > 0) { + $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1"; + $resqltmp = $db->query($tmpsql); + if ($resqltmp) { + $obj = $db->fetch_object($resqltmp); + if ($obj && $obj->nb > 1) { + $msg = $langs->trans('ModuleEnabledAdminMustCheckRights'); + setEventMessages($msg, null, 'warnings'); + } + } else { + dol_print_error($db); + } + } + } + header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : '')); + exit; } + /* * View */ @@ -464,6 +493,19 @@ if ($action == 'reset_confirm' && $user->admin) { } } +if ($action == 'reload_confirm' && $user->admin) { + if (!empty($modules[$value])) { + $objMod = $modules[$value]; + + if (!empty($objMod->langfiles)) { + $langs->loadLangs($objMod->langfiles); + } + + $form = new Form($db); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmReload'), $langs->trans(GETPOST('confirm_message_code')), 'reload', '', 'no', 1); + } +} + print $formconfirm; asort($orders); @@ -547,6 +589,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= '
'; $moreforfilter .= $form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), $langs->trans('Origin'), 0, 0, '', 0, 0, 0, '', 'maxwidth250', 1); $moreforfilter .= '
'; + if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) { $array_version = array('stable'=>$langs->transnoentitiesnoconv("Stable")); if ($conf->global->MAIN_FEATURES_LEVEL < 0) { @@ -559,11 +602,12 @@ if ($mode == 'common' || $mode == 'commonkanban') { $array_version['development'] = $langs->trans("Development"); } $moreforfilter .= '
'; - $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->trans('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); + $moreforfilter .= $form->selectarray('search_version', $array_version, $search_version, $langs->transnoentitiesnoconv('Version'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; } + $array_status = array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")); $moreforfilter .= '
'; - $moreforfilter .= $form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, $langs->trans('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); + $moreforfilter .= $form->selectarray('search_status', $array_status, $search_status, $langs->transnoentitiesnoconv('Status'), 0, 0, '', 0, 0, 0, '', 'maxwidth150', 1); $moreforfilter .= '
'; $moreforfilter .= ' '; $moreforfilter .= '
'; @@ -641,11 +685,11 @@ if ($mode == 'common' || $mode == 'commonkanban') { // We discard showing according to filters if ($search_keyword) { $qualified = 0; - if (preg_match('/'.preg_quote($search_keyword).'/i', $modulename) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduletechnicalname) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesc) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduledesclong) - || preg_match('/'.preg_quote($search_keyword).'/i', $moduleauthor) + if (preg_match('/'.preg_quote($search_keyword, '/').'/i', $modulename) + || preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduletechnicalname) + || ($moduledesc && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesc)) + || ($moduledesclong && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduledesclong)) + || ($moduleauthor && preg_match('/'.preg_quote($search_keyword, '/').'/i', $moduleauthor)) ) { $qualified = 1; } @@ -734,15 +778,17 @@ if ($mode == 'common' || $mode == 'commonkanban') { // Version (with picto warning or not) $version = $objMod->getVersion(0); $versiontrans = ''; + $warningstring = ''; if (preg_match('/development/i', $version)) { - $versiontrans .= img_warning($langs->trans("Development"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Development"); } if (preg_match('/experimental/i', $version)) { - $versiontrans .= img_warning($langs->trans("Experimental"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Experimental"); } if (preg_match('/deprecated/i', $version)) { - $versiontrans .= img_warning($langs->trans("Deprecated"), '', 'floatleft paddingright'); + $warningstring = $langs->trans("Deprecated"); } + if ($objMod->isCoreOrExternalModule() == 'external' || preg_match('/development|experimental|deprecated/i', $version)) { $versiontrans .= $objMod->getVersion(1); } @@ -800,12 +846,24 @@ if ($mode == 'common' || $mode == 'commonkanban') { } else { if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { $codeenabledisable .= 'warnings_unactivation[$mysoc->country_code]).'&value='.$modName.'&mode='.$mode.$param.'">'; - $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); + $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on'); $codeenabledisable .= ''; + if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) { + $codeenabledisable .= ' '; + $codeenabledisable .= ''; + $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"'); + $codeenabledisable .= ''; + } } else { $codeenabledisable .= ''; - $codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on'); + $codeenabledisable .= img_picto($langs->trans("Activated").($warningstring ? ' '.$warningstring : ''), 'switch_on'); $codeenabledisable .= ''; + if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) { + $codeenabledisable .= ' '; + $codeenabledisable .= ''; + $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="opacitymedium"'); + $codeenabledisable .= ''; + } } } @@ -844,10 +902,10 @@ if ($mode == 'common' || $mode == 'commonkanban') { } } } - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) { + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } else { - $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; + $codetoconfig .= ''.img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15').''; } } else { $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); @@ -907,7 +965,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { // Output Kanban print $objMod->getKanbanView($codeenabledisable, $codetoconfig); } else { - print '
'."\n"; + print ''."\n"; if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { print ''; } @@ -941,7 +999,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print ''; // Version - print '\n"; // Link enable/disable - print '\n"; @@ -1075,7 +1133,7 @@ if ($mode == 'marketplace') {
'; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -588,14 +586,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } diff --git a/htdocs/admin/knowledgemanagement.php b/htdocs/admin/knowledgemanagement.php index b1710a53839..3fc8ebb3724 100644 --- a/htdocs/admin/knowledgemanagement.php +++ b/htdocs/admin/knowledgemanagement.php @@ -69,11 +69,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskorder = GETPOST('maskorder', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -209,14 +209,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type'] == 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, isModEnabled('fckeditor'), ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -275,9 +275,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -286,7 +286,7 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } @@ -304,17 +304,17 @@ if ($action == 'edit') { } print '
    ' . implode(' ', $toprint) . '
'; } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalString($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalString($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'.$langs->trans("Label").'
'.$langs->trans("Email").''; print img_picto('', 'email', 'class="pictofixedwidth"'); - print '
'.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index e462b7854ac..1cb418cb6c9 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -69,6 +69,7 @@ $search_type_template = GETPOST('search_type_template', 'alpha'); $search_lang = GETPOST('search_lang', 'alpha'); $search_fk_user = GETPOST('search_fk_user', 'intcomma'); $search_topic = GETPOST('search_topic', 'alpha'); +$search_module = GETPOST('search_module', 'alpha'); $acts = array(); $actl = array(); @@ -108,7 +109,7 @@ $tabname[25] = MAIN_DB_PREFIX."c_email_templates"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield = array(); -$tabfield[25] = "label,lang,type_template,fk_user,private,position,topic,joinfiles,content"; +$tabfield[25] = "label,lang,type_template,fk_user,private,position,module,topic,joinfiles,content"; if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $tabfield[25] .= ',content_lines'; } @@ -290,6 +291,7 @@ if (empty($reshook)) { $search_lang = ''; $search_fk_user = ''; $search_topic = ''; + $search_module = ''; $toselect = array(); $search_array_options = array(); } @@ -598,6 +600,9 @@ if ($search_lang) { if ($search_fk_user != '' && $search_fk_user != '-1') { $sql .= natural_search('fk_user', $search_fk_user, 2); } +if ($search_module) { + $sql .= natural_search('module', $search_module); +} if ($search_topic) { $sql .= natural_search('topic', $search_topic); } @@ -703,6 +708,9 @@ if ($action == 'create') { $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $align = "left"; + if ($fieldlist[$field] == 'module') { + $valuetoshow = ''; + } if ($fieldlist[$field] == 'fk_user') { $valuetoshow = $langs->trans("Owner"); } @@ -802,9 +810,9 @@ if ($action == 'create') { $fieldsforcontent = array('topic', 'joinfiles', 'content', 'content_lines'); } foreach ($fieldsforcontent as $tmpfieldlist) { - print '
'; + print '
'; - // Label + // Topic of email if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; } @@ -882,6 +890,9 @@ if ($search_type_template != '-1') { if ($search_fk_user > 0) { $param .= '&search_fk_user='.urlencode($search_fk_user); } +if ($search_module) { + $param .= '&search_module='.urlencode($search_module); +} if ($search_topic) { $param .= '&search_topic='.urlencode($search_topic); } @@ -909,7 +920,9 @@ if ($num > $listlimit) { print '
'; @@ -917,7 +930,7 @@ foreach ($fieldlist as $field => $value) { print ''; - print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth125', 1); + print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'maxwidth100', 1); print '
'; + print ''; if ($tmpfieldlist == 'topic') { print ''.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).' '; print ''; @@ -1068,7 +1088,6 @@ if ($num) { if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); print $doleditor->Create(1); } @@ -1130,7 +1149,8 @@ if ($num) { $align = ""; $class = "tddict"; $title = ''; - $valuetoshow = $obj->{$fieldlist[$field]}; + $tmpvar = $fieldlist[$field]; + $valuetoshow = $obj->$tmpvar; if ($value == 'label' || $value == 'topic') { if ($langs->trans($valuetoshow) != $valuetoshow) { $valuetoshow = $langs->trans($valuetoshow); @@ -1268,29 +1288,31 @@ $db->close(); */ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') { - global $conf, $langs, $user, $db; + global $langs, $user, $db; global $form; global $elementList; $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { - if ($value == 'fk_user') { + if ($value == 'module') { + print ''; if ($user->admin) { - print $form->select_dolusers(empty($obj->{$value}) ? '' : $obj->{$value}, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth150 maxwidth200'); + print $form->select_dolusers(empty($obj->$value) ? '' : $obj->$value, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100'); } else { if ($context == 'add') { // I am not admin and we show the add form print $user->getNomUrl(1); // Me $forcedvalue = $user->id; } else { - if ($obj && !empty($obj->{$value}) && $obj->{$value} > 0) { + if ($obj && !empty($obj->$value) && $obj->$value > 0) { $fuser = new User($db); - $fuser->fetch($obj->{$value}); + $fuser->fetch($obj->$value); print $fuser->getNomUrl(1); $forcedvalue = $fuser->id; } else { - $forcedvalue = $obj->{$value}; + $forcedvalue = $obj->$value; } } $keyname = $value; @@ -1304,7 +1326,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') if ($context == 'edit') { $selectedlang = $obj->lang; } - print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth150'); + print $formadmin->select_language($selectedlang, 'langcode', 0, null, 1, 0, 0, 'maxwidth100'); } else { if (!empty($obj->lang)) { print $obj->lang.' - '.$langs->trans('Language_'.$obj->lang); @@ -1324,7 +1346,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; print $obj->type_template; } else { - print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150', 1, '', 0, 1); + print $form->selectarray('type_template', $elementList, (!empty($obj->type_template) ? $obj->type_template:''), 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 maxwidth125', 1, '', 0, 1); } print '
'.$linenum.''; + print ''; if ($objMod->needUpdate) { $versionTitle = $langs->trans('ModuleUpdateAvailable').' : '.$objMod->lastVersion; print ''.$versiontrans.''; @@ -951,7 +1009,7 @@ if ($mode == 'common' || $mode == 'commonkanban') { print "'; + print ''; print $codeenabledisable; print "
- get_products(!empty($categorie) ? $categorie: ''); ?> + get_products(); ?>
@@ -1216,10 +1274,10 @@ if ($mode == 'deploy') { print ''."\n"; diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 36a82e965f4..21fff1c45e6 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.php @@ -52,10 +52,10 @@ $type = 'mrp'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstmrp = GETPOST('maskconstMo', 'alpha'); + $maskconstmrp = GETPOST('maskconstMo', 'aZ09'); $maskmrp = GETPOST('maskMo', 'alpha'); - if ($maskconstmrp) { + if ($maskconstmrp && preg_match('/_MASK$/', $maskconstmrp)) { $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/multicurrency.php b/htdocs/admin/multicurrency.php index 1cf838c08cb..5945ebfb5d5 100644 --- a/htdocs/admin/multicurrency.php +++ b/htdocs/admin/multicurrency.php @@ -134,7 +134,8 @@ if ($action == 'add_currency') { dolibarr_set_const($db, 'MULTICURRENCY_APP_SOURCE', GETPOST('MULTICURRENCY_APP_SOURCE', 'alpha')); //dolibarr_set_const($db, 'MULTICURRENCY_ALTERNATE_SOURCE', GETPOST('MULTICURRENCY_ALTERNATE_SOURCE', 'alpha')); } else { - $result = MultiCurrency::syncRates($conf->global->MULTICURRENCY_APP_ID); + $multiurrency = new MultiCurrency($db); + $result = $multiurrency->syncRates(getDolGlobalString('MULTICURRENCY_APP_ID')); if ($result > 0) { setEventMessages($langs->trans("CurrencyRateSyncSucceed"), null, "mesgs"); } diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php index 64968b1a516..8c082d674db 100644 --- a/htdocs/admin/oauth.php +++ b/htdocs/admin/oauth.php @@ -48,6 +48,8 @@ $action = GETPOST('action', 'aZ09'); $provider = GETPOST('provider', 'aZ09'); $label = GETPOST('label', 'aZ09'); +$servicetoeditname = GETPOST('servicetoeditname', 'aZ09'); + $error = 0; @@ -72,15 +74,24 @@ if ($action == 'update') { foreach ($conf->global as $key => $val) { if (!empty($val) && preg_match('/^OAUTH_.+_ID$/', $key)) { $constvalue = str_replace('_ID', '', $key); - if (!dolibarr_set_const($db, $constvalue.'_ID', GETPOST($constvalue.'_ID'), 'chaine', 0, '', $conf->entity)) { - $error++; + $newconstvalue = $constvalue; + if (GETPOSTISSET($constvalue.'_NAME')) { + $newconstvalue = preg_replace('/-.*$/', '', $constvalue).'-'.GETPOST($constvalue.'_NAME'); + } + + if (GETPOSTISSET($constvalue.'_ID')) { + if (!dolibarr_set_const($db, $newconstvalue.'_ID', GETPOST($constvalue.'_ID'), 'chaine', 0, '', $conf->entity)) { + $error++; + } } // If we reset this provider, we also remove the secret - if (!dolibarr_set_const($db, $constvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) { - $error++; + if (GETPOSTISSET($constvalue.'_SECRET')) { + if (!dolibarr_set_const($db, $newconstvalue.'_SECRET', GETPOST($constvalue.'_ID') ? GETPOST($constvalue.'_SECRET') : '', 'chaine', 0, '', $conf->entity)) { + $error++; + } } if (GETPOSTISSET($constvalue.'_URLAUTHORIZE')) { - if (!dolibarr_set_const($db, $constvalue.'_URLAUTHORIZE', GETPOST($constvalue.'_URLAUTHORIZE'), 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, $newconstvalue.'_URLAUTHORIZE', GETPOST($constvalue.'_URLAUTHORIZE'), 'chaine', 0, '', $conf->entity)) { $error++; } } @@ -90,14 +101,46 @@ if ($action == 'update') { } else { $scopestring = GETPOST($constvalue.'_SCOPE'); } - if (!dolibarr_set_const($db, $constvalue.'_SCOPE', $scopestring, 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, $newconstvalue.'_SCOPE', $scopestring, 'chaine', 0, '', $conf->entity)) { $error++; } - } else { - if (!dolibarr_set_const($db, $constvalue.'_SCOPE', '', 'chaine', 0, '', $conf->entity)) { + } elseif ($newconstvalue !== $constvalue) { + if (!dolibarr_set_const($db, $newconstvalue.'_SCOPE', '', 'chaine', 0, '', $conf->entity)) { $error++; } } + + // If name changed, we have to delete old const and proceed few other changes + if ($constvalue !== $newconstvalue) { + dolibarr_del_const($db, $constvalue.'_ID', $conf->entity); + dolibarr_del_const($db, $constvalue.'_SECRET', $conf->entity); + dolibarr_del_const($db, $constvalue.'_URLAUTHORIZE', $conf->entity); + dolibarr_del_const($db, $constvalue.'_SCOPE', $conf->entity); + + // Update name of token + $oldname = preg_replace('/^OAUTH_/', '', $constvalue); + $oldprovider = ucfirst(strtolower(preg_replace('/-.*$/', '', $oldname))); + $oldlabel = preg_replace('/^.*-/', '', $oldname); + $newlabel = preg_replace('/^.*-/', '', $newconstvalue); + + + $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; + $sql.= " SET service = '".$db->escape($oldprovider."-".$newlabel)."'"; + $sql.= " WHERE service = '".$db->escape($oldprovider."-".$oldlabel)."'"; + + + $resql = $db->query($sql); + if (!$resql) { + $error++; + } + + // Update const where the token was used, might not be exhaustive + if (getDolGlobalString('MAIN_MAIL_SMTPS_OAUTH_SERVICE') == $oldname) { + if (!dolibarr_set_const($db, 'MAIN_MAIL_SMTPS_OAUTH_SERVICE', strtoupper($oldprovider).'-'.$newlabel, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + } } } @@ -270,11 +313,16 @@ if (count($listinsetup) > 0) { } else { print $label; } - if ($keyforprovider) { + if ($servicetoeditname == $key[0]) { + print ' ()'; + } elseif ($keyforprovider) { print ' ('.$keyforprovider.')'; } else { print ' ('.$langs->trans("NoName").')'; } + if (!($servicetoeditname == $key[0])) { + print ''.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + } print '
'; if (!empty($supportedoauth2array[$keyforsupportedoauth2array]['urlforcredentials'])) { @@ -285,7 +333,7 @@ if (count($listinsetup) > 0) { // Delete print ''; $label = preg_replace('/_NAME$/', '', $keyforsupportedoauth2array); - print ''; + print ''; print img_picto('', 'delete'); print ''; @@ -298,7 +346,8 @@ if (count($listinsetup) > 0) { $redirect_uri = $urlwithroot.'/core/modules/oauth/'.$supportedoauth2array[$keyforsupportedoauth2array]['callbackfile'].'_oauthcallback.php'; print '
'.$langs->trans("UseTheFollowingUrlAsRedirectURI").''; + print ''; + print ajax_autoselect('uri'.$keyforsupportedoauth2array.$keyforprovider); print '
'.$langs->trans("URLOfServiceForAuthorization").''; + print ''; print '
'; - print ''; + print ''; //print img_edit_remove(); print img_picto('', 'switch_on'); print ''; diff --git a/htdocs/admin/propal.php b/htdocs/admin/propal.php index 7883cc7da20..10044e33b5b 100644 --- a/htdocs/admin/propal.php +++ b/htdocs/admin/propal.php @@ -58,9 +58,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $error = 0; if ($action == 'updateMask') { - $maskconstpropal = GETPOST('maskconstpropal', 'alpha'); + $maskconstpropal = GETPOST('maskconstpropal', 'aZ09'); $maskpropal = GETPOST('maskpropal', 'alpha'); - if ($maskconstpropal) { + if ($maskconstpropal && preg_match('/_MASK$/', $maskconstpropal)) { $res = dolibarr_set_const($db, $maskconstpropal, $maskpropal, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/reception_setup.php b/htdocs/admin/reception_setup.php index c86db66e464..32f6c5b226e 100644 --- a/htdocs/admin/reception_setup.php +++ b/htdocs/admin/reception_setup.php @@ -65,9 +65,9 @@ if (empty($conf->global->RECEPTION_ADDON_NUMBER)) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconstreception', 'alpha'); + $maskconst = GETPOST('maskconstreception', 'aZ09'); $maskvalue = GETPOST('maskreception', 'alpha'); - if (!empty($maskconst)) { + if (!empty($maskconst) && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 33344363cf7..e30e50769bb 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -56,8 +56,8 @@ if ($action == 'activate_encrypt') { $db->begin(); - // On old version a bug created the constant into user entity, so we delete it to be sure, such entry won't exists. We want it in entity 0 or nowhere. - dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // On old version, a bug created the constant into user entity, so we delete it to be sure such entry won't exists. We want it in entity 0 or nowhere. + dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", $conf->entity); // We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody $entityforall = 0; dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall); diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 1d73f5238ad..7a7e49a3129 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -247,7 +247,7 @@ if (isModEnabled('commande')) { print "
  => '.$langs->trans("CurrentHour").''.dol_print_date(dol_now('gmt'), 'dayhour', 'tzserver').'
'; - print ''; + print ''; print ''; if ($module->type == 'pdf') { - print ''.img_object($langs->trans("Preview"), 'pdf').''; + print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); } @@ -526,7 +526,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, $conf->global->TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND); + print $formcategory->selectarray("TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND", $arrval, getDolGlobalString('TICKET_AUTO_READ_WHEN_CREATED_FROM_BACKEND')); } print ''; @@ -542,7 +542,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + print $formcategory->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, getDolGlobalString('TICKET_AUTO_ASSIGN_USER_CREATE')); } print ''; @@ -557,7 +557,7 @@ if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFY_AT_CLOSING'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, $conf->global->TICKET_NOTIFY_AT_CLOSING); + print $formcategory->selectarray("TICKET_NOTIFY_AT_CLOSING", $arrval, getDolGlobalString('TICKET_NOTIFY_AT_CLOSING')); } print ''; @@ -569,7 +569,7 @@ if (isModEnabled('product')) { $htmlname = "product_category_id"; print '
'.$langs->trans("TicketChooseProductCategory").''; - $formcategory->selectProductCategory($conf->global->TICKET_PRODUCT_CATEGORY, $htmlname); + $formcategory->selectProductCategory(getDolGlobalString('TICKET_PRODUCT_CATEGORY'), $htmlname); if ($conf->use_javascript_ajax) { print ajax_combobox('select_'.$htmlname); } @@ -583,7 +583,7 @@ if (isModEnabled('product')) { print '
'.$langs->trans("TicketsDelayBeforeFirstAnswer")." - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBeforeFirstAnswerHelp"), 1, 'help'); @@ -593,7 +593,7 @@ print '
'.$langs->trans("TicketsDelayBetweenAnswers")." - + '; print $formcategory->textwithpicto('', $langs->trans("TicketsDelayBetweenAnswersHelp"), 1, 'help'); diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index abb5ebfd6ba..fcbc01abef1 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -427,7 +427,7 @@ if ($mode == 'overwrite') { print '   '; print ''; } else { - print ''.img_edit().''; + print ''.img_edit().''; print '   '; print ''.img_delete().''; } diff --git a/htdocs/admin/webhook.php b/htdocs/admin/webhook.php index b589eac4079..91d3358a92d 100644 --- a/htdocs/admin/webhook.php +++ b/htdocs/admin/webhook.php @@ -150,10 +150,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; @@ -293,14 +293,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -382,9 +382,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -393,14 +393,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalString($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -412,25 +412,25 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { setEventMessages(null, $object->errors, "errors"); } } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } print '
'; // Title of lines @@ -533,6 +532,10 @@ if ($id) { $align = "left"; $sortable = 1; $valuetoshow = ''; + if (in_array($fieldlist[$field], array('pageviews_total', 'pageviews_previous_month'))) { + $align = 'right'; + } + /* $tmparray=getLabelOfField($fieldlist[$field]); $showfield=$tmp['showfield']; @@ -554,14 +557,24 @@ if ($id) { if ($fieldlist[$field] == 'date_creation') { $valuetoshow = $langs->trans("DateCreation"); } + if ($fieldlist[$field] == 'lastaccess') { + $valuetoshow = $langs->trans("LastAccess"); + } + if ($fieldlist[$field] == 'pageviews_previous_month') { + $valuetoshow = $langs->trans("PagesViewedPreviousMonth"); + } + if ($fieldlist[$field] == 'pageviews_total') { + $valuetoshow = $langs->trans("PagesViewedTotal"); + } // Affiche nom du champ if ($showfield) { - print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder); + print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, $align.' '); } } - print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", 'align="center"', $sortfield, $sortorder); + // Status + print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "status", ($page ? 'page='.$page.'&' : ''), "", '', $sortfield, $sortorder, 'center '); print getTitleFieldOfList(''); print getTitleFieldOfList(''); print ''; @@ -581,8 +594,9 @@ if ($id) { fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); } - print ''; + print ''; } else { $tmpaction = 'view'; $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); @@ -593,13 +607,16 @@ if ($id) { if (empty($reshook)) { foreach ($fieldlist as $field => $value) { $showfield = 1; - $align = "left"; $fieldname = $fieldlist[$field]; + $align = "left"; + if (in_array($fieldname, array('pageviews_total', 'pageviews_previous_month'))) { + $align = 'right'; + } $valuetoshow = $obj->$fieldname; // Show value for field if ($showfield) { - print ''; + print ''; } } } @@ -612,9 +629,10 @@ if ($id) { $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&'; + // Active print '"; // Modify link @@ -633,6 +651,7 @@ if ($id) { } print '
 '; - print '  '; + print ''; + print ' '.$valuetoshow.''.$valuetoshow.''; - print ''.$actl[($obj->status ? 1 : 0)].''; + print ''.$actl[($obj->status ? 1 : 0)].''; print "
'; + print ''; print ''; } @@ -668,6 +687,10 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); foreach ($fieldlist as $field => $value) { + if (in_array($fieldlist[$field], array('lastaccess', 'pageviews_previous_month', 'pageviews_month', 'pageviews_total'))) { + continue; + } + $fieldname = $fieldlist[$field]; if ($fieldlist[$field] == 'lang') { diff --git a/htdocs/admin/workstation.php b/htdocs/admin/workstation.php index bdd7ba662cd..314e6d13a91 100644 --- a/htdocs/admin/workstation.php +++ b/htdocs/admin/workstation.php @@ -63,11 +63,11 @@ if (!$user->admin) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstWorkstation', 'alpha'); + $maskconst = GETPOST('maskconstWorkstation', 'aZ09'); $maskorder = GETPOST('maskWorkstation', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskorder, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index b9548c7f69e..d618c65836b 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -71,7 +71,7 @@ if ($action == 'setproductionmode') { } // Disable compression mode -if ($action == 'setdisablecomprssion') { +if ($action == 'setdisablecompression') { $status = GETPOST('status', 'alpha'); if (dolibarr_set_const($db, 'API_DISABLE_COMPRESSION', $status, 'chaine', 0, '', 0) > 0) { @@ -118,11 +118,11 @@ print ''; print ''.$langs->trans("ApiProductionMode").''; $production_mode = (empty($conf->global->API_PRODUCTION_MODE) ?false:true); if ($production_mode) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } @@ -133,11 +133,11 @@ print ''; print ''.$langs->trans("API_DISABLE_COMPRESSION").''; $disable_compression = (empty($conf->global->API_DISABLE_COMPRESSION) ?false:true); if ($disable_compression) { - print ''; + print ''; print img_picto($langs->trans("Activated"), 'switch_on'); print ''; } else { - print ''; + print ''; print img_picto($langs->trans("Disabled"), 'switch_off'); print ''; } diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index f885677225e..541682101c6 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2023 Ferran Marcet * * 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 @@ -142,12 +143,38 @@ class DolibarrApiAccess implements iAuthenticate if (!$login) { throw new RestException(503, 'Error when searching login user from api key'); } + + + $genericmessageerroruser = 'Error user not valid (not found or bad status or bad validity dates) (conf->entity='.$conf->entity.')'; + $fuser = new User($this->db); $result = $fuser->fetch('', $login, '', 0, (empty($userentity) ? -1 : $conf->entity)); // If user is not entity 0, we search in working entity $conf->entity (that may have been forced to a different value than user entity) if ($result <= 0) { - throw new RestException(503, 'Error when fetching user :'.$fuser->error.' (conf->entity='.$conf->entity.')'); + throw new RestException(503, $genericmessageerroruser); } + // Check if user status is enabled + if ($fuser->statut != $fuser::STATUS_ENABLED) { + // Status is disabled + dol_syslog("The user has been disabled"); + throw new RestException(503, $genericmessageerroruser); + } + + // Check if session was unvalidated by a password change + if (($fuser->flagdelsessionsbefore && !empty($_SESSION["dol_logindate"]) && $fuser->flagdelsessionsbefore > $_SESSION["dol_logindate"])) { + // Session is no more valid + dol_syslog("The user has a date for session invalidation = ".$fuser->flagdelsessionsbefore." and a session date = ".$_SESSION["dol_logindate"].". We must invalidate its sessions."); + throw new RestException(503, $genericmessageerroruser); + } + + // Check date validity + if ($fuser->isNotIntoValidityDateRange()) { + // User validity dates are no more valid + dol_syslog("The user login has a validity between [".$fuser->datestartvalidity." and ".$fuser->dateendvalidity."], curren date is ".dol_now()); + throw new RestException(503, $genericmessageerroruser); + } + + // User seems valid $fuser->getrights(); // Set the property $user to the $user of API diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index d5362f4ac56..0b8d3e64828 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -121,6 +121,9 @@ class Login include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $login = checkLoginPassEntity($login, $password, $entity, $authmode, 'api'); // Check credentials. + if ($login === '--bad-login-validity--') { + $login = ''; + } if (empty($login)) { throw new RestException(403, 'Access denied'); } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9dcd168f344..17649370ae0 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -319,8 +319,8 @@ class Setup extends DolibarrApi /** * Get state by ID. * - * @param int $id ID of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/{id} * @@ -334,8 +334,8 @@ class Setup extends DolibarrApi /** * Get state by Code. * - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param string $code Code of state + * @return Object Object with cleaned properties * * @url GET dictionary/states/byCode/{code} * @@ -424,10 +424,9 @@ class Setup extends DolibarrApi /** * Get country by ID. * - * @param int $id ID of country - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/{id} * @@ -441,10 +440,9 @@ class Setup extends DolibarrApi /** * Get country by Code. * - * @param string $code Code of country (2 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $code Code of country (2 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byCode/{code} * @@ -458,10 +456,9 @@ class Setup extends DolibarrApi /** * Get country by Iso. * - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @url GET dictionary/countries/byISO/{iso} * @@ -475,9 +472,9 @@ class Setup extends DolibarrApi /** * Get state. * - * @param int $id ID of state - * @param string $code Code of state - * @return array Array of cleaned object properties + * @param int $id ID of state + * @param string $code Code of state + * @return Object Object with cleaned properties * * @throws RestException */ @@ -498,12 +495,11 @@ class Setup extends DolibarrApi /** * Get country. * - * @param int $id ID of country - * @param string $code Code of country (2 characters) - * @param string $iso ISO of country (3 characters) - * @param string $lang Code of the language the name of the - * country must be translated to - * @return array Array of cleaned object properties + * @param int $id ID of country + * @param string $code Code of country (2 characters) + * @param string $iso ISO of country (3 characters) + * @param string $lang Code of the language the name of the country must be translated to + * @return Object Object with cleaned properties * * @throws RestException */ @@ -527,12 +523,12 @@ class Setup extends DolibarrApi /** * Get the list of delivery times. * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Delivery times is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Delivery times is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. * * @url GET dictionary/availability * @@ -592,8 +588,8 @@ class Setup extends DolibarrApi /** * Clean sensible object datas * - * @param Object $object Object to clean - * @return Object Object with cleaned properties + * @param Object $object Object to clean + * @return Object Object with cleaned properties */ protected function _cleanObjectDatas($object) { @@ -1686,6 +1682,68 @@ class Setup extends DolibarrApi return $list; } + /** + * Get the list of incoterms. + * + * @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 int $active Payment term is active or not {@min 0} {@max 1} + * @param string $lang Code of the language the label of the type must be translated to + * @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 incoterm types + * + * @url GET dictionary/incoterms + * + * @throws RestException + */ + public function getListOfIncoterms($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $lang = '', $sqlfilters = '') + { + $list = array(); + + $sql = "SELECT rowid, code, active"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_incoterms as t"; + $sql .= " WHERE 1=1"; + + // Add sql filters + if ($sqlfilters) { + $errormessage = ''; + if (!DolibarrApi::_checkFilters($sqlfilters, $errormessage)) { + throw new RestException(400, 'Error when validating parameter sqlfilters -> '.$errormessage); + } + $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++) { + $type =$this->db->fetch_object($result); + $list[] = $type; + } + } else { + throw new RestException(503, 'Error when retrieving list of incoterm types : '.$this->db->lasterror()); + } + + return $list; + } + /** * Get properties of company * @@ -1704,11 +1762,6 @@ class Setup extends DolibarrApi throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_GET_COMPANY'); } - unset($mysoc->skype); - unset($mysoc->twitter); - unset($mysoc->facebook); - unset($mysoc->linkedin); - unset($mysoc->pays); unset($mysoc->note); unset($mysoc->nom); @@ -1786,8 +1839,8 @@ class Setup extends DolibarrApi /** * Get establishment by ID. * - * @param int $id ID of establishment - * @return array Array of cleaned object properties + * @param int $id ID of establishment + * @return Object Object with cleaned properties * * @url GET establishments/{id} * @@ -1813,7 +1866,7 @@ class Setup extends DolibarrApi * Note that conf variables that stores security key or password hashes can't be loaded with API. * * @param string $constantname Name of conf variable to get - * @return array|mixed Data without useless information + * @return string Data without useless information * * @url GET conf/{constantname} * @@ -1825,7 +1878,7 @@ class Setup extends DolibarrApi global $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_CONST_READ)) { + && (!getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ') || DolibarrApiAccess::$user->login != getDolGlobalString('API_LOGINS_ALLOWED_FOR_CONST_READ'))) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGINS_ALLOWED_FOR_CONST_READ'); } @@ -1836,7 +1889,7 @@ class Setup extends DolibarrApi throw new RestException(403, 'Forbidden. This parameter cant be read with APIs'); } - return $conf->global->$constantname; + return getDolGlobalString($constantname); } /** diff --git a/htdocs/api/index.php b/htdocs/api/index.php index 085dd338e69..4e4da2c94cc 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -389,13 +389,13 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' && $usecompression = (empty($conf->global->API_DISABLE_COMPRESSION) && !empty($_SERVER['HTTP_ACCEPT_ENCODING'])); $foundonealgorithm = 0; if ($usecompression) { - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress')) { $foundonealgorithm++; } - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) { $foundonealgorithm++; } - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) { $foundonealgorithm++; } if (!$foundonealgorithm) { @@ -413,13 +413,13 @@ $result = $api->r->handle(); if (Luracast\Restler\Defaults::$returnResponse) { // We try to compress the data received data - if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && is_callable('brotli_compress')) { + if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'br') !== false && function_exists('brotli_compress') && defined('BROTLI_TEXT')) { header('Content-Encoding: br'); - $result = brotli_compress($result, 11, BROTLI_TEXT); - } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && is_callable('bzcompress')) { + $result = brotli_compress($result, 11, constant('BROTLI_TEXT')); + } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'bz') !== false && function_exists('bzcompress')) { header('Content-Encoding: bz'); $result = bzcompress($result, 9); - } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && is_callable('gzencode')) { + } elseif (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('gzencode')) { header('Content-Encoding: gzip'); $result = gzencode($result, 9); } else { diff --git a/htdocs/asset/admin/setup.php b/htdocs/asset/admin/setup.php index 67448b0e304..1b107746319 100644 --- a/htdocs/asset/admin/setup.php +++ b/htdocs/asset/admin/setup.php @@ -68,16 +68,14 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstorder = GETPOST('maskconstorder', 'alpha'); - $maskorder = GETPOST('maskorder', 'alpha'); + $maskconst = GETPOST('maskconst', 'alpha'); + $mask = GETPOST('mask', 'alpha'); - if ($maskconstorder) { - $res = dolibarr_set_const($db, $maskconstorder, $maskorder, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $mask, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; } @@ -206,7 +204,7 @@ foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) { } if ($myTmpObjectArray['includerefgeneration']) { /* - * Orders Numbering model + * Assets Numbering model */ $setupnotempty++; @@ -475,14 +473,14 @@ if ($action == 'edit') { if ($val['type'] == 'textarea') { print '\n"; } elseif ($val['type']== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($constname, getDolGlobalString($constname), '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); + print $form->selectyesno($constname, getDolGlobalString($constname), 1); } elseif (preg_match('/emailtemplate:/', $val['type'])) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -502,7 +500,7 @@ if ($action == 'edit') { $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; } } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray($constname, $arrayofmessagename, getDolGlobalString($constname), 'None', 0, 0, '', 0, 0, 0, '', '', 1); } elseif (preg_match('/category:/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -510,11 +508,11 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); + print $formother->select_categories($tmp[1], getDolGlobalString($constname), $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $val['type'])) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); + print $formcompany->selectProspectCustomerType(getDolGlobalString($constname), $constname); } elseif ($val['type'] == 'securekey') { print ''; if (!empty($conf->use_javascript_ajax)) { @@ -526,11 +524,11 @@ if ($action == 'edit') { print dolJSToSetRandomPassword($constname, 'generate_token'.$constname); } elseif ($val['type'] == 'product') { if (isModEnabled("product") || isModEnabled("service")) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); $form->select_produits($selected, $constname, '', 0); } } elseif ($val['type'] == 'accountancy_code') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php'; $formaccounting = new FormAccounting($db); @@ -539,7 +537,7 @@ if ($action == 'edit') { print ''; } } elseif ($val['type'] == 'accountancy_category') { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); + $selected = getDolGlobalString($constname); if (isModEnabled('accounting')) { print ''; // autosuggest from existing account types if found @@ -589,9 +587,9 @@ if ($action == 'edit') { print ''; if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); + print dol_nl2br(getDolGlobalString($constname)); } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } elseif ($val['type'] == 'yesno') { print ajax_constantonoff($constname); } elseif (preg_match('/emailtemplate:/', $val['type'])) { @@ -600,14 +598,14 @@ if ($action == 'edit') { $tmp = explode(':', $val['type']); - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); + $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, getDolGlobalString($constname)); if ($template<0) { setEventMessages(null, $formmail->errors, 'errors'); } print $langs->trans($template->label); } elseif (preg_match('/category:/', $val['type'])) { $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); + $result = $c->fetch(getDolGlobalInt($constname)); if ($result < 0) { setEventMessages(null, $c->errors, 'errors'); } elseif ($result > 0 ) { @@ -619,18 +617,18 @@ if ($action == 'edit') { print '
    ' . implode(' ', $toprint) . '
'; } } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { + if (getDolGlobalInt($constname)==2) { print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { + } elseif (getDolGlobalInt($constname)==3) { print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { + } elseif (getDolGlobalInt($constname)==1) { print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { + } elseif (getDolGlobalInt($constname)==0) { print $langs->trans("NorProspectNorCustomer"); } } elseif ($val['type'] == 'product') { $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); + $resprod = $product->fetch(getDolGlobalInt($constname)); if ($resprod > 0) { print $product->ref; } elseif ($resprod < 0) { @@ -640,11 +638,11 @@ if ($action == 'edit') { if (isModEnabled('accounting')) { require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php'; $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $conf->global->{$constname}, 1); + $accountingaccount->fetch('', getDolGlobalString($constname), 1); print $accountingaccount->getNomUrl(0, 1, 1, '', 1); } else { - print $conf->global->{$constname}; + print getDolGlobalString($constname); } } else { print $conf->global->{$constname}; diff --git a/htdocs/asset/agenda.php b/htdocs/asset/agenda.php index b40ed122ec6..c86697b207d 100644 --- a/htdocs/asset/agenda.php +++ b/htdocs/asset/agenda.php @@ -46,7 +46,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -171,7 +171,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid=' . urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -181,7 +181,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print '' . $langs->trans("AddAction") . ''; } else { print '' . $langs->trans("AddAction") . ''; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 7c2b55c045e..c01f4b967c4 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -410,7 +410,7 @@ class Asset extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index fb574e6ea18..a973abc3764 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -348,7 +348,7 @@ class AssetModel extends CommonObject $sql .= $this->getFieldList('t'); $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + $sql .= " WHERE t.entity IN (".getEntity($this->element).")"; } else { $sql .= " WHERE 1 = 1"; } diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index 17fb19fe565..8758d22879c 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -46,7 +46,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ? GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -173,7 +173,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid=' . urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : '') . '&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid=' . urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -183,7 +183,7 @@ if ($object->id > 0) { print '
'; // if (isModEnabled('agenda')) { - // if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + // if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { // print '' . $langs->trans("AddAction") . ''; // } else { // print '' . $langs->trans("AddAction") . ''; diff --git a/htdocs/asset/tpl/linkedobjectblock.tpl.php b/htdocs/asset/tpl/linkedobjectblock.tpl.php index aef30995432..11d94714db8 100644 --- a/htdocs/asset/tpl/linkedobjectblock.tpl.php +++ b/htdocs/asset/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Asset"); + echo ''.$langs->trans("Asset"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''.$objectlink->label.''; echo ''.dol_print_date($objectlink->date_start, 'day').''; echo ''; diff --git a/htdocs/barcode/codeinit.php b/htdocs/barcode/codeinit.php index 8ce559031a1..9c45d29cf79 100644 --- a/htdocs/barcode/codeinit.php +++ b/htdocs/barcode/codeinit.php @@ -48,7 +48,7 @@ $thirdpartytmp = new Societe($db); $modBarCodeProduct = ''; $modBarCodeThirdparty = ''; -$maxperinit = 1000; +$maxperinit = empty($conf->global->BARCODE_INIT_MAX) ? 1000 : $conf->global->BARCODE_INIT_MAX; // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); @@ -179,14 +179,16 @@ if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) { 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); - } + if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) { + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } - $modBarCodeProduct = new $file(); - break; + $modBarCodeProduct = new $file(); + break; + } } } closedir($handle); diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 373effecbe8..56361b948f0 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -226,7 +226,7 @@ if ($action == 'builddoc') { 'code'=>$code, 'encoding'=>$encoding, 'is2d'=>$is2d, - 'photo'=>$barcodeimage // Photo must be a file that exists with format supported by TCPDF + 'photo'=>!empty($barcodeimage) ? $barcodeimage : '' // Photo must be a file that exists with format supported by TCPDF ); } } else { diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 7240aaf0151..b3dd9b45f47 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -304,8 +304,8 @@ class BlockedLogAuthority $url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$signature.'&b='.$block->signature; $res = getURLContent($url); - echo $block->signature.' '.$url.' '.$res.'
'; - if ($res === 'blockalreadyadded' || $res === 'blockadded') { + echo $block->signature.' '.$url.' '.$res['content'].'
'; + if ($res['content'] === 'blockalreadyadded' || $res['content'] === 'blockadded') { $block->setCertified(); } else { $this->error = $langs->trans('ImpossibleToContactAuthority ', $url); diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index f133d1bbd4b..c7fcf64fb47 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -49,7 +49,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -215,7 +215,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.$objthirdparty->id; } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.="
"; @@ -225,7 +225,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 333b6232f9f..3901e18bac4 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2017-2023 Laurent Destailleur * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -275,303 +275,303 @@ if (empty($reshook)) { $object->calculateCosts(); } } +} +/* + * View + */ - /* - * View - */ - - $form = new Form($db); - $formfile = new FormFile($db); +$form = new Form($db); +$formfile = new FormFile($db); - $title = $langs->trans('BOM'); - $help_url ='EN:Module_BOM'; - llxHeader('', $title, $help_url); +$title = $langs->trans('BOM'); +$help_url ='EN:Module_BOM'; +llxHeader('', $title, $help_url); - // Part to create - if ($action == 'create') { - print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); +// Part to create +if ($action == 'create') { + print load_fiche_titre($langs->trans("NewBOM"), '', 'bom'); - print '
'; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; - print dol_get_fiche_head(array(), ''); + print dol_get_fiche_head(array(), ''); - print ''."\n"; + print '
'."\n"; - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - print '
'."\n"; + print ''."\n"; - print dol_get_fiche_end(); + print dol_get_fiche_end(); - print $form->buttonsSaveCancel("Create"); + print $form->buttonsSaveCancel("Create"); - print '
'; + print ''; +} + +// Part to edit record +if (($id || $ref) && $action == 'edit') { + print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print dol_get_fiche_head(); + + //$object->fields['keyfield']['disabled'] = 1; + + print ''."\n"; + + // Common attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); + + print $form->buttonsSaveCancel("Create"); + + print '
'; +} + +// Part to show record +if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { + $head = bomPrepareHead($object); + print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); + + $formconfirm = ''; + + // Confirmation to delete + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); + } + // Confirmation to delete line + if ($action == 'deleteline') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); } - // Part to edit record - if (($id || $ref) && $action == 'edit') { - print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes'); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print dol_get_fiche_head(); - - //$object->fields['keyfield']['disabled'] = 1; - - print ''."\n"; - - // Common attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_edit.tpl.php'; - - print '
'; - - print dol_get_fiche_end(); - - print $form->buttonsSaveCancel("Create"); - - print '
'; - } - - // Part to show record - if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $head = bomPrepareHead($object); - print dol_get_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom'); - - $formconfirm = ''; - - // Confirmation to delete - if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1); - } - // Confirmation to delete line - if ($action == 'deleteline') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); - } - - // Confirmation of validation - if ($action == 'validate') { - // We check that object has a temporary ref - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') { - $object->fetch_product(); - $numref = $object->getNextNumRef($object->product); - } else { - $numref = $object->ref; - } - - $text = $langs->trans('ConfirmValidateBom', $numref); - /*if (isModEnabled('notification')) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); - }*/ - - $formquestion = array(); - if (isModEnabled('bom')) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); - } - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); - } - - // Confirmation of closing - if ($action == 'close') { - $text = $langs->trans('ConfirmCloseBom', $object->ref); - /*if (isModEnabled('notification')) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - if (isModEnabled('bom')) { - $langs->load("mrp"); - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); - } - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); - } - - // Confirmation of reopen - if ($action == 'reopen') { - $text = $langs->trans('ConfirmReopenBom', $object->ref); - /*if (isModEnabled('notification')) - { - require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); - }*/ - - $formquestion = array(); - if (isModEnabled('bom')) { - $langs->load("mrp"); - require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; - $forcecombo = 0; - if ($conf->browser->name == 'ie') { - $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy - } - $formquestion = array( - // 'text' => $langs->trans("ConfirmClone"), - // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - ); - } - - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); - } - - // Clone confirmation - if ($action == 'clone') { - // Create an array for form - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); - } - - // Confirmation of action xxxx - if ($action == 'setdraft') { - $text = $langs->trans('ConfirmSetToDraft', $object->ref); - - $formquestion = array(); - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - - // Object card - // ------------------------------------------------------------ - $linkback = ''.$langs->trans("BackToList").''; - - $morehtmlref = '
'; - /* - // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); - // Thirdparty - $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); - // Project - if (isModEnabled('project')) - { - $langs->load("projects"); - $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($permissiontoadd) - { - if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref.='
'; - $morehtmlref.=''; - $morehtmlref.=''; - $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref.=''; - $morehtmlref.='
'; - } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } + // Confirmation of validation + if ($action == 'validate') { + // We check that object has a temporary ref + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') { + $object->fetch_product(); + $numref = $object->getNextNumRef($object->product); } else { - if (! empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref.=$proj->getNomUrl(); - } else { - $morehtmlref.=''; + $numref = $object->ref; + } + + $text = $langs->trans('ConfirmValidateBom', $numref); + /*if (isModEnabled('notification')) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_VALIDATE', $object->socid, $object); + }*/ + + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy } + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $text, 'confirm_validate', $formquestion, 0, 1, 220); + } + + // Confirmation of closing + if ($action == 'close') { + $text = $langs->trans('ConfirmCloseBom', $object->ref); + /*if (isModEnabled('notification')) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ + + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); } - */ - $morehtmlref .= '
'; + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Close'), $text, 'confirm_close', $formquestion, 0, 1, 220); + } + + // Confirmation of reopen + if ($action == 'reopen') { + $text = $langs->trans('ConfirmReopenBom', $object->ref); + /*if (isModEnabled('notification')) + { + require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('BOM_CLOSE', $object->socid, $object); + }*/ + + $formquestion = array(); + if (isModEnabled('bom')) { + $langs->load("mrp"); + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $forcecombo = 0; + if ($conf->browser->name == 'ie') { + $forcecombo = 1; // There is a bug in IE10 that make combo inside popup crazy + } + $formquestion = array( + // 'text' => $langs->trans("ConfirmClone"), + // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + ); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $text, 'confirm_reopen', $formquestion, 0, 1, 220); + } + + // Clone confirmation + if ($action == 'clone') { + // Create an array for form + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneBillOfMaterials', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); + } + + // Confirmation of action xxxx + if ($action == 'setdraft') { + $text = $langs->trans('ConfirmSetToDraft', $object->ref); + + $formquestion = array(); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220); + } + + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } + + // Print form confirm + print $formconfirm; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + // Object card + // ------------------------------------------------------------ + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + /* + // Ref bis + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); + // Thirdparty + $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); + // Project + if (isModEnabled('project')) + { + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($permissiontoadd) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=$proj->getNomUrl(); + } else { + $morehtmlref.=''; + } + } + } + */ + $morehtmlref .= '
'; - print '
'; - print '
'; - print '
'; - print ''."\n"; + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - // Common attributes - $keyforbreak = 'duration'; - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + + print '
'; + print '
'; + print '
'; + print '
'."\n"; + + // Common attributes + $keyforbreak = 'duration'; + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + $object->calculateCosts(); + print ''; + print ''; + + // Other attributes + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + + print '
'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).'
'.$langs->trans("UnitCost").''.price($object->unit_cost).'
'; + print '
'; + print '
'; + + print '
'; + + print dol_get_fiche_end(); + + + + /* + * Lines + */ + + if (!empty($object->table_element_line)) { + // Products + $res = $object->fetchLinesbytypeproduct(0); $object->calculateCosts(); - print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).''.price($object->total_cost).''; - print ''.$langs->trans("UnitCost").''.price($object->unit_cost).''; - // Other attributes - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); - print ''; - print '
'; - print '
'; - - print '
'; - - print dol_get_fiche_end(); - - - - /* - * Lines - */ - - if (!empty($object->table_element_line)) { - //Products - $res = $object->fetchLinesbytypeproduct(0); - $object->calculateCosts(); - - print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMProductsList'), '', 'product'); - - print '
+ print ' @@ -579,81 +579,30 @@ if (empty($reshook)) { '; - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add products/services form + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add products/services form - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - } - } - - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print '
'; - } - print '
'; - - print "
\n"; - - mrpCollapseBomManagement(); - - - //Services - $filtertype = 1; - $res = $object->fetchLinesbytypeproduct(1); - $object->calculateCosts(); - - print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); - - print '
- - - - - '; - - if (!empty($conf->use_javascript_ajax) && $object->status == 0) { - $tagidfortablednd = 'tablelinesservice'; - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; - } - - print '
'; - if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { - print ''; - } - - if (!empty($object->lines)) { - $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); - } - - // Form to add new line - if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { - if ($action != 'editline') { - // Add services form - $parameters = array(); - $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - if (empty($reshook)) - $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); - } } } @@ -664,12 +613,61 @@ if (empty($reshook)) { print "\n"; - mrpCollapseBomManagement(); + // Services + $filtertype = 1; + $res = $object->fetchLinesbytypeproduct(1); + $object->calculateCosts(); + + print ($res == 0 && $object->status >= $object::STATUS_VALIDATED) ? '' : load_fiche_titre($langs->trans('BOMServicesList'), '', 'service'); + + print ' + + + + + '; + + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + $tagidfortablednd = 'tablelinesservice'; + include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + } + + print '
'; + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + + if (!empty($object->lines)) { + $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); + } + + // Form to add new line + if ($object->status == 0 && $permissiontoadd && $action != 'selectlines') { + if ($action != 'editline') { + // Add services form + $parameters = array(); + $reshook = $hookmanager->executeHooks('formAddObjectServiceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if (empty($reshook)) + $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl'); + } + } } - $res = $object->fetchLines(); + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { + print '
'; + } + print '
'; - // Buttons for actions + print "\n"; + + + mrpCollapseBomManagement(); + + + $res = $object->fetchLines(); + + // Buttons for actions if ($action != 'presend' && $action != 'editline') { print '
'."\n"; @@ -683,16 +681,16 @@ if (empty($reshook)) { // Send //if (empty($user->socid)) { // print '' . $langs->trans('SendMail') . ''."\n"; - //} + //} - // Back to draft + // Back to draft if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { print ''.$langs->trans("SetToDraft").''."\n"; } } - // Modify + // Modify if ($object->status == $object::STATUS_DRAFT) { if ($permissiontoadd) { print ''.$langs->trans("Modify").''."\n"; @@ -701,7 +699,7 @@ if (empty($reshook)) { } } - // Validate + // Validate if ($object->status == $object::STATUS_DRAFT) { if ($permissiontoadd) { if (is_array($object->lines) && count($object->lines) > 0) { @@ -713,50 +711,50 @@ if (empty($reshook)) { } } - // Re-open + // Re-open if ($permissiontoadd && $object->status == $object::STATUS_CANCELED) { print ''.$langs->trans("ReOpen").''."\n"; } - // Create MO + // Create MO if (isModEnabled('mrp')) { if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write)) { print ''.$langs->trans("CreateMO").''."\n"; } } - // Clone + // Clone if ($permissiontoadd) { print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : "").'&action=clone&object=bom', 'clone', $permissiontoadd); } - // Close / Cancel + // Close / Cancel if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED) { print ''.$langs->trans("Disable").''."\n"; } - /* - if ($user->rights->bom->write) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; - } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ + /* + if ($user->rights->bom->write) + { + if ($object->status == 1) + { + print ''.$langs->trans("Disable").''."\n"; + } + else + { + print ''.$langs->trans("Enable").''."\n"; + } + } + */ - // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); + // Delete + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); } print '
'."\n"; } - // Select mail models is same action as presend + // Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } @@ -793,20 +791,21 @@ if (empty($reshook)) { print '
'; } - //Select mail models is same action as presend + //Select mail models is same action as presend if (GETPOST('modelselected')) { $action = 'presend'; } - // Presend form - $modelmail = 'bom'; - $defaulttopic = 'InformationMessage'; - $diroutput = $conf->bom->dir_output; - $trackid = 'bom'.$object->id; + // Presend form + $modelmail = 'bom'; + $defaulttopic = 'InformationMessage'; + $diroutput = $conf->bom->dir_output; + $trackid = 'bom'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } + // End of page llxFooter(); $db->close(); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index b9b20c64d1f..c5e5491dff8 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -42,6 +42,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'bomlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'alpha'); // mode view (kanban or common) + // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -70,6 +72,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. } if (!$sortorder) { @@ -77,7 +80,7 @@ if (!$sortorder) { } // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = GETPOST('search_all', 'alphanohtml'); $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { @@ -106,7 +109,7 @@ foreach ($object->fields as $key => $val) { $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -297,7 +300,7 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key.' ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks @@ -334,17 +337,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -364,9 +367,8 @@ $sql .= $hookmanager->resPrint; /* If a group by is required $sql.= " GROUP BY "; -foreach($object->fields as $key => $val) -{ - $sql .= "t.".$key.", "; +foreach($object->fields as $key => $val) { + $sql .= "t.".$db->escape($key).", "; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { @@ -433,6 +435,9 @@ llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', ''); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -440,11 +445,17 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -464,7 +475,7 @@ $arrayofmassactions = array( 'enable'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Enable"), 'disable'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Disable"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -483,8 +494,13 @@ print ''; print ''; print ''; print ''; +print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bom/bom_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->rights->bom->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -496,10 +512,13 @@ $trackid = 'bom'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -535,13 +554,14 @@ print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; $searchpicto = $form->showFilterButtons('left'); print $searchpicto; print ''; } foreach ($object->fields as $key => $val) { + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -549,13 +569,13 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status width100 onrightofpage' : ''), 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { @@ -567,6 +587,12 @@ foreach ($object->fields as $key => $val) { print '
'; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print ''; } @@ -580,20 +606,22 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $obje print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; } print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); @@ -603,23 +631,26 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // 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); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; } +$totalarray['nbfield']++; // For the column action print ''."\n"; @@ -637,9 +668,11 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); $totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -648,88 +681,107 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - 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($object->id, $arrayofselected)) { - $selected = 1; - } - print ''; + // mode view kanban + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; } - print ''; - } - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + // Output kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print ''; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; - } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); - } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; - } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - 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($object->id, $arrayofselected)) { - $selected = 1; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - print ''; - } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; + } + } + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; } @@ -746,14 +798,14 @@ if ($num == 0) { $colspan++; } } - print ''.$langs->trans("NoRecordFound").''; + print ''.$langs->trans("NoRecordFound").''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print ''."\n"; diff --git a/htdocs/bom/bom_net_needs.php b/htdocs/bom/bom_net_needs.php index 1b8afa91e52..60736d085da 100644 --- a/htdocs/bom/bom_net_needs.php +++ b/htdocs/bom/bom_net_needs.php @@ -187,8 +187,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dol_get_fiche_end(); - $viewlink = dolGetButtonTitle($langs->trans('GroupByProduct'), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); - $viewlink .= dolGetButtonTitle($langs->trans('TreeStructure'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':''))); + $viewlink = dolGetButtonTitle($langs->trans('GroupByX', $langs->transnoentitiesnoconv("Products")), '', 'fa fa-bars imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&token='.newToken(), '', 1, array('morecss' => 'reposition '.($action !== 'treeview' ? 'btnTitleSelected':''))); + $viewlink .= dolGetButtonTitle($langs->trans('TreeView'), '', 'fa fa-stream imgforviewmode', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=treeview&token='.newToken(), '', 1, array('morecss' => 'reposition marginleftonly '.($action == 'treeview' ? 'btnTitleSelected':''))); print load_fiche_titre($langs->trans("BOMNetNeeds"), $viewlink, ''); diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index c2df69b9012..1a42e17d875 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -205,6 +205,9 @@ class Boms extends DolibarrApi foreach ($request_data as $field => $value) { $this->bom->$field = $value; } + + $this->checkRefNumbering(); + if (!$this->bom->create(DolibarrApiAccess::$user)) { throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } @@ -241,6 +244,8 @@ class Boms extends DolibarrApi $this->bom->$field = $value; } + $this->checkRefNumbering(); + if ($this->bom->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); } else { @@ -536,4 +541,27 @@ class Boms extends DolibarrApi } return $myobject; } + + /** + * Validate the ref field and get the next Number if it's necessary. + * + * @return void + */ + private function checkRefNumbering(): void + { + $ref = substr($this->bom->ref, 1, 4); + if ($this->bom->status > 0 && $ref == 'PROV') { + throw new RestException(400, "Wrong naming scheme '(PROV%)' is only allowed on 'DRAFT' status. For automatic increment use 'auto' on the 'ref' field."); + } + + if (strtolower($this->bom->ref) == 'auto') { + if (empty($this->bom->id) && $this->bom->status == 0) { + $this->bom->ref = ''; // 'ref' will auto incremented with '(PROV' + newID + ')' + } else { + $this->bom->fetch_product(); + $numref = $this->bom->getNextNumRef($this->bom->product); + $this->bom->ref = $numref; + } + } + } } diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index cd5b119cabf..84bae509ebd 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -102,9 +102,9 @@ class BOM extends CommonObject 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'notnull'=>1, 'searchall'=>1, 'showoncombobox'=>'2', 'autofocusoncreate'=>1, 'css'=>'minwidth300 maxwidth400', 'csslist'=>'tdoverflowmax200'), 'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth175', 'csslist'=>'minwidth175 center'), //'bomtype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'position'=>32, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing')), - 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:(finished IS NULL or finished <> 0)', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'), + 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:1:((finished:is:null) or (finished:!=:0))', 'label'=>'Product', 'picto'=>'product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'help'=>'ProductBOMHelp', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,), - 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth75imp'), + 'qty' => array('type'=>'real', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>55, 'notnull'=>1, 'isameasure'=>'1', 'css'=>'maxwidth50imp right'), //'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', 'picto'=>'stock', 'enabled'=>1, 'visible'=>-1, 'position'=>102, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax100'), @@ -476,7 +476,7 @@ class BOM extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -1329,7 +1329,7 @@ class BOM extends CommonObject * BOM costs calculation based on cost_price or pmp of each BOM line. * Set the property ->total_cost and ->unit_cost of BOM. * - * @return void + * @return int <0 if KO, >0 if OK */ public function calculateCosts() { @@ -1378,7 +1378,8 @@ class BOM extends CommonObject if ($res > 0) { $bom_child->calculateCosts(); $line->childBom[] = $bom_child; - $this->total_cost += $bom_child->total_cost * $line->qty; + $this->total_cost += price2num($bom_child->total_cost * $line->qty, 'MT'); + $this->total_cost += $line->total_cost; } else { $this->error = $bom_child->error; return -2; @@ -1414,6 +1415,8 @@ class BOM extends CommonObject $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } + + return 1; } /** @@ -1515,6 +1518,47 @@ class BOM extends CommonObject } } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $db,$langs; + $prod = new Product($db); + $prod->fetch($this->fk_product); + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : '').''; + if (property_exists($this, 'fields') && !empty($this->fields['bomtype']['arrayofkeyval'])) { + $return .= '
'.$langs->trans("Type").' : '; + if ($this->bomtype == 0) { + $return .= ''.$this->fields['bomtype']['arrayofkeyval'][0].''; + } else { + $return .= ''.$this->fields['bomtype']['arrayofkeyval'][1].''; + } + } + if (property_exists($this, 'fk_product') && !is_null($this->fk_product)) { + $return .= '
'.$prod->getNomUrl(1).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -1736,7 +1780,7 @@ class BOMLine extends CommonObjectLine $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if ($this->ismultientitymanaged) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index 8a98c078bc5..1765e9a84c1 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -47,12 +47,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo ''; - echo ''.$langs->trans("Bom"); + echo ''.$langs->trans("Bom"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' '; - echo ''.$objectlink->getNomUrl(1).''; + echo ''.$objectlink->getNomUrl(1).''; echo ''; $result = $product_static->fetch($objectlink->fk_product); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index e644c7813e7..e87d526302b 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -73,7 +73,7 @@ if ($nolinesbefore) { print ''.$langs->trans('Qty').''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; print ''; print $langs->trans('Unit'); @@ -107,7 +107,7 @@ print ''; if (isModEnabled("product") || isModEnabled("service")) { if ($filtertype == 1) { print $langs->trans("Service"); - } elseif (!empty($conf->global->BOM_SUB_BOM)) { + } else { print $langs->trans("Product"); } echo ''; @@ -145,7 +145,7 @@ print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index 88463996ebc..969b210e89b 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -126,7 +126,7 @@ if (($line->info_bits & 2) != 2) { print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $coldisplay++; print ''; print ''; diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 5252baf61ca..0ede4190279 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -67,7 +67,7 @@ print ''; print ''.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print '' . $langs->trans('Unit') . ''; } diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index b7087b27288..2dbc793fdf4 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -119,7 +119,7 @@ echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but print ''; if ($filtertype != 1) { - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; $label = $tmpproduct->getLabelOfUnit('long'); if ($label !== '') { @@ -167,9 +167,14 @@ if ($filtertype != 1) { } } $total_cost = 0; +$tmpbom->calculateCosts(); print ''; $coldisplay++; -echo ''.price($line->total_cost).''; +if (!empty($line->fk_bom_child)) { + echo ''.price($tmpbom->total_cost * $line->qty).''; +} else { + echo ''.price($line->total_cost).''; +} print ''; if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') { @@ -261,11 +266,23 @@ if ($resql) { } // Qty + $label = $sub_bom_product->getLabelOfUnit('long'); if ($sub_bom_line->qty_frozen > 0) { print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + if ($label !== '') print $langs->trans($label); + print ''; + } print ''.$langs->trans('Yes').''; } else { print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + print ''; + if ($label !== '') print $langs->trans($label); + print ''; + } + print ' '; } @@ -282,13 +299,13 @@ if ($resql) { // Cost if (!empty($sub_bom->id)) { $sub_bom->calculateCosts(); - print ''.price($sub_bom->total_cost * $sub_bom_line->qty * $line->qty).''; + print ''.price(price2num($sub_bom->total_cost * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom->total_cost * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->cost_price > 0) { - print ''.price($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty).''; + print ''.price(price2num($sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost+= $sub_bom_product->cost_price * $sub_bom_line->qty * $line->qty; } elseif ($sub_bom_product->pmp > 0) { // PMP if cost price isn't defined - print ''.price($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty).''; + print ''.price(price2num($sub_bom_product->pmp * $sub_bom_line->qty * $line->qty, 'MT')).''; $total_cost.= $sub_bom_product->pmp * $sub_bom_line->qty * $line->qty; } else { // Minimum purchase price if cost price and PMP aren't defined $sql_supplier_price = 'SELECT MIN(price) AS min_price, quantity AS qty FROM '.MAIN_DB_PREFIX.'product_fournisseur_price'; @@ -298,7 +315,7 @@ if ($resql) { $obj = $object->db->fetch_object($resql_supplier_price); $line_cost = $obj->min_price/$obj->qty * $sub_bom_line->qty * $line->qty; - print ''.price($line_cost).''; + print ''.price2num($line_cost, 'MT').''; $total_cost+= $line_cost; } } @@ -309,15 +326,5 @@ if ($resql) { } } -// Replace of the total_cost value by the sum of all sub-BOM lines total_cost -// TODO Remove this bad practice. We should not replace content of ouput using javascript but value should be good during generation of output. -if ($total_cost > 0) { - $line->total_cost = price($total_cost); - ?> - - \n"; diff --git a/htdocs/bookcal/admin/about.php b/htdocs/bookcal/admin/about.php deleted file mode 100644 index 85f0efcdebb..00000000000 --- a/htdocs/bookcal/admin/about.php +++ /dev/null @@ -1,105 +0,0 @@ - - * Copyright (C) 2022 Alice Adminson - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file bookcal/admin/about.php - * \ingroup bookcal - * \brief About page of module BookCal. - */ - -// Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} - -// Libraries -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once '../lib/bookcal.lib.php'; - -// Translations -$langs->loadLangs(array("errors", "admin", "bookcal@bookcal")); - -// Access control -if (!$user->admin) { - accessforbidden(); -} - -// Parameters -$action = GETPOST('action', 'aZ09'); -$backtopage = GETPOST('backtopage', 'alpha'); - - -/* - * Actions - */ - -// None - - -/* - * View - */ - -$form = new Form($db); - -$help_url = ''; -$page_name = "BookCalAbout"; - -llxHeader('', $langs->trans($page_name), $help_url); - -// Subheader -$linkback = ''.$langs->trans("BackToModuleList").''; - -print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); - -// Configuration header -$head = bookcalAdminPrepareHead(); -print dol_get_fiche_head($head, 'about', $langs->trans($page_name), 0, 'bookcal@bookcal'); - -dol_include_once('/bookcal/core/modules/modBookCal.class.php'); -$tmpmodule = new modBookCal($db); -print $tmpmodule->getDescLong(); - -// Page end -print dol_get_fiche_end(); -llxFooter(); -$db->close(); diff --git a/htdocs/bookcal/admin/availabilities_extrafields.php b/htdocs/bookcal/admin/availabilities_extrafields.php index 9d16d7b5395..190a44f339d 100644 --- a/htdocs/bookcal/admin/availabilities_extrafields.php +++ b/htdocs/bookcal/admin/availabilities_extrafields.php @@ -27,38 +27,13 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/bookcal.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('bookcal@bookcal', 'admin')); +$langs->loadLangs(array('agenda', 'admin')); $extrafields = new ExtraFields($db); $form = new Form($db); @@ -105,7 +80,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); $head = bookcalAdminPrepareHead(); -print dol_get_fiche_head($head, 'availabilities_extrafields', $langs->trans($page_name), -1, 'bookcal@bookcal'); +print dol_get_fiche_head($head, 'availabilities_extrafields', $langs->trans($page_name), -1, 'fa-calendar-check'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/bookcal/admin/booking_extrafields.php b/htdocs/bookcal/admin/booking_extrafields.php index 30122d95048..b4029a99338 100644 --- a/htdocs/bookcal/admin/booking_extrafields.php +++ b/htdocs/bookcal/admin/booking_extrafields.php @@ -27,38 +27,13 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once '../lib/bookcal.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('bookcal@bookcal', 'admin')); +$langs->loadLangs(array('agenda', 'admin')); $extrafields = new ExtraFields($db); $form = new Form($db); @@ -105,7 +80,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); $head = bookcalAdminPrepareHead(); -print dol_get_fiche_head($head, 'booking_extrafields', $langs->trans($page_name), -1, 'bookcal@bookcal'); +print dol_get_fiche_head($head, 'booking_extrafields', $langs->trans($page_name), -1, 'fa-calendar-check'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; diff --git a/htdocs/bookcal/admin/setup.php b/htdocs/bookcal/admin/setup.php index c4fd74404eb..e3addec83e3 100644 --- a/htdocs/bookcal/admin/setup.php +++ b/htdocs/bookcal/admin/setup.php @@ -23,32 +23,7 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../../main.inc.php'; global $langs, $user; @@ -58,7 +33,7 @@ require_once '../lib/bookcal.lib.php'; //require_once "../class/myclass.class.php"; // Translations -$langs->loadLangs(array("admin", "bookcal@bookcal")); +$langs->loadLangs(array("admin", "agenda")); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('bookcalsetup', 'globalsetup')); @@ -178,10 +153,10 @@ if ( versioncompare(explode('.', DOL_VERSION), array(15)) < 0 && $action == 'upd include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconst = GETPOST('maskconst', 'alpha'); + $maskconst = GETPOST('maskconst', 'aZ09'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) { + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); if (!($res > 0)) { $error++; @@ -294,7 +269,7 @@ print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); // Configuration header $head = bookcalAdminPrepareHead(); -print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "bookcal@bookcal"); +print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "fa-calendar-check"); // Setup page goes here echo ''.$langs->trans("BookCalSetupPage").'

'; diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php index c3e66a17257..d97970c3add 100644 --- a/htdocs/bookcal/availabilities_agenda.php +++ b/htdocs/bookcal/availabilities_agenda.php @@ -22,67 +22,18 @@ * \brief Tab of events on Availabilities */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -270,7 +221,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '').'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -280,7 +231,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php index b9f5277d4ae..f64b5e6f4b6 100644 --- a/htdocs/bookcal/availabilities_card.php +++ b/htdocs/bookcal/availabilities_card.php @@ -22,67 +22,17 @@ * \brief Page to create/edit/view availabilities */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification -//if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -404,7 +354,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; $morehtmlref .= ' : '; if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; @@ -412,7 +362,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (! empty($object->fk_project)) { diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php index dd01e8bf046..348602f58a9 100644 --- a/htdocs/bookcal/availabilities_contact.php +++ b/htdocs/bookcal/availabilities_contact.php @@ -23,43 +23,15 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); +$langs->loadLangs(array("agenda", "companies", "other", "mails")); $id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index 5bab9356ee1..ed6b2976570 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -22,67 +22,18 @@ * \brief Tab for documents linked to Availabilities */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); +$langs->loadLangs(array("agenda", "companies", "other", "mails")); $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php index 6c5b4c2ed64..414faf2dc5a 100644 --- a/htdocs/bookcal/availabilities_list.php +++ b/htdocs/bookcal/availabilities_list.php @@ -22,58 +22,8 @@ * \brief List page for availabilities */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification -//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -86,7 +36,7 @@ require_once __DIR__.'/class/availabilities.class.php'; //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -260,7 +210,7 @@ $now = dol_now(); //$help_url = "EN:Module_Availabilities|FR:Module_Availabilities_FR|ES:Módulo_Availabilities"; $help_url = ''; -$title = $langs->trans("Availabilitiess"); +$title = $langs->trans("Availabilities"); $morejs = array(); $morecss = array(); @@ -520,7 +470,7 @@ if ($search_all) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php index faae7a08834..6913491d85e 100644 --- a/htdocs/bookcal/availabilities_note.php +++ b/htdocs/bookcal/availabilities_note.php @@ -22,63 +22,14 @@ * \brief Tab for notes on Availabilities */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; -dol_include_once('/bookcal/class/availabilities.class.php'); -dol_include_once('/bookcal/lib/bookcal_availabilities.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_availabilities.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies")); +$langs->loadLangs(array("agenda", "companies")); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php index 1b4e360e4ce..46281eb048a 100644 --- a/htdocs/bookcal/bookcalindex.php +++ b/htdocs/bookcal/bookcalindex.php @@ -25,40 +25,12 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal")); +$langs->loadLangs(array("agenda")); $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php index dec1ebee921..fb26fce4fc7 100644 --- a/htdocs/bookcal/booking_agenda.php +++ b/htdocs/bookcal/booking_agenda.php @@ -22,67 +22,18 @@ * \brief Tab of events on Booking */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -270,7 +221,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.urlencode($objthirdparty->id); } - $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : '').'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.urlencode($objcon->id) : ''); //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -280,7 +231,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php index 0240ab2dccc..82bd884cd2d 100644 --- a/htdocs/bookcal/booking_card.php +++ b/htdocs/bookcal/booking_card.php @@ -22,67 +22,17 @@ * \brief Page to create/edit/view booking */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification -//if (! defined('NOSESSION')) define('NOSESSION', '1'); // Disable session - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -400,7 +350,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; $morehtmlref .= ' : '; if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; @@ -408,7 +358,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= '
'; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (! empty($object->fk_project)) { diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php index 923976adb47..631f6af8e6c 100644 --- a/htdocs/bookcal/booking_contact.php +++ b/htdocs/bookcal/booking_contact.php @@ -23,43 +23,15 @@ */ // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); +$langs->loadLangs(array("agenda", "companies", "other", "mails")); $id = (GETPOST('id') ?GETPOST('id', 'int') : GETPOST('facid', 'int')); // For backward compatibility $ref = GETPOST('ref', 'alpha'); diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php index 81342e1a7b6..fa925759399 100644 --- a/htdocs/bookcal/booking_document.php +++ b/htdocs/bookcal/booking_document.php @@ -22,67 +22,18 @@ * \brief Tab for documents linked to Booking */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies", "other", "mails")); +$langs->loadLangs(array("agenda", "companies", "other", "mails")); $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php index f4aac1e5ed8..3c78ffea120 100644 --- a/htdocs/bookcal/booking_list.php +++ b/htdocs/bookcal/booking_list.php @@ -22,58 +22,8 @@ * \brief List page for booking */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification -//if (! defined('NOSESSION')) define('NOSESSION', '1'); // On CLI mode, no need to use web sessions - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -86,7 +36,7 @@ require_once __DIR__.'/class/booking.class.php'; //dol_include_once('/othermodule/class/otherobject.class.php'); // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "other")); +$langs->loadLangs(array("agenda", "other")); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -520,7 +470,7 @@ if ($search_all) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php index f68ffcbd72b..809f382cc16 100644 --- a/htdocs/bookcal/booking_note.php +++ b/htdocs/bookcal/booking_note.php @@ -22,63 +22,14 @@ * \brief Tab for notes on Booking */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION', '1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', 1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP', 'none'); // Disable all Content Security Policies -//if (! defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET -//if (! defined('NOBROWSERNOTIF')) define('NOBROWSERNOTIF', '1'); // Disable browser notification - // Load Dolibarr environment -$res = 0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { - $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -} -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1; -while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) { - $i--; $j--; -} -if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) { - $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php"; -} -if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) { - $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php"; -} -// Try main.inc.php using relative path -if (!$res && file_exists("../main.inc.php")) { - $res = @include "../main.inc.php"; -} -if (!$res && file_exists("../../main.inc.php")) { - $res = @include "../../main.inc.php"; -} -if (!$res && file_exists("../../../main.inc.php")) { - $res = @include "../../../main.inc.php"; -} -if (!$res) { - die("Include of main fails"); -} +require '../main.inc.php'; -dol_include_once('/bookcal/class/booking.class.php'); -dol_include_once('/bookcal/lib/bookcal_booking.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bookcal/class/booking.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bookcal/lib/bookcal_booking.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("bookcal@bookcal", "companies")); +$langs->loadLangs(array("agenda", "companies")); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index cfbfc8eed88..6b4502e3364 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -74,7 +74,7 @@ class Availabilities extends CommonObject * 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. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...) + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...) * '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) @@ -116,10 +116,10 @@ class Availabilities extends CommonObject 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Canceled'), 'validate'=>'1',), - 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'isameasure'=>'1',), - 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'isameasure'=>'1',), + 'start' => array('type'=>'date', 'label'=>'Start Date', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'searchall'=>1), + 'end' => array('type'=>'date', 'label'=>'End Date', 'enabled'=>'1', 'position'=>45, 'notnull'=>1, 'visible'=>1, 'searchall'=>1), 'type' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>'1', 'position'=>49, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Customer', '1'=>'Supplier', '2'=>'Else'),), - 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30', 'isameasure'=>'1',), + 'duration' => array('type'=>'integer', 'label'=>'Duration', 'enabled'=>'1', 'position'=>47, 'notnull'=>1, 'visible'=>1, 'default'=>'30'), 'startHour' => array('type'=>'integer', 'label'=>'Start Hour', 'enabled'=>'1', 'position'=>46, 'notnull'=>1, 'visible'=>-1,), 'endHour' => array('type'=>'integer', 'label'=>'End Hour', 'enabled'=>'1', 'position'=>46.5, 'notnull'=>1, 'visible'=>-1,), ); @@ -842,7 +842,7 @@ class Availabilities extends CommonObject // phpcs:enable if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; - //$langs->load("bookcal@bookcal"); + //$langs->load("agenda"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); @@ -944,7 +944,7 @@ class Availabilities extends CommonObject public function getNextNumRef() { global $langs, $conf; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); if (empty($conf->global->BOOKCAL_AVAILABILITIES_ADDON)) { $conf->global->BOOKCAL_AVAILABILITIES_ADDON = 'mod_availabilities_standard'; @@ -1009,7 +1009,7 @@ class Availabilities extends CommonObject $result = 0; $includedocgeneration = 0; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); if (!dol_strlen($modele)) { $modele = 'standard_availabilities'; diff --git a/htdocs/bookcal/class/booking.class.php b/htdocs/bookcal/class/booking.class.php index a74cb87a43d..80807d7125f 100644 --- a/htdocs/bookcal/class/booking.class.php +++ b/htdocs/bookcal/class/booking.class.php @@ -74,7 +74,7 @@ class Booking extends CommonObject * 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. * 'picto' is code of a picto to show before value in forms - * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or '!empty($conf->multicurrency->enabled)' ...) + * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM' or 'isModEnabled('multicurrency')' ...) * '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) @@ -104,7 +104,7 @@ class Booking extends CommonObject public $fields=array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1.2, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'validate'=>'1', 'comment'=>"Reference of object"), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'isModEnabled("societe")', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'help'=>"LinkToThirparty", 'validate'=>'1',), 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'picto'=>'project', 'enabled'=>'$conf->project->enabled', 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'css'=>'maxwidth500 widthcentpercentminusxx', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), @@ -842,7 +842,7 @@ class Booking extends CommonObject // phpcs:enable if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; - //$langs->load("bookcal@bookcal"); + //$langs->load("agenda"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); @@ -944,7 +944,7 @@ class Booking extends CommonObject public function getNextNumRef() { global $langs, $conf; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); if (empty($conf->global->BOOKCAL_BOOKING_ADDON)) { $conf->global->BOOKCAL_BOOKING_ADDON = 'mod_booking_standard'; @@ -1009,7 +1009,7 @@ class Booking extends CommonObject $result = 0; $includedocgeneration = 0; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); if (!dol_strlen($modele)) { $modele = 'standard_booking'; diff --git a/htdocs/bookcal/lib/bookcal.lib.php b/htdocs/bookcal/lib/bookcal.lib.php index bc60468fb1d..3f809da08d8 100644 --- a/htdocs/bookcal/lib/bookcal.lib.php +++ b/htdocs/bookcal/lib/bookcal.lib.php @@ -30,7 +30,7 @@ function bookcalAdminPrepareHead() { global $langs, $conf; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); $h = 0; $head = array(); @@ -47,11 +47,6 @@ function bookcalAdminPrepareHead() $h++; */ - $head[$h][0] = dol_buildpath("/bookcal/admin/about.php", 1); - $head[$h][1] = $langs->trans("About"); - $head[$h][2] = 'about'; - $h++; - // Show more tabs from modules // Entries must be declared in modules descriptor with line //$this->tabs = array( diff --git a/htdocs/bookcal/lib/bookcal_availabilities.lib.php b/htdocs/bookcal/lib/bookcal_availabilities.lib.php index 83d204a2d76..1fb4b2aed75 100644 --- a/htdocs/bookcal/lib/bookcal_availabilities.lib.php +++ b/htdocs/bookcal/lib/bookcal_availabilities.lib.php @@ -31,7 +31,7 @@ function availabilitiesPrepareHead($object) { global $db, $langs, $conf; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); $showtabofpagecontact = 1; $showtabofpagenote = 1; diff --git a/htdocs/bookcal/lib/bookcal_booking.lib.php b/htdocs/bookcal/lib/bookcal_booking.lib.php index a6cb0e50df6..c0dec7d6d2e 100644 --- a/htdocs/bookcal/lib/bookcal_booking.lib.php +++ b/htdocs/bookcal/lib/bookcal_booking.lib.php @@ -31,7 +31,7 @@ function bookingPrepareHead($object) { global $db, $langs, $conf; - $langs->load("bookcal@bookcal"); + $langs->load("agenda"); $showtabofpagecontact = 1; $showtabofpagenote = 1; diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index d5258ba26f1..88cae3e4293 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -52,6 +52,7 @@ function printDropdownBookmarksList() } } } + $tmpurl = ''; // No urlencode, all param $url will be urlencoded later if ($sortfield) { @@ -65,7 +66,13 @@ function printDropdownBookmarksList() if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var)) && $val != '' && !array_key_exists($key, $url_param)) { - $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + if (is_array($val)) { + foreach ($val as $tmpsubval) { + $url_param[] = http_build_query(array(dol_escape_htmltag($key).'[]' => dol_escape_htmltag($tmpsubval))); + } + } elseif ($val != '') { + $url_param[$key] = http_build_query(array(dol_escape_htmltag($key) => dol_escape_htmltag($val))); + } } } } @@ -203,11 +210,11 @@ function printDropdownBookmarksList() $html .= ' '."\n"; @@ -1949,7 +1949,7 @@ if ($id > 0) { // related contact print ''.$langs->trans("ActionOnContact").''; print '
'; - print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); + print img_picto('', 'contact', 'class="paddingrightonly"').$form->selectcontacts(empty($conf->global->MAIN_ACTIONCOM_CAN_ADD_ANY_CONTACT) ? $object->socid : 0, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print '
'; print ''; print ''; @@ -2104,7 +2104,7 @@ if ($id > 0) { $("#select_actioncommsendmodel_mail").closest("tr").show(); } else { $("#select_actioncommsendmodel_mail").closest("tr").hide(); - }; + } }); })'; @@ -2191,7 +2191,7 @@ if ($id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2425,7 +2425,7 @@ if ($id > 0) { $tmpuserstatic = new User($db); foreach ($object->reminders as $actioncommreminderid => $actioncommreminder) { - print $TRemindTypes[$actioncommreminder->typeremind]; + print $TRemindTypes[$actioncommreminder->typeremind]['label']; if ($actioncommreminder->fk_user > 0) { $tmpuserstatic->fetch($actioncommreminder->fk_user); print ' ('.$tmpuserstatic->getNomUrl(0, '', 0, 0, 16).')'; @@ -2466,14 +2466,14 @@ if ($id > 0) { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (empty($reshook)) { if ($action != 'edit') { - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; } else { print ''; } - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { print ''; } else { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 64d01817c85..af98356ab18 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -225,22 +225,22 @@ class ActionComm extends CommonObject public $transparency; /** - * @var int (0 By default) + * @var int (0 By default) */ public $priority; /** - * @var int[] Array of user ids + * @var int[] Array of user ids */ public $userassigned = array(); /** - * @var int Id of user owner = fk_user_action into table + * @var int Id of user owner = fk_user_action into table */ public $userownerid; /** - * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. + * @var int Id of user that has done the event. Used only if AGENDA_ENABLE_DONEBY is set. */ public $userdoneid; @@ -429,7 +429,7 @@ class ActionComm extends CommonObject $now = dol_now(); // Check parameters - if (!isset($this->userownerid) || $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) of > 0 + if (!isset($this->userownerid) || (string) $this->userownerid === '') { // $this->userownerid may be 0 (anonymous event) or > 0 dol_syslog("You tried to create an event but mandatory property ownerid was not defined", LOG_WARNING); $this->errors[] = 'ErrorActionCommPropertyUserowneridNotDefined'; return -1; @@ -477,8 +477,8 @@ class ActionComm extends CommonObject $this->elementtype = 'contract'; } - if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead fo array - $tmpid = $this->userassigned; + if (!is_array($this->userassigned) && !empty($this->userassigned)) { // For backward compatibility when userassigned was an int instead of an array + $tmpid = (int) $this->userassigned; $this->userassigned = array(); $this->userassigned[$tmpid] = array('id'=>$tmpid, 'transparency'=>$this->transparency); } @@ -742,6 +742,8 @@ class ActionComm extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1800,8 +1802,8 @@ class ActionComm extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1835,7 +1837,7 @@ class ActionComm extends CommonObject $c->add_type($this, Categorie::TYPE_ACTIONCOMM); } } - return; + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2261,18 +2263,18 @@ class ActionComm extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'actioncomm' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 8c13709b250..c0accf82866 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -210,7 +210,7 @@ class AgendaEvents extends DolibarrApi if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } @@ -249,7 +249,7 @@ class AgendaEvents extends DolibarrApi if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->create && DolibarrApiAccess::$user->id != $request_data['userownerid']) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { throw new RestException(401, "Insufficient rights to create an Agenda Event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index 049b70737e8..c7ab296a2a9 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -217,7 +217,7 @@ class CActionComm $qualified = 1; } // For case module = 'myobject@eventorganization' - $tmparray = preg_split("/@/", $obj->module, -1); + $tmparray = explode("@", $obj->module); if (count($tmparray) > 1 && $tmparray[1] == 'eventorganization' && isModEnabled('eventorganization')) { $qualified = 1; } diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 7ab09e8d891..26db2cd5e6e 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -54,8 +54,8 @@ class ICal /** * Read text file, icalender text file * - * @param string $file File - * @return string + * @param string $file File + * @return string|null Content of remote file read or null if error */ public function read_file($file) { @@ -65,7 +65,7 @@ class ICal $tmpresult = getURLContent($file, 'GET'); if ($tmpresult['http_code'] != 200) { - $file_text = ''; + $file_text = null; $this->error = 'Error: '.$tmpresult['http_code'].' '.$tmpresult['content']; } else { $file_text = preg_replace("/[\r\n]{1,} /", "", $tmpresult['content']); @@ -102,17 +102,40 @@ class ICal /** * Translate Calendar * - * @param string $uri Url + * @param string $uri Url + * @param string $usecachefile Full path of a cache file to use a cache file + * @param string $delaycache Delay in seconds for cache (by default 3600 secondes) * @return array|string */ - public function parse($uri) + public function parse($uri, $usecachefile = '', $delaycache = 3600) { $this->cal = array(); // new empty array $this->event_count = -1; + $this->file_text = null; + + // Save file into a cache + if ($usecachefile) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $datefile = dol_filemtime($usecachefile); + $now = dol_now('gmt'); + //print $datefile.' '.$now.' ...'; + if ($datefile && $datefile > ($now - $delaycache)) { + // We reuse the cache file + $this->file_text = file_get_contents($usecachefile); + } + } // read FILE text - $this->file_text = $this->read_file($uri); + if (is_null($this->file_text)) { + $this->file_text = $this->read_file($uri); + + if ($usecachefile && !is_null($this->file_text)) { + // Save the file content into cache file + file_put_contents($usecachefile, $this->file_text, LOCK_EX); + dolChmod($usecachefile); + } + } $this->file_text = preg_split("[\n]", $this->file_text); @@ -402,7 +425,7 @@ class ICal public function get_event_list() { // phpcs:enable - return (empty($this->cal['VEVENT']) ? '' : $this->cal['VEVENT']); + return (empty($this->cal['VEVENT']) ? array() : $this->cal['VEVENT']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -414,7 +437,7 @@ class ICal public function get_freebusy_list() { // phpcs:enable - return (empty($this->cal['VFREEBUSY']) ? '' : $this->cal['VFREEBUSY']); + return (empty($this->cal['VFREEBUSY']) ? array() : $this->cal['VFREEBUSY']); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 82cc7584c07..0bff7cf5616 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -92,7 +92,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); $permissiontoadd = $usercancreate; @@ -181,7 +181,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -305,7 +305,7 @@ if ($object->id > 0) { $modulepart = 'actions'; - $permissiontoadd = $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create; + $permissiontoadd = $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ab814957e5b..9d84e205f2b 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -49,6 +49,7 @@ if (empty($conf->global->AGENDA_EXT_NB)) { $conf->global->AGENDA_EXT_NB = 5; } $MAXAGENDA = $conf->global->AGENDA_EXT_NB; +$DELAYFORCACHE = 300; // 300 seconds $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); @@ -299,6 +300,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT)) { $enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i; $default = 'AGENDA_EXT_ACTIVEBYDEFAULT_'.$user->id.'_'.$i; $buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i; + if (getDolUserString($source) && getDolUserString($name)) { // Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight' $listofextcals[] = array( @@ -427,36 +429,33 @@ if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') { } // Show navigation bar +$nav = ''; +$nav .= ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); //$nav .= ' '; @@ -495,7 +494,8 @@ print ''; //print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid); //print dol_get_fiche_end(); -$viewmode = ''; +$viewmode = ''; + $viewmode .= ''; // To add a space before the navigation tools $newcardbutton = ''; $newparam = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.((int) $month).'&year='.((int) $tmpforcreatebutton['year']).'&mode='.urlencode($mode); @@ -614,7 +616,7 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $default = ''; } - $s .= '
 
'; + $s .= '
 
'; } } @@ -1009,9 +1011,13 @@ if ($mode == 'show_day') { // Request only leaves for the current selected day $sql .= " AND '".$db->escape($year)."-".$db->escape($month)."-".$db->escape($day)."' BETWEEN x.date_debut AND x.date_fin"; // date_debut and date_fin are date without time } elseif ($mode == 'show_week') { - // TODO: Add filter to reduce database request + // Restrict on current month (we get more, but we will filter later) + $sql .= " AND date_debut < '".dol_get_last_day($year, $month)."'"; + $sql .= " AND date_fin >= '".dol_get_first_day($year, $month)."'"; } elseif ($mode == 'show_month') { - // TODO: Add filter to reduce database request + // Restrict on current month + $sql .= " AND date_debut <= '".dol_get_last_day($year, $month)."'"; + $sql .= " AND date_fin >= '".dol_get_first_day($year, $month)."'"; } $resql = $db->query($sql); @@ -1082,8 +1088,11 @@ if (count($listofextcals)) { $colorcal = $extcal['color']; $buggedfile = $extcal['buggedfile']; + $pathforcachefile = dol_sanitizePathName($conf->user->dir_temp).'/'.dol_sanitizeFileName('extcal_'.$namecal.'_user'.$user->id).'.cache'; + //var_dump($pathforcachefile);exit; + $ical = new ICal(); - $ical->parse($url); + $ical->parse($url, $pathforcachefile, $DELAYFORCACHE); // After this $ical->cal['VEVENT'] contains array of events, $ical->cal['DAYLIGHT'] contains daylight info, $ical->cal['STANDARD'] contains non daylight info, ... //var_dump($ical->cal); exit; @@ -1703,7 +1712,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $curtime = dol_mktime(0, 0, 0, $month, $day, $year); $urltoshow = DOL_URL_ROOT.'/comm/action/index.php?mode=show_day&day='.str_pad($day, 2, "0", STR_PAD_LEFT).'&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year.$newparam; $urltocreate = ''; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { + if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$year; $hourminsec = '100000'; $urltocreate = DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $year, $month, $day).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); @@ -1722,7 +1731,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } print '
'; print '
'; - if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { + if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { print ''; // Explicit link, usefull for nojs interfaces print img_picto($langs->trans("NewAction"), 'edit_add.png'); print ''; @@ -1849,7 +1858,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $cssclass .= ' movable cursormove'; } } else { - if ($user->rights->agenda->allactions->create || + if ($user->hasRight('agenda', 'allactions', 'create') || (($event->authorid == $user->id || $event->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { $cssclass .= " movable cursormove"; } else { @@ -1936,7 +1945,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } $listofusertoshow = ''; - $listofusertoshow .= '
'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + $listofusertoshow .= '
'.$cacheusers[$tmpid]->getNomUrl(-1, '', 0, 0, 0, 0, '', 'paddingright valignmiddle'); print $listofusertoshow; } else { // Other calendar // Picto @@ -2011,7 +2020,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $cacheusers[$tmpid] = $newuser; } - $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'paddingright valigntextbottom'); + $listofusertoshow .= $cacheusers[$tmpid]->getNomUrl(-3, '', 0, 0, 0, 0, '', 'valignmiddle'); } print $titletoshow; @@ -2039,7 +2048,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } } if (!empty($contact_id) && $contact_id > 0) { - if (!is_object($cachecontacts[$contact_id])) { + if (empty($cachecontacts[$contact_id]) || !is_object($cachecontacts[$contact_id])) { $contact = new Contact($db); $contact->fetch($contact_id); $cachecontacts[$contact_id] = $contact; @@ -2061,7 +2070,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $linerelatedto .= dolGetElementUrl($event->fk_element, $event->elementtype, 1); } if ($linerelatedto) { - print '
'.$linerelatedto; + print ' '.$linerelatedto; } } diff --git a/htdocs/comm/action/info.php b/htdocs/comm/action/info.php index d4588223b26..816fef8e395 100644 --- a/htdocs/comm/action/info.php +++ b/htdocs/comm/action/info.php @@ -53,7 +53,7 @@ if ($user->socid && $socid) { $result = restrictedArea($user, 'societe', $socid); } -$usercancreate = $user->rights->agenda->allactions->create || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); +$usercancreate = $user->hasRight('agenda', 'allactions', 'create') || (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create); /* @@ -109,7 +109,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 5eb538d4e62..a0176ca18b0 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -33,18 +33,22 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + // Load translation files required by the page $langs->loadLangs(array("users", "companies", "agenda", "commercial", "other", "orders", "bills")); -$action = GETPOST('action', 'aZ09'); +// Get Parameters +$action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search -$optioncss = GETPOST('optioncss', 'alpha'); -$toselect = GETPOST('toselect', 'array'); -$confirm = GETPOST('confirm', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); + $disabledefaultvalues = GETPOST('disabledefaultvalues', 'int'); @@ -70,6 +74,7 @@ if (GETPOST('search_actioncode', 'array')) { $actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : ((empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) || $disabledefaultvalues) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } +// Search Fields $search_id = GETPOST('search_id', 'alpha'); $search_title = GETPOST('search_title', 'alpha'); $search_note = GETPOST('search_note', 'alpha'); @@ -106,6 +111,7 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { $filtert = $user->id; } +// Pagination parameters $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -600,7 +606,7 @@ $num = $db->num_rows($resql); $arrayofselected = is_array($toselect) ? $toselect : array(); // Local calendar -$newtitle = '
'; +$newtitle = '
'; $newtitle .= ' '.$langs->trans("LocalAgenda").'   '; $newtitle .= '
'; //$newtitle=$langs->trans($title); @@ -700,7 +706,7 @@ $url = DOL_URL_ROOT.'/comm/action/card.php?action=create'; $url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec; $url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')); -$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create); +$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')); $param .= '&mode='.$mode; @@ -795,9 +801,8 @@ if (!empty($arrayfields['a.tms']['checked'])) { print ''; } if (!empty($arrayfields['a.percent']['checked'])) { - print ''; - $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125'); - print ajax_combobox('selectsearch_status'); + print ''; + $formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'search_status width100 onrightofpage'); print ''; } // Action column @@ -887,6 +892,7 @@ print "\n"; $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; +$today_start_time = dol_mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now)); require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php'; $caction = new CActionComm($db); @@ -899,6 +905,7 @@ $i = 0; //$savnbfield = $totalarray['nbfield']; //$totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); +$cache_user_list = array(); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { @@ -933,7 +940,55 @@ while ($i < $imaxinloop) { $actionstatic->fetchResources(); } - print ''; + // cache of user list (owners) + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $userstatic = new User($db); + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + + // get event style for user owner + $event_owner_style = ''; + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if ($cache_user_list[$obj->fk_user_action]->color != '') { + $event_owner_style .= 'border-left: #' . $cache_user_list[$obj->fk_user_action]->color . ' 5px solid;'; + } + + // get event style for start and end date + $event_more_class = ''; + $event_start_date_css = ''; + $event_end_date_css = ''; + $event_start_date_time = $actionstatic->datep; + if ($event_start_date_time > $now) { + // future event + $event_more_class = 'event-future'; + $event_start_date_css = $event_end_date_css = $event_more_class; + } else { + if ($obj->fulldayevent == 1) { + $today_start_date_time = $today_start_time; + } else { + $today_start_date_time = $now; + } + + // check event end date + $event_end_date_time = $db->jdate($obj->dp2); + if ($event_end_date_time != null && $event_end_date_time < $today_start_date_time) { + // past event + $event_more_class = 'event-past'; + } elseif ($event_end_date_time == null && $event_start_date_time < $today_start_date_time) { + // past event + $event_more_class = 'event-past'; + } else { + // current event + $event_more_class = 'event-current'; + } + $event_start_date_css = $event_end_date_css = $event_more_class; + } + $event_start_date_css = $event_end_date_css = $event_more_class; + + print ''; // Action column if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; @@ -955,10 +1010,16 @@ while ($i < $imaxinloop) { // User owner if (!empty($arrayfields['owner']['checked'])) { - print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. - if ($obj->fk_user_action > 0) { - $userstatic->fetch($obj->fk_user_action); - print $userstatic->getNomUrl(-1); + print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $userstatic = new User($db); + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + if (isset($cache_user_list[$obj->fk_user_action])) { + print $cache_user_list[$obj->fk_user_action]->getNomUrl(-1); } else { print ' '; } @@ -1006,13 +1067,14 @@ while ($i < $imaxinloop) { // Start date if (!empty($arrayfields['a.datep']['checked'])) { - print ''; + print ''; if (empty($obj->fulldayevent)) { print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); print dol_print_date($db->jdate($obj->dp), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } + print ''; $late = 0; if ($actionstatic->hasDelay() && $actionstatic->percentage >= 0 && $actionstatic->percentage < 100 ) { $late = 1; @@ -1025,13 +1087,14 @@ while ($i < $imaxinloop) { // End date if (!empty($arrayfields['a.datep2']['checked'])) { - print ''; + print ''; if (empty($obj->fulldayevent)) { print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuserrel'); } else { $tzforfullday = getDolGlobalString('MAIN_STORE_FULL_EVENT_IN_GMT'); print dol_print_date($db->jdate($obj->dp2), $formatToUse, ($tzforfullday ? $tzforfullday : 'tzuserrel')); } + print ''; print ''; } diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 61092df5665..9d3bd0044e4 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -63,23 +63,19 @@ if (empty($filtert) && empty($conf->global->AGENDA_ALL_CALENDARS)) { // Sorting $sortfield = GETPOST('sortfield', 'aZ09comma'); -if (!$sortfield) { - $sortfield = "a.datec"; -} - $sortorder = GETPOST('sortorder', 'aZ09comma'); -if (!$sortorder) { - $sortorder = "ASC"; -} - -// Page $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; - +if (!$sortorder) { + $sortorder = "ASC"; +} +if (!$sortfield) { + $sortfield = "a.datec"; +} // Security check @@ -110,14 +106,14 @@ $month = GETPOST("month", "int") ? GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ? GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ? GETPOST("day", "int") : date("d"); $pid = GETPOSTISSET("search_projectid") ? GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('search_actioncode', 'array')) { - $actioncode = GETPOST('search_actioncode', 'array', 3); +if (GETPOST('search_actioncode', 'array:aZ09')) { + $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); if (!count($actioncode)) { $actioncode = '0'; } @@ -321,7 +317,7 @@ if ($pid) { if ($type) { $param .= "&search_type=".urlencode($type); } -if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month' || $mode != 'show_peruser') { +if ($mode != 'show_pertype') { $param .= '&mode='.urlencode($mode); } if ($begin_h != '') { @@ -356,24 +352,28 @@ $next_year = $year + 1; $next_month = $month; $next_day = $day; -// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) +// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1 +// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; -//print dol_print_date($firstdaytoshow,'dayhour'); -//print dol_print_date($lastdaytoshow,'dayhour'); +//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); +//print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; -$nav = "".img_previous($langs->trans("Previous"))."\n"; +// Show navigation bar +$nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; @@ -477,9 +477,9 @@ if (empty($reshook)) { $viewmode = $hookmanager->resPrint; } - +$newparam = ''; $newcardbutton = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year']; @@ -592,12 +592,12 @@ if ($filtert > 0 || $usergroup > 0) { if ($mode == 'show_day') { $sql .= " AND ("; $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= " OR "; $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; - $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')"; + $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= " OR "; - $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'"; + $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year, 'tzuserrel'))."'"; $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year, 'tzuserrel'))."')"; $sql .= ')'; } else { @@ -619,12 +619,14 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1') { +if ($status === 'na') { + // Not applicable $sql .= " AND a.percent = -1"; -} // Not applicable +} if ($status == '50') { + // Running already started $sql .= " AND (a.percent > 0 AND a.percent < 100)"; -} // Running already started +} if ($status == 'done' || $status == '100') { $sql .= " AND (a.percent = 100)"; } @@ -788,8 +790,9 @@ echo ''; //print "begin_d=".$begin_d." end_d=".$end_d; +echo '
'; -echo ''; +echo '
'; echo ''; echo ''; @@ -847,10 +850,11 @@ foreach ($typeofevents as $typeofevent) { // Show days of the current week $curtime = dol_time_plus_duree($firstdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime, 'fast'); - $tmpday = $tmparray['mday']; - $tmpmonth = $tmparray['mon']; - $tmpyear = $tmparray['year']; + // $curtime is a gmt time, but we want the day, month, year in user TZ + $tmpday = dol_print_date($curtime, "%d", "tzuserrel"); + $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel"); + $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel"); + //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); $style = 'cal_current_month'; if ($iter_day == 6) { @@ -875,6 +879,8 @@ foreach ($typeofevents as $typeofevent) { echo "
\n"; echo "
"; +echo '
'; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { $langs->load("commercial"); print '
'.$langs->trans("Legend").':
'; @@ -984,14 +990,14 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { - $annee = dol_print_date($daykey, '%Y'); - $mois = dol_print_date($daykey, '%m'); - $jour = dol_print_date($daykey, '%d'); + $annee = dol_print_date($daykey, '%Y', 'tzuserrel'); + $mois = dol_print_date($daykey, '%m', 'tzuserrel'); + $jour = dol_print_date($daykey, '%d', 'tzuserrel'); - if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ? + if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ? // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { - //print $daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; + //print 'daykey='.$daykey.' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; //var_dump($event); $keysofuserassigned = array_keys($event->userassigned); @@ -1173,7 +1179,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } } - // Now output $casesX + // Now output $casesX from start hour to end hour for ($h = $begin_h; $h < $end_h; $h++) { $color1 = ''; $color2 = ''; $style1 = ''; $style2 = ''; @@ -1214,11 +1220,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } } - $ids1 = ''; $ids2 = ''; - if (count($cases1[$h]) && array_keys($cases1[$h])) { + $ids1 = ''; + $ids2 = ''; + if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) && array_keys($cases1[$h])) { $ids1 = join(',', array_keys($cases1[$h])); } - if (count($cases2[$h]) && array_keys($cases2[$h])) { + if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) && array_keys($cases2[$h])) { $ids2 = join(',', array_keys($cases2[$h])); } @@ -1227,7 +1234,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s } else { echo ''; } - if (count($cases1[$h]) == 1) { // only 1 event + if (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) == 1) { // only 1 event $output = array_slice($cases1[$h], 0, 1); $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); if ($output[0]['string']) { @@ -1236,12 +1243,12 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s if ($output[0]['color']) { $color1 = $output[0]['color']; } - } elseif (count($cases1[$h]) > 1) { + } elseif (!empty($cases1[$h]) && is_array($cases1[$h]) && count($cases1[$h]) > 1) { $title1 = $langs->trans("Ref").' '.$ids1.($title1 ? ' - '.$title1 : ''); $color1 = '222222'; } - if (count($cases2[$h]) == 1) { // only 1 event + if (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) == 1) { // only 1 event $output = array_slice($cases2[$h], 0, 1); $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); if ($output[0]['string']) { @@ -1250,7 +1257,7 @@ function show_day_events_pertype($username, $day, $month, $year, $monthshown, $s if ($output[0]['color']) { $color2 = $output[0]['color']; } - } elseif (count($cases2[$h]) > 1) { + } elseif (!empty($cases2[$h]) && is_array($cases2[$h]) && count($cases2[$h]) > 1) { $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; } diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 5c5ef948c30..340efbf30a8 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -349,27 +349,30 @@ $next_year = $next['year']; $next_month = $next['month']; $next_day = $next['day']; -// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1) -$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'gmt'); - +// Define firstdaytoshow and lastdaytoshow. Warning: lastdaytoshow is last second to show + 1 +// $firstdaytoshow and lastdaytoshow become a gmt dates to use to search/compare because first_xxx are in tz idea and we used tzuserrel +$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year, 'tzuserrel'); $nb_weeks_to_show = (!empty($conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER)) ? ((int) $conf->global->AGENDA_NB_WEEKS_IN_VIEW_PER_USER * 7) : 7; $lastdaytoshow = dol_time_plus_duree($firstdaytoshow, $nb_weeks_to_show, 'd'); //print $firstday.'-'.$first_month.'-'.$first_year; -//print dol_print_date($firstdaytoshow,'dayhour'); -//print dol_print_date($lastdaytoshow,'dayhour'); +//print dol_print_date($firstdaytoshow, 'dayhour', 'gmt'); +//print dol_print_date($lastdaytoshow,'dayhour', 'gmt'); $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year, 'gmt')); $tmpday = $first_day; $picto = 'calendarweek'; -$nav = "trans("Previous"))."\">   \n"; +// Show navigation bar +$nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; @@ -475,7 +478,7 @@ if (empty($reshook)) { $newparam = ''; $newcardbutton = ''; -if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create) { +if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allactions', 'create')) { $tmpforcreatebutton = dol_getdate(dol_now(), true); $newparam .= '&month='.urlencode(str_pad($month, 2, "0", STR_PAD_LEFT)).'&year='.urlencode($tmpforcreatebutton['year']); @@ -628,7 +631,7 @@ if ($type) { if ($status == '0') { $sql .= " AND a.percent = 0"; } -if ($status == '-1' || $status == 'na') { +if ($status === 'na') { // Not applicable $sql .= " AND a.percent = -1"; } @@ -655,7 +658,7 @@ if ($filtert > 0 || $usergroup > 0) { } // Sort on date $sql .= ' ORDER BY fk_user_action, datep'; //fk_user_action - +//print $sql; dol_syslog("comm/action/peruser.php", LOG_DEBUG); $resql = $db->query($sql); @@ -665,6 +668,7 @@ if ($resql) { $i = 0; while ($i < $num) { $obj = $db->fetch_object($resql); + //print $obj->fk_user_action.' '.$obj->id."
"; // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->code == 'AC_OTH_AUTO') { @@ -675,6 +679,7 @@ if ($resql) { $datep = $db->jdate($obj->datep); $datep2 = $db->jdate($obj->datep2); + // Create a new object action $event = new ActionComm($db); $event->id = $obj->id; @@ -717,13 +722,15 @@ if ($resql) { } } + //print '
'.$i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' '.dol_print_date($firstdaytoshow, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').' '.dol_print_date($lastdaytoshow, 'dayhour').'
'."\n"; + // Check values if ($event->date_end_in_calendar < $firstdaytoshow || $event->date_start_in_calendar >= $lastdaytoshow) { // This record is out of visible range unset($event); } else { - //print $i.' - '.dol_print_date($this->date_start_in_calendar, 'dayhour').' - '.dol_print_date($this->date_end_in_calendar, 'dayhour').'
'."\n"; + //print $i.' - eventid='.$event->id.' '.dol_print_date($event->date_start_in_calendar, 'dayhour').' - '.dol_print_date($event->date_end_in_calendar, 'dayhour').'
'."\n"; $event->fetch_userassigned(); // This load $event->userassigned if ($event->date_start_in_calendar < $firstdaytoshow) { @@ -744,7 +751,7 @@ if ($resql) { $loop = true; $j = 0; $daykey = dol_mktime(0, 0, 0, $mois, $jour, $annee, 'gmt'); do { - //if ($event->id==408) print 'daykey='.$daykey.' '.$event->datep.' '.$event->datef.'
'; + //print 'Add event into eventarray for daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$event->id.' '.$event->datep.' '.$event->datef.'
'; $eventarray[$daykey][] = $event; $j++; @@ -802,6 +809,7 @@ echo ''; $currentdaytoshow = $firstdaytoshow; echo '
'; +//print dol_print_date($currentdaytoshow, 'dayhour', 'gmt'); while ($currentdaytoshow < $lastdaytoshow) { echo ''; @@ -853,9 +861,9 @@ while ($currentdaytoshow < $lastdaytoshow) { echo ''.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).''; print "
"; if ($i) { - print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day'); + print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day', 'tzuserrel'); } else { - print dol_print_date($currentdaytoshow, 'day'); + print dol_print_date($currentdaytoshow, 'day', 'tzuserrel'); } echo "\n"; $i++; @@ -940,26 +948,6 @@ while ($currentdaytoshow < $lastdaytoshow) { $usernames[] = $tmpuser; } - /* - if ($filtert > 0) - { - $tmpuser = new User($db); - $tmpuser->fetch($filtert); - $usernames[] = $tmpuser; - } - else if ($usergroup) - { - $tmpgroup = new UserGroup($db); - $tmpgroup->fetch($usergroup); - $usernames = $tmpgroup->listUsersForGroup(); - } - else - { - $tmpgroup = new UserGroup($db); - //$tmpgroup->fetch($usergroup); No fetch, we want all users for all groups - $usernames = $tmpgroup->listUsersForGroup(); - }*/ - // Load array of colors by type $colorsbytype = array(); $labelbytype = array(); @@ -976,6 +964,8 @@ while ($currentdaytoshow < $lastdaytoshow) { $showheader = true; $var = false; foreach ($usernames as $username) { + //if ($username->login != 'admin') continue; + $var = !$var; echo ""; echo ''; + print ''; + print dol_get_fiche_end(); diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index e5e1f584f5e..6a753a24cdb 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -686,6 +686,11 @@ class Shipments extends DolibarrApi if (!empty($object->lines) && is_array($object->lines)) { foreach ($object->lines as $line) { + if (is_array($line->detail_batch)) { + foreach ($line->detail_batch as $keytmp2 => $valtmp2) { + unset($line->detail_batch[$keytmp2]->db); + } + } unset($line->tva_tx); unset($line->vat_src_code); unset($line->total_ht); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 0b8668a6c1a..dd6dfee55b1 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1911,23 +1911,6 @@ class Expedition extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new Commande($this->db); $order->initAsSpecimen(); @@ -1940,7 +1923,7 @@ class Expedition extends CommonObject $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; - $this->date_delivery = $now; + $this->date_delivery = $now + 24 * 3600; $this->date_expedition = $now + 24 * 3600; $this->entrepot_id = 0; @@ -2450,18 +2433,18 @@ class Expedition extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'expedition' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/expedition/class/expeditionlinebatch.class.php b/htdocs/expedition/class/expeditionlinebatch.class.php index 5d99d1c7a74..ab1d9123830 100644 --- a/htdocs/expedition/class/expeditionlinebatch.class.php +++ b/htdocs/expedition/class/expeditionlinebatch.class.php @@ -194,7 +194,7 @@ class ExpeditionLineBatch extends CommonObject } $sql .= " WHERE fk_expeditiondet=".(int) $id_line_expdet; - dol_syslog(__METHOD__."", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 48822121fa3..a3bcd1a2ef0 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -158,7 +158,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index 517c1cea8d2..c0725bd5fe1 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -150,7 +150,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 14544087647..26cafe14b5d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -78,6 +78,7 @@ $search_sale = GETPOST('search_sale', 'int'); $search_categ_cus = GETPOST("search_categ_cus", 'int'); $search_product_category = GETPOST('search_product_category', 'int'); $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -489,6 +490,9 @@ $arrayofselected = is_array($toselect) ? $toselect : array(); $expedition = new Expedition($db); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -577,7 +581,10 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); // $url = DOL_URL_ROOT.'/expedition/card.php?action=create'; // if (!empty($socid)) $url .= '&socid='.$socid; // $newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', $url, '', $user->rights->expedition->creer); -$newcardbutton = dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2', '', $user->rights->expedition->creer); $i = 0; print ''."\n"; @@ -589,6 +596,7 @@ print ''; print ''; print ''; +print ''; print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'dolly', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -786,8 +794,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; } // Status billed @@ -892,213 +900,227 @@ while ($i < min($num, $limit)) { $object = new Expedition($db); $object->fetch($obj->rowid); - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - // Ref - if (!empty($arrayfields['e.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['e.ref_customer']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Weight - if (!empty($arrayfields['e.weight']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery planed - if (!empty($arrayfields['e.date_delivery']['checked'])) { - print '\n"; - } - if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { - // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print ''; - } - // Tracking number - if (!empty($arrayfields['e.tracking_number']['checked'])) { - $shipment->getUrlTrackingStatus($obj->tracking_number); - print '\n"; - //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number); - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { - $shipment->fetchObjectLinked($shipment->id, $shipment->element); - $receiving = ''; - if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { - $receiving = reset($shipment->linkedObjects['delivery']); - } - - if (!empty($arrayfields['l.ref']['checked'])) { - // Ref - print ''; } - - if (!empty($arrayfields['l.date_delivery']['checked'])) { - // Date received - print ''."\n"; - } - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['e.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['e.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['e.billed']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Ref customer + if (!empty($arrayfields['e.ref_customer']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Weight + if (!empty($arrayfields['e.weight']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery planed + if (!empty($arrayfields['e.date_delivery']['checked'])) { + print '\n"; + } + if (!empty($arrayfields['e.fk_shipping_method']['checked'])) { + // Get code using getLabelFromKey + $code=$langs->getLabelFromKey($db, $shipment->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print ''; + } + // Tracking number + if (!empty($arrayfields['e.tracking_number']['checked'])) { + $shipment->getUrlTrackingStatus($obj->tracking_number); + print '\n"; + //print $form->editfieldval("TrackingNumber", 'tracking_number', $obj->tracking_url, $obj, $user->rights->expedition->creer, 'string', $obj->tracking_number); + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { + $shipment->fetchObjectLinked($shipment->id, $shipment->element); + $receiving = ''; + if (is_array($shipment->linkedObjects['delivery']) && count($shipment->linkedObjects['delivery']) > 0) { + $receiving = reset($shipment->linkedObjects['delivery']); + } + + if (!empty($arrayfields['l.ref']['checked'])) { + // Ref + print ''; + } + + if (!empty($arrayfields['l.date_delivery']['checked'])) { + // Date received + print ''."\n"; + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['e.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['e.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['e.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['e.billed']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 4401af0b20c..fcf191c4915 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -119,7 +119,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 9394269a03a..b4a89c5be30 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -296,7 +296,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); @@ -329,7 +329,7 @@ if ($id > 0 || !empty($ref)) { $filtercreditnote = "fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')"; } - print ''; } print '
'; @@ -993,10 +983,10 @@ while ($currentdaytoshow < $lastdaytoshow) { // Show days of the current week $curtime = dol_time_plus_duree($currentdaytoshow, $iter_day, 'd'); - $tmparray = dol_getdate($curtime, 'fast'); - $tmpday = $tmparray['mday']; - $tmpmonth = $tmparray['mon']; - $tmpyear = $tmparray['year']; + // $curtime is a gmt time, but we want the day, month, year in user TZ + $tmpday = dol_print_date($curtime, "%d", "tzuserrel"); + $tmpmonth = dol_print_date($curtime, "%m", "tzuserrel"); + $tmpyear = dol_print_date($curtime, "%Y", "tzuserrel"); //var_dump($curtime.' '.$tmpday.' '.$tmpmonth.' '.$tmpyear); $style = 'cal_current_month'; @@ -1134,17 +1124,22 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & //if ($username->id && $day==1) { //var_dump($eventarray); //} + //var_dump("------ username=".$username->login." for day=".$day); // We are in a particular day for $username, now we scan all events foreach ($eventarray as $daykey => $notused) { - $annee = dol_print_date($daykey, '%Y'); - $mois = dol_print_date($daykey, '%m'); - $jour = dol_print_date($daykey, '%d'); + $annee = dol_print_date($daykey, '%Y', 'tzuserrel'); + $mois = dol_print_date($daykey, '%m', 'tzuserrel'); + $jour = dol_print_date($daykey, '%d', 'tzuserrel'); + //var_dump("daykey=$daykey day=$day jour=$jour, month=$month mois=$mois, year=$year annee=$annee"); + + + if ($day == $jour && (int) $month == (int) $mois && $year == $annee) { // Is it the day we are looking for when calling function ? + //var_dump("day=$day jour=$jour month=$month mois=$mois year=$year annee=$annee"); - if ($day == $jour && $month == $mois && $year == $annee) { // Is it the day we are looking for when calling function ? // Scan all event for this date foreach ($eventarray[$daykey] as $index => $event) { - //print $daykey.' '.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> '.$event->id.' '.$index.' '.$annee.'-'.$mois.'-'.$jour."
\n"; + //print 'daykey='.$daykey.'='.dol_print_date($daykey, 'dayhour', 'gmt').' '.$year.'-'.$month.'-'.$day.' -> This event: '.$event->id.' '.$index.' is open for this daykey '.$annee.'-'.$mois.'-'.$jour."
\n"; //var_dump($event); $keysofuserassigned = array_keys($event->userassigned); @@ -1353,7 +1348,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & } } - // Now output $casesX + // Now output $casesX from start hour to end hour for ($h = $begin_h; $h < $end_h; $h++) { $color1 = ''; $color2 = ''; $style1 = ''; $style2 = ''; @@ -1435,7 +1430,7 @@ function show_day_events2($username, $day, $month, $year, $monthshown, $style, & $title2 = $langs->trans("Ref").' '.$ids2.($title2 ? ' - '.$title2 : ''); $color2 = '222222'; } - print ''; + print '
'; print '
id > 0) { print "
"; + print '
'; + // Prospection level and status if ($object->client == 2 || $object->client == 3) { - print '
'; - print '
'; print ''; // Level of prospection print ''; - print ''; } + // TODO Show also lines ordered but not delivered + + print "
'; - print ''; - print '
'; - print '
'; + print ''; print "
'; print $langs->trans('ProspectLevel'); print ''; if ($action != 'editlevel' && $user->rights->societe->creer) { @@ -683,10 +683,11 @@ if ($object->id > 0) { } print '
"; - } - print '
'; - print '
'; + print '
'; + } else { + print '

'; + } $boxstat = ''; @@ -695,7 +696,7 @@ if ($object->id > 0) { // Lien recap $boxstat .= '
'; - $boxstat .= ''; + $boxstat .= '
'; $boxstat .= ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Status - print ''; + print ''; // Amount paid print ''; print "\n"; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index e9c2b82ae22..866cd25eef1 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -58,7 +58,7 @@ $form = new Form($db); llxHeader(); -print load_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg); +print load_fiche_titre($langs->trans("StatisticsOfDonations"), $mesg); dol_mkdir($dir); @@ -72,9 +72,9 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); if (empty($user->rights->societe->client->voir) || $user->socid) { - $filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png'; + $filenamenb = $dir.'/donationnbinyear-'.$user->id.'-'.$year.'.png'; } else { - $filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/donationnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); @@ -91,11 +91,11 @@ if (!$mesg) { $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); $px1->SetWidth($WIDTH); $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfSendings")); + $px1->SetYLabel($langs->trans("NbOfDonations")); $px1->SetShading(3); $px1->SetHorizTickIncrement(1); $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfShipmentsByMonth")); + $px1->SetTitle($langs->trans("NumberOfDonationsByMonth")); $px1->draw($filenamenb, $fileurlnb); } @@ -245,7 +245,7 @@ print '
'; print '
'; if (isModEnabled("propal") && $user->rights->propal->lire) { @@ -1418,7 +1419,7 @@ if ($object->id > 0) { $sql .= ', f.total_tva'; $sql .= ', f.total_ttc'; $sql .= ', f.entity'; - $sql .= ', f.datef as df, f.datec as dc, f.paye as paye, f.fk_statut as status'; + $sql .= ', f.datef as df, f.date_lim_reglement as dl, f.datec as dc, f.paye as paye, f.fk_statut as status'; $sql .= ', s.nom, s.rowid as socid'; $sql .= ', SUM(pf.amount) as am'; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; @@ -1426,7 +1427,7 @@ if ($object->id > 0) { $sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id); $sql .= " AND f.entity IN (".getEntity('invoice').")"; $sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,'; - $sql .= ' f.entity, f.datef, f.datec, f.paye, f.fk_statut,'; + $sql .= ' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,'; $sql .= ' s.nom, s.rowid'; $sql .= " ORDER BY f.datef DESC, f.datec DESC"; @@ -1440,7 +1441,7 @@ if ($object->id > 0) { print ''; print ''; - print ''; - echo ''; + echo ''; echo ''; echo ''; echo ''; } // Bordereau diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index a923f3a0829..15cb5123e0f 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -515,6 +515,7 @@ if ($action == 'create') { // Show fields of bank account $sizecss = ''; foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; $sizecss = 'minwidth100'; @@ -534,7 +535,7 @@ if ($action == 'create') { } print ''; - print ''; + print ''; print ''; } $ibankey = FormBank::getIBANLabel($object); @@ -545,10 +546,10 @@ if ($action == 'create') { // IBAN print ''; - print ''; + print ''; print ''; - print ''; + print ''; if (isModEnabled('paymentbybanktransfer')) { print ''; @@ -559,7 +560,7 @@ if ($action == 'create') { print '"; print ''; @@ -730,6 +731,7 @@ if ($action == 'create') { // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $content = $object->code_banque; } elseif ($val == 'DeskCode') { @@ -1034,31 +1036,32 @@ if ($action == 'create') { // If bank account print ''; - print ''; + print ''; print ''; // Show fields of bank account foreach ($object->getFieldsToShow() as $val) { + $content = ''; if ($val == 'BankCode') { $name = 'code_banque'; - $size = 8; + $css = 'with100'; $content = $object->code_banque; } elseif ($val == 'DeskCode') { $name = 'code_guichet'; - $size = 8; + $css = 'with100'; $content = $object->code_guichet; } elseif ($val == 'BankAccountNumber') { $name = 'number'; - $size = 18; + $css = 'with200'; $content = $object->number; } elseif ($val == 'BankAccountNumberKey') { $name = 'cle_rib'; - $size = 3; + $css = 'with50'; $content = $object->cle_rib; } print ''; - print ''; + print ''; print ''; } diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index a73fd2b5f2c..e144677832f 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1060,8 +1060,8 @@ class Account extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1077,8 +1077,6 @@ class Account extends CommonObject */ public function delete(User $user = null) { - global $conf; - $error = 0; $this->db->begin(); @@ -1096,8 +1094,8 @@ class Account extends CommonObject } if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_account"; - $sql .= " WHERE rowid = ".((int) $this->rowid); + $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; + $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $result = $this->db->query($sql); @@ -1748,6 +1746,40 @@ class Account extends CommonObject return false; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + if (property_exists($this, 'type_lib')) { + $return .= '
'.substr($this->type_lib[$this->type], 0, 24).'...'; + } + if (method_exists($this, 'solde')) { + $return .= '
'; + $return .= ''.$langs->trans("Balance").' : '.price($this->solde(1), 0, $langs, 1, -1, -1, $this->currency_code).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index c9886a176f0..537c7c9acb6 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -122,8 +122,8 @@ class BankAccounts extends DolibarrApi /** * Get account by ID. * - * @param int $id ID of account - * @return array Account object + * @param int $id ID of account + * @return Object Object with cleaned properties * * @throws RestException */ @@ -313,9 +313,9 @@ class BankAccounts extends DolibarrApi /** * Update account * - * @param int $id ID of account - * @param array $request_data data - * @return int + * @param int $id ID of account + * @param array $request_data data + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php index 1795704d4ff..581bc5fd1da 100644 --- a/htdocs/compta/bank/class/bankcateg.class.php +++ b/htdocs/compta/bank/class/bankcateg.class.php @@ -80,7 +80,7 @@ class BankCateg // extends CommonObject $sql .= "label"; $sql .= ", entity"; $sql .= ") VALUES ("; - $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").""; + $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'"); $sql .= ", ".((int) $conf->entity); $sql .= ")"; @@ -169,7 +169,7 @@ class BankCateg // extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."bank_categ SET"; - $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").""; + $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $sql .= " AND entity = ".$conf->entity; diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 3d07c280559..d5888e0e7a1 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -768,4 +768,42 @@ class PaymentVarious extends CommonObject } return 0; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_bank')) { + $return .= ' | '.$this->fk_bank.''; + } + if (property_exists($this, 'datep')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->datep), 'day').''; + } + if (property_exists($this, 'type_payment') && !empty($this->type_payment)) { + $return .= '
'.$langs->trans("Payment", $this->type_payment).' : '.$this->type_payment.''; + } + if (property_exists($this, 'accountancy_code')) { + $return .= '
'.$langs->trans("Account").' : '.$this->accountancy_code.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Debit").' : '.price($this->amount).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index c11e13f1e71..490107e4893 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -458,7 +458,7 @@ if ($result < 0) { if ($day > ($max + 86400)) { $datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph } else { - $datas[$i] = 0 + $solde + $subtotal; + $datas[$i] = $solde + $subtotal; } $datamin[$i] = $object->min_desired; $dataall[$i] = $object->min_allowed; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 38b666cc2ef..2a0995af009 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -52,6 +52,7 @@ $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 +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -305,6 +306,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -365,8 +369,13 @@ print ''; print ''; print ''; +print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); + +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1); @@ -483,7 +492,7 @@ if (!empty($arrayfields['b.tms']['checked'])) { } // Status if (!empty($arrayfields['b.clos']['checked'])) { - print '
'; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - print ''; - } - // Ref - if (!empty($arrayfields['b.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['b.label']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account type - if (!empty($arrayfields['accountype']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Number - if (!empty($arrayfields['b.number']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account number - if (!empty($arrayfields['b.account_number']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accountancy journal - if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - } else { - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency - if (!empty($arrayfields['b.currency_code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Transactions to reconcile - if (!empty($arrayfields['toreconcile']['checked'])) { - $conciliate = $objecttmp->canBeConciliated(); - - $labeltoshow = ''; - if ($conciliate == -2) { - $labeltoshow = $langs->trans("CashAccount"); - } elseif ($conciliate == -3) { - $labeltoshow = $langs->trans("Closed"); - } elseif (empty($objecttmp->rappro)) { - $labeltoshow = $langs->trans("ConciliationDisabled"); } - print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account type + if (!empty($arrayfields['accountype']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Number + if (!empty($arrayfields['b.number']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account number + if (!empty($arrayfields['b.account_number']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accountancy journal + if (!empty($arrayfields['b.fk_accountancy_journal']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency + if (!empty($arrayfields['b.currency_code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Transactions to reconcile + if (!empty($arrayfields['toreconcile']['checked'])) { + $conciliate = $objecttmp->canBeConciliated(); + + $labeltoshow = ''; + if ($conciliate == -2) { + $labeltoshow = $langs->trans("CashAccount"); + } elseif ($conciliate == -3) { + $labeltoshow = $langs->trans("Closed"); + } elseif (empty($objecttmp->rappro)) { + $labeltoshow = $langs->trans("ConciliationDisabled"); + } + + print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Extra fields - if (is_array($objecttmp->array_options)) { - $obj = new stdClass(); - foreach ($objecttmp->array_options as $k => $v) { - $obj->$k = $v; - } - } - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['b.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['b.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status - if (!empty($arrayfields['b.clos']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Balance - if (!empty($arrayfields['balance']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'balance'; - } - $totalarray['val']['balance'] += $solde; - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print ''; + // Extra fields + if (is_array($objecttmp->array_options)) { + $obj = new stdClass(); + foreach ($objecttmp->array_options as $k => $v) { + $obj->$k = $v; + } + } + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $objecttmp, $action); // Note that $action and $objecttmpect may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['b.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['b.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - if (empty($total[$objecttmp->currency_code])) { - $total[$objecttmp->currency_code] = $solde; - } else { - $total[$objecttmp->currency_code] += $solde; + // Status + if (!empty($arrayfields['b.clos']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Balance + if (!empty($arrayfields['balance']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'balance'; + } + $totalarray['val']['balance'] += $solde; + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''; + + if (empty($total[$objecttmp->currency_code])) { + $total[$objecttmp->currency_code] = $solde; + } else { + $total[$objecttmp->currency_code] += $solde; + } } - $i++; } diff --git a/htdocs/compta/bank/treso.php b/htdocs/compta/bank/treso.php index d3e573f21bf..e75402ba429 100644 --- a/htdocs/compta/bank/treso.php +++ b/htdocs/compta/bank/treso.php @@ -353,10 +353,10 @@ if (GETPOST("account") || GETPOST("ref")) { print ""; if ($tmpobj->total_ttc < 0) { print '"; - }; + } if ($tmpobj->total_ttc >= 0) { print '"; - }; + } print ''; print ""; } diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 79f338cef85..f94eb38f27d 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -574,7 +574,7 @@ if ($id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 611d516613b..43259727917 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -114,7 +114,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 7cca5c7b4ec..ca31915d2f4 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -74,7 +74,7 @@ if (isModEnabled('project')) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index c1d6e9f3ec4..70abe873cba 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -29,6 +29,7 @@ require '../../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -45,6 +46,7 @@ if ($user->socid) { } $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $search_ref = GETPOST('search_ref', 'int'); @@ -312,6 +314,9 @@ if ($resql) { $total = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -362,7 +367,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.urlencode($socid); } - $newcardbutton = dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewVariousPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->modifier); print '
'; @@ -375,6 +383,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -466,7 +476,7 @@ if ($resql) { } // Accounting account - if ($arrayfields['account']['checked']) { + if (!empty($arrayfields['account']['checked'])) { print '
'; @@ -535,10 +545,10 @@ if ($resql) { if ($arrayfields['entry']['checked']) { print_liste_field_titre($arrayfields['entry']['label'], $_SERVER["PHP_SELF"], 'ba.label', '', $param, '', $sortfield, $sortorder); } - if ($arrayfields['account']['checked']) { + if (!empty($arrayfields['account']['checked'])) { print_liste_field_titre($arrayfields['account']['label'], $_SERVER["PHP_SELF"], 'v.accountancy_code', '', $param, '', $sortfield, $sortorder, 'left '); } - if ($arrayfields['subledger']['checked']) { + if (!empty($arrayfields['subledger']['checked'])) { print_liste_field_titre($arrayfields['subledger']['label'], $_SERVER["PHP_SELF"], 'v.subledger_account', '', $param, '', $sortfield, $sortorder, 'left '); } if ($arrayfields['debit']['checked']) { @@ -568,166 +578,187 @@ if ($resql) { $variousstatic->id = $obj->rowid; $variousstatic->ref = $obj->rowid; $variousstatic->label = $obj->label; + $variousstatic->datep = $obj->datep; + $variousstatic->type_payment = $obj->payment_code; + $bankline->fetch($obj->fk_bank); + $variousstatic->fk_bank = $bankline->getNomUrl(1); + $variousstatic->amount = $obj->amount; - print ''; + $accountingaccount->fetch('', $obj->accountancy_code, 1); + $variousstatic->accountancy_code = $accountingaccount->getNomUrl(0, 0, 1, $obj->accountingaccount, 1); - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - } - - // Ref - if ($arrayfields['ref']['checked']) { - print '"; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print '"; - if (!$i) { - $totalarray['nbfield']++; + print $variousstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Date payment - if ($arrayfields['datep']['checked']) { - print '"; - if (!$i) { - $totalarray['nbfield']++; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; } - } - - // Date value - if ($arrayfields['datev']['checked']) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if ($arrayfields['type']['checked']) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project - if ($arrayfields['project']['checked']) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Bank account - if ($arrayfields['bank']['checked']) { - print '"; + if (!$i) { + $totalarray['nbfield']++; } - - $accountstatic->label = $obj->blabel; - print $accountstatic->getNomUrl(1); - } else { - print ' '; } - print ''; + + // Label payment + if ($arrayfields['label']['checked']) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date payment + if ($arrayfields['datep']['checked']) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + // Date value + if ($arrayfields['datev']['checked']) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if ($arrayfields['type']['checked']) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project + if ($arrayfields['project']['checked']) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank account + if ($arrayfields['bank']['checked']) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank entry + if ($arrayfields['entry']['checked']) { + $bankline->fetch($obj->fk_bank); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accounting account + if (!empty($arrayfields['account']['checked'])) { + $accountingaccount->fetch('', $obj->accountancy_code, 1); + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Accounting subledger account + if (!empty($arrayfields['subledger']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Debit + if ($arrayfields['debit']['checked']) { + print ''; + } + + // Credit + if ($arrayfields['credit']['checked']) { + print ''; + } + + print ''; + if (!$i) { $totalarray['nbfield']++; } + + print ''."\n"; } - - // Bank entry - if ($arrayfields['entry']['checked']) { - $bankline->fetch($obj->fk_bank); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accounting account - if ($arrayfields['account']['checked']) { - $accountingaccount->fetch('', $obj->accountancy_code, 1); - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Accounting subledger account - if ($arrayfields['subledger']['checked']) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Debit - if ($arrayfields['debit']['checked']) { - print ''; - } - - // Credit - if ($arrayfields['credit']['checked']) { - print ''; - } - - print ''; - - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - $i++; } diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7d433282367..05612f54166 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -41,7 +41,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'cashcontrol'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') - +$mode = GETPOST('mode', 'alpha'); // for mode view result $id = GETPOST('id', 'int'); // Load variable for pagination @@ -399,10 +399,14 @@ print ''; print ''; print ''; print ''; +print ''; $permforcashfence = 1; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permforcashfence); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'cash-register', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -419,7 +423,7 @@ if ($search_all) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } @@ -552,81 +556,101 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - $j = 0; - print '
'; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + // show kanban result + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + // Show here line of result + $j = 0; + print ''; + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; } - print '>'; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; + print ''."\n"; + } $i++; } diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index bc45f3b417d..8cc3c93b59c 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -469,4 +469,37 @@ class CashControl extends CommonObject return $result; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //var_dump($this->fields['rowid']);exit; + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1, 1) : $this->ref).''; + if (property_exists($this, 'posmodule')) { + $return .= '
'.substr($langs->trans("Module/Application"), 0, 12).' : '.$this->posmodule.''; + } + if (property_exists($this, 'year_close')) { + $return .= '
'.$langs->trans("Year").' : '.$this->year_close.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/clients.php b/htdocs/compta/clients.php index cd472c270e3..8db4516d3dd 100644 --- a/htdocs/compta/clients.php +++ b/htdocs/compta/clients.php @@ -133,7 +133,7 @@ if ($resql) { $langs->load('commercial'); - print_barre_liste($langs->trans("ListOfCustomers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("Customers"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); print ''; diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index a4a782de603..6f4613097d9 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -68,7 +68,7 @@ $childids[] = $user->id; //$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'; $help_url = ''; -llxHeader('', $langs->trans("ListOfFees"), $help_url); +llxHeader('', $langs->trans("TripsAndExpenses"), $help_url); diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index cae06774332..c1c5e5cb851 100644 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -131,7 +131,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - print_barre_liste($langs->trans("ListOfFees"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); + print_barre_liste($langs->trans("TripsAndExpenses"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num); $i = 0; print ''."\n"; diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 64a37dcbed4..87834ffe7df 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -271,7 +271,7 @@ if (empty($reshook)) { } // Delete - if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer) { + if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->supprimer) { $object->delete($user); header("Location: ".DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php'); @@ -1175,8 +1175,8 @@ if ($action == 'create') { } // Confirm delete of repeatable invoice - if ($action == 'ask_deleteinvoice') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_deleteinvoice', '', 'no', 1); + if ($action == 'delete') { + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteRepeatableInvoice'), $langs->trans('ConfirmDeleteRepeatableInvoice'), 'confirm_delete', '', 'no', 1); } // Call Hook formConfirm @@ -1231,7 +1231,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -1635,7 +1635,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { $canchangeproduct = 1; - $ret = $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 0); // No date selector for template invoice } // Form to add new line diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 36c98a495ec..ec4bfb8e0f5 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2038,12 +2038,12 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; } + $tva_tx = GETPOST('tva_tx', 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { @@ -2137,7 +2137,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit // Replaces $fk_unit with the product's if (!empty($idprod) && $idprod > 0) { @@ -2157,8 +2156,8 @@ if (empty($reshook)) { $price_min_ttc = $datapriceofproduct['price_min_ttc']; $price_base_type = $datapriceofproduct['price_base_type']; - $tva_tx = $datapriceofproduct['tva_tx']; - $tva_npr = $datapriceofproduct['tva_npr']; + //$tva_tx = $datapriceofproduct['tva_tx']; + //$tva_npr = $datapriceofproduct['tva_npr']; $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); @@ -2763,7 +2762,7 @@ if (empty($reshook)) { } if (!$errors) { - setEventMessages($langs->trans('Updated'), '', 'mesgs'); + setEventMessages($langs->trans('Updated'), null, 'mesgs'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); } else { setEventMessages($langs->trans('ErrorOutingSituationInvoiceCreditNote'), array(), 'errors'); @@ -3066,9 +3065,9 @@ if ($action == 'create') { $remise_percent = (!empty($expesrc->remise_percent) ? $expesrc->remise_percent : (!empty($soc->remise_percent) ? $soc->remise_percent : 0)); $remise_absolue = (!empty($expesrc->remise_absolue) ? $expesrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - if (!empty($conf->multicurrency->enabled)) { - $currency_code = (!empty($expesrc->currency_code) ? $expesrc->currency_code : (!empty($soc->currency_code) ? $soc->currency_code : $objectsrc->multicurrency_code)); - $currency_tx = (!empty($expesrc->currency_tx) ? $expesrc->currency_tx : (!empty($soc->currency_tx) ? $soc->currency_tx : $objectsrc->currency_tx)); + if (isModEnabled('multicurrency')) { + $currency_code = (!empty($expesrc->multicurrency_code) ? $expesrc->multicurrency_code : (!empty($soc->multicurrency_code) ? $soc->multicurrency_code : $objectsrc->multicurrency_code)); + $currency_tx = (!empty($expesrc->multicurrency_tx) ? $expesrc->multicurrency_tx : (!empty($soc->multicurrency_tx) ? $soc->multicurrency_tx : $objectsrc->multicurrency_tx)); } //Replicate extrafields @@ -3357,7 +3356,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -3780,7 +3779,7 @@ if ($action == 'create') { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -4381,7 +4380,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -4678,16 +4677,16 @@ if ($action == 'create') { if ($displayWarranty) { // Retained Warranty print ''; } @@ -576,162 +585,179 @@ while ($i < min($num, $limit)) { $chargesociale_static->ref = $obj->rowid; $chargesociale_static->label = $obj->label; $chargesociale_static->type_label = $obj->type_label; + $chargesociale_static->amount = $obj->amount; + $chargesociale_static->paye = $obj->paye; + $chargesociale_static->date_ech = $obj->date_ech; + if (isModEnabled('project')) { $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; } - - print ''; - - // Line number - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + $chargesociale_static->fk_project = $projectstatic->getNomUrl(); + print $chargesociale_static->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Label - if (!empty($arrayfields['cs.libelle']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['cs.fk_type']['checked'])) { - $typelabeltoshow = $obj->type_label; - $typelabelpopup = $obj->type_label; - if (isModEnabled('accounting')) { - $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['cs.date_ech']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date end period - if (!empty($arrayfields['cs.periode']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['cs.fk_user']['checked'])) { - // Employee - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print $ustatic->getNomUrl(-1); } - print "\n"; + + // Ref + if (!empty($arrayfields['cs.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['cs.libelle']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['cs.fk_type']['checked'])) { + $typelabeltoshow = $obj->type_label; + $typelabelpopup = $obj->type_label; + if (isModEnabled('accounting')) { + $typelabelpopup .= ' - '.$langs->trans("AccountancyCode").': '.$obj->type_accountancy_code; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['cs.date_ech']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date end period + if (!empty($arrayfields['cs.periode']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['cs.fk_user']['checked'])) { + // Employee + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type + if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Account + if (!empty($arrayfields['cs.fk_account']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount + if (!empty($arrayfields['cs.amount']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + } + $totalarray['val']['totalttcfield'] += $obj->amount; + } + + // Status + if (!empty($arrayfields['cs.paye']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Buttons + print ''; if (!$i) { $totalarray['nbfield']++; } + + print ''."\n"; } - - // Type - if (!empty($arrayfields['cs.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Account - if (!empty($arrayfields['cs.fk_account']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - } - - // Amount - if (!empty($arrayfields['cs.amount']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; - } - $totalarray['val']['totalttcfield'] += $obj->amount; - } - - // Status - if (!empty($arrayfields['cs.paye']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Buttons - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''."\n"; - $i++; } diff --git a/htdocs/compta/stats/byratecountry.php b/htdocs/compta/stats/byratecountry.php index fb8ad4de1a5..b9dd6c7429d 100644 --- a/htdocs/compta/stats/byratecountry.php +++ b/htdocs/compta/stats/byratecountry.php @@ -461,9 +461,9 @@ if ($modecompta == 'CREANCES-DETTES') { $j -= 12; } $monthj = 'month'.str_pad($j, 2, '0', STR_PAD_LEFT); - print ''; + print ''; } - print ''; + print ''; print ''; } else { print $db->lasterror(); // Show last sql error diff --git a/htdocs/compta/stats/cabyprodserv.php b/htdocs/compta/stats/cabyprodserv.php index dc0fa94030c..e747c4380a4 100644 --- a/htdocs/compta/stats/cabyprodserv.php +++ b/htdocs/compta/stats/cabyprodserv.php @@ -324,7 +324,7 @@ if ($modecompta == 'CREANCES-DETTES') { } if ($selected_cat === -2) { // Without any category $sql .= " AND cp.fk_product is null"; - } elseif ($selected_cat) { // Into a specific category + } elseif ($selected_cat > 0) { // Into a specific category if ($subcat) { $TListOfCats = $categorie->get_full_arbo('product', $selected_cat, 1); diff --git a/htdocs/compta/stats/casoc.php b/htdocs/compta/stats/casoc.php index d24e5a5452a..b499ca17c71 100644 --- a/htdocs/compta/stats/casoc.php +++ b/htdocs/compta/stats/casoc.php @@ -406,12 +406,16 @@ if ($modecompta == "RECETTES-DEPENSES") { while ($i < $num) { $obj = $db->fetch_object($result); - $amount[$obj->rowid] += $obj->amount_ttc; + if (empty($amount[$obj->socid])) { + $amount[$obj->socid] = $obj->amount_ttc; + } else { + $amount[$obj->socid] += $obj->amount_ttc; + } - $name[$obj->rowid] = $obj->name; - $address_zip[$obj->rowid] = $obj->zip; - $address_town[$obj->rowid] = $obj->town; - $address_pays[$obj->rowid] = getCountry($obj->fk_pays); + $name[$obj->socid] = $obj->name; + $address_zip[$obj->socid] = ''; + $address_town[$obj->socid] = ''; + $address_pays[$obj->socid] = 0; $catotal += $obj->amount_ttc; diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index 058fba33177..7d70bc10527 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -577,7 +577,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Montant total HT if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print '"; } else { print ''; @@ -587,7 +587,7 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Total amount if (!empty($total[$annee]) || ($annee >= $minyear && $annee <= max($nowyear, $maxyear))) { print '"; } else { print ''; @@ -595,19 +595,19 @@ for ($annee = $year_start; $annee <= $year_end; $annee++) { // Pourcentage total if ($annee > $minyear && $annee <= max($nowyear, $maxyear)) { - if ($total[$annee - 1] && $total[$annee]) { + if (!empty($total[$annee - 1]) && !empty($total[$annee])) { $percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100); print ''; } - if ($total[$annee - 1] && !$total[$annee]) { + if (!empty($total[$annee - 1]) && empty($total[$annee])) { print ''; } - if (!$total[$annee - 1] && $total[$annee]) { + if (empty($total[$annee - 1]) && !empty($total[$annee])) { print ''; } - if (!$total[$annee - 1] && !$total[$annee]) { + if (empty($total[$annee - 1]) && empty($total[$annee])) { print ''; } } else { diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index e7c7678b818..c78b41ba274 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -333,6 +333,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char $object->id = $object->ref = null; $object->paye = 0; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -405,7 +409,7 @@ if ($action == 'create') { $("#label_type_payment").removeClass("fieldrequired"); $(".hide_if_no_auto_create_payment").hide(); } - }; + } $("#radiopayment").click(function() { $("#label").val($(this).data("label")); }); @@ -540,6 +544,7 @@ if ($id > 0) { //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); + $formquestion[] = array('type' => 'text', 'name' => 'amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount), 'morecss' => 'width100'); print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index ec951d8d72d..fcc241c728d 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -366,27 +366,22 @@ class PaymentVAT extends CommonObject $this->fk_user_modif = (int) $this->fk_user_modif; } - - // Check parameters // Put here code to add control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET"; - - $sql .= " fk_tva=".(isset($this->fk_tva) ? $this->fk_tva : "null").","; + $sql .= " fk_tva=".(isset($this->fk_tva) ? ((int) $this->fk_tva) : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; - $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; - $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " amount=".(isset($this->amount) ? (float) price2num($this->amount) : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").","; + $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; - $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; - $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - - + $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index d6efb35ef2f..2ec1199dd29 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -226,7 +226,7 @@ class Tva extends CommonObject $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; $sql .= " fk_user_creat=".((int) $this->fk_user_creat).","; - $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; + $sql .= " fk_user_modif=".((int) ($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id)); $sql .= " WHERE rowid=".((int) $this->id); dol_syslog(get_class($this)."::update", LOG_DEBUG); @@ -906,4 +906,40 @@ class Tva extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'amount')) { + $return .= ' | '.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (property_exists($this, 'type_payment')) { + $return .= '
'.$langs->trans("Payement").' : '.$this->type_payment.''; + } + if (property_exists($this, 'datev')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->datev).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->paiementtype, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index f0efe305d8c..37e7f75b306 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -229,6 +229,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next($langs->trans("Next"), 'class="valignbottom"').""; //print load_fiche_titre($langs->transcountry("VAT", $mysoc->country_code), $textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -242,7 +245,7 @@ if ($refresh === true) { print '
'; + print ''; print ''; @@ -1457,6 +1458,8 @@ if ($object->id > 0) { $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->statut = $objp->status; + $facturestatic->date = $db->jdate($objp->df); + $facturestatic->date_lim_reglement = $db->jdate($objp->dl); print ''; print ''; if ($objp->df > 0) { - print ''; + print ''; } else { - print ''; + print ''; + } + if ($objp->dl > 0) { + print ''; + } else { + print ''; } print ''; // Status of recipient sending email (Warning != status of emailing) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 4ea794bfbd4..75cf669d3c8 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -217,9 +217,10 @@ class Mailing extends CommonObject * Create an EMailing * * @param User $user Object of user making creation - * @return int -1 if error, Id of created object if OK + * @param int $notrigger Disable triggers + * @return int <0 if KO, Id of created object if OK */ - public function create($user) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -229,8 +230,6 @@ class Mailing extends CommonObject return -1; } - $this->db->begin(); - $this->title = trim($this->title); $this->email_from = trim($this->email_from); @@ -239,7 +238,9 @@ class Mailing extends CommonObject return -1; } + $error = 0; $now = dol_now(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing"; $sql .= " (date_creat, fk_user_creat, entity)"; @@ -249,20 +250,33 @@ class Mailing extends CommonObject $this->title = $langs->trans("NoTitle"); } - dol_syslog("Mailing::Create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing"); - if ($this->update($user) > 0) { - $this->db->commit(); - } else { - $this->error = $this->db->lasterror(); - $this->db->rollback(); - return -1; + $result = $this->update($user, 1); + if ($result < 0) { + $error++; } - return $this->id; + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('MAILING_CREATE', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + $this->db->commit(); + return $this->id; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); $this->db->rollback(); @@ -274,9 +288,10 @@ class Mailing extends CommonObject * Update emailing record * * @param User $user Object of user making change + * @param int $notrigger Disable triggers * @return int < 0 if KO, > 0 if OK */ - public function update($user) + public function update($user, $notrigger = 0) { // Check properties if ($this->body === 'InvalidHTMLString') { @@ -284,6 +299,9 @@ class Mailing extends CommonObject return -1; } + $error = 0; + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql .= " SET titre = '".$this->db->escape($this->title)."'"; $sql .= ", sujet = '".$this->db->escape($this->sujet)."'"; @@ -295,12 +313,30 @@ class Mailing extends CommonObject $sql .= ", bgimage = '".($this->bgimage ? $this->db->escape($this->bgimage) : null)."'"; $sql .= " WHERE rowid = ".(int) $this->id; - dol_syslog("Mailing::Update", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) { - return 1; + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if (!$error && !$notrigger) { + // Call trigger + $result = $this->call_trigger('MAILING_MODIFY', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } + + if (!$error) { + dol_syslog(__METHOD__ . ' success'); + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } } else { $this->error = $this->db->lasterror(); + $this->db->rollback(); return -1; } } @@ -528,36 +564,46 @@ class Mailing extends CommonObject { global $user; + $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing"; - $sql .= " WHERE rowid = ".((int) $rowid); + if (!$notrigger) { + $result = $this->call_trigger('MAILING_DELETE', $user); + if ($result < 0) { + $error++; + } + } - dol_syslog("Mailing::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - $res = $this->delete_targets(); - if ($res <= 0) { + if (!$error) { + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "mailing"; + $sql .= " WHERE rowid = " . ((int) $rowid); + + dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + $res = $this->delete_targets(); + if ($res <= 0) { + $error++; + } + + if (!$error) { + dol_syslog(__METHOD__ . ' success'); + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + dol_syslog(__METHOD__ . ' ' . $this->error, LOG_ERR); + return -2; + } + } else { $this->db->rollback(); $this->error = $this->db->lasterror(); return -1; } } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); return -1; } - - if (!$notrigger) { - $result = $this->call_trigger('MAILING_DELETE', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; - } - } - - $this->db->commit(); - return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index d3ebc379b55..cf3d18adbac 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -101,7 +101,7 @@ if (is_resource($handle)) { $qualified = 1; foreach ($mailmodule->require_module as $key) { - if (!$conf->$key->enabled || (!$user->admin && $mailmodule->require_admin)) { + if (empty($conf->$key->enabled) || (!$user->admin && $mailmodule->require_admin)) { $qualified = 0; //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; break; @@ -176,7 +176,7 @@ if ($result) { print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 13a7e63d364..501de4c11cf 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -27,19 +27,24 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; // Load translation files required by the page -$langs->load("mails"); +$langs->load('mails'); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$optioncss = GETPOST('optioncss', 'alpha'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +// Get Parameters +$massaction = GETPOST('massaction', 'alpha'); +$optioncss = GETPOST('optioncss', 'alpha'); + +// Pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$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; $pagenext = $page + 1; + if (!$sortorder) { $sortorder = "DESC"; } @@ -47,10 +52,12 @@ if (!$sortfield) { $sortfield = "m.date_creat"; } +// Search Fields $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); $filteremail = GETPOST('filteremail', 'alpha'); +// Initialize objects $object = new Mailing($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -127,7 +134,9 @@ if (empty($reshook)) { * View */ -llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'); +// Page Header +$help_url = 'EN:Module_EMailing|FR:Module_Mailing|ES:Módulo_Mailing'; +llxHeader('', $langs->trans("Mailing"), $help_url); $form = new Form($db); @@ -187,7 +196,7 @@ $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - $title = $langs->trans("ListOfEMailings"); + $title = $langs->trans("EMailings"); if ($filteremail) { $title .= ' ('.$langs->trans("SentTo", $filteremail).')'; } diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 07729fd55de..3f74c4a860f 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -15,6 +15,7 @@ * Copyright (C) 2018-2021 Frédéric France * Copyright (C) 2020 Nicolas ZABOURI * Copyright (C) 2022 Gauthier VERDOL + * Copyright (C) 2023 Lenin Rivas * * 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 @@ -606,6 +607,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { @@ -938,12 +940,12 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; } + $tva_tx = GETPOST('tva_tx', 'alpha'); + $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { @@ -992,6 +994,8 @@ if (empty($reshook)) { if (!$error && ($qty >= 0) && (!empty($product_desc) || (!empty($idprod) && $idprod > 0))) { $pu_ht = 0; $pu_ttc = 0; + $pu_ht_devise = 0; + $pu_ttc_devise = 0; $price_min = 0; $price_min_ttc = 0; $price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT'); @@ -1002,7 +1006,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Replaces $fk_unit with the product unit if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); @@ -1011,11 +1014,11 @@ if (empty($reshook)) { $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ // Price unique per product $pu_ht = $prod->price; @@ -1056,14 +1059,14 @@ if (empty($reshook)) { $price_min = price($prodcustprice->lines[0]->price_min); $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); $price_base_type = $prodcustprice->lines[0]->price_base_type; - $tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); + /*$tva_tx = ($prodcustprice->lines[0]->default_vat_code ? $prodcustprice->lines[0]->tva_tx.' ('.$prodcustprice->lines[0]->default_vat_code.' )' : $prodcustprice->lines[0]->tva_tx); if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; } $tva_npr = $prodcustprice->lines[0]->recuperableonly; if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ } } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { @@ -1114,12 +1117,12 @@ if (empty($reshook)) { $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // Set unit price to use - if (!empty($price_ht) || $price_ht === '0') { + if (!empty($price_ht) || (string) $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); - } elseif (!empty($price_ttc) || $price_ttc === '0') { + $pu_ttc = price2num($pu_ht * (1 + ((float) $tmpvat / 100)), 'MU'); + } elseif (!empty($price_ttc) || (string) $price_ttc === '0') { $pu_ttc = price2num($price_ttc, 'MU'); - $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); + $pu_ht = price2num($pu_ttc / (1 + ((float) $tmpvat / 100)), 'MU'); } elseif ($tmpvat != $tmpprodvat) { // Is this still used ? if ($price_base_type != 'HT') { @@ -1233,6 +1236,20 @@ if (empty($reshook)) { $date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year')); $date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year')); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Local Taxes $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $tva_npr); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $tva_npr); @@ -1246,11 +1263,11 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1349,6 +1366,20 @@ if (empty($reshook)) { $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Extrafields $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); @@ -1388,12 +1419,12 @@ if (empty($reshook)) { //var_dump(price2num($price_min_ttc)); var_dump(price2num($pu_ttc)); var_dump($remise_percent);exit; if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - (float) $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - (float) $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1830,7 +1861,7 @@ if ($action == 'create') { } print ''; } @@ -1900,7 +1931,7 @@ if ($action == 'create') { print ''; print ''; print ''; } if (!empty($arrayfields['sale_representative']['checked'])) { @@ -1438,8 +1456,8 @@ if ($resql) { } // Status if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; } // Action column @@ -1697,574 +1715,590 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['p.ref_client']['checked'])) { - // Customer ref - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.ref']['checked'])) { - // Project ref - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['pr.title']['checked'])) { - // Project label - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - if (!is_array($typenArray) || empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date proposal - if (!empty($arrayfields['p.date']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date end validity - if (!empty($arrayfields['p.fin_validite']['checked'])) { - if ($obj->dfv) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date delivery - if (!empty($arrayfields['p.date_livraison']['checked'])) { - if ($obj->ddelivery) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date Signature - if (!empty($arrayfields['p.date_signature']['checked'])) { - if ($obj->dsignature) { - print ''; - } else { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - } - // Availability - if (!empty($arrayfields['ava.rowid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Shipping Method - if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Source - input reason - if (!empty($arrayfields['p.fk_input_reason']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment terms - if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['p.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; - } - if (empty($totalarray['val']['p.total_ht'])) { - $totalarray['val']['p.total_ht'] = $obj->total_ht; - } else { - $totalarray['val']['p.total_ht'] += $obj->total_ht; - } - } - // Amount VAT - if (!empty($arrayfields['p.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; - } - if (empty($totalarray['val']['p.total_tva'])) { - $totalarray['val']['p.total_tva'] = $obj->total_tva; - } else { - $totalarray['val']['p.total_tva'] += $obj->total_tva; - } - } - // Amount TTC - if (!empty($arrayfields['p.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; - } - if (empty($totalarray['val']['p.total_ttc'])) { - $totalarray['val']['p.total_ttc'] = $obj->total_ttc; - } else { - $totalarray['val']['p.total_ttc'] += $obj->total_ttc; - } - } - // Amount invoiced HT - if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; - } - if (empty($totalarray['val']['p.total_ht_invoiced'])) { - $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; - } else { - $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; - } - } - // Amount invoiced TTC - if (!empty($arrayfields['p.total_invoiced']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; - } - if (empty($totalarray['val']['p.total_invoiced'])) { - $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; - } else { - $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_tva']['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; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->user_entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['p.ref_client']['checked'])) { + // Customer ref + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['pr.ref']['checked'])) { + // Project ref + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['pr.title']['checked'])) { + // Project label + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + if (!is_array($typenArray) || empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date proposal + if (!empty($arrayfields['p.date']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date end validity + if (!empty($arrayfields['p.fin_validite']['checked'])) { + if ($obj->dfv) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date delivery + if (!empty($arrayfields['p.date_livraison']['checked'])) { + if ($obj->ddelivery) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date Signature + if (!empty($arrayfields['p.date_signature']['checked'])) { + if ($obj->dsignature) { + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Availability + if (!empty($arrayfields['ava.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['p.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Source - input reason + if (!empty($arrayfields['p.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['p.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['p.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['p.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht'; + } + if (empty($totalarray['val']['p.total_ht'])) { + $totalarray['val']['p.total_ht'] = $obj->total_ht; + } else { + $totalarray['val']['p.total_ht'] += $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['p.total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_tva'; + } + if (empty($totalarray['val']['p.total_tva'])) { + $totalarray['val']['p.total_tva'] = $obj->total_tva; + } else { + $totalarray['val']['p.total_tva'] += $obj->total_tva; + } + } + // Amount TTC + if (!empty($arrayfields['p.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ttc'; + } + if (empty($totalarray['val']['p.total_ttc'])) { + $totalarray['val']['p.total_ttc'] = $obj->total_ttc; + } else { + $totalarray['val']['p.total_ttc'] += $obj->total_ttc; + } + } + // Amount invoiced HT + if (!empty($arrayfields['p.total_ht_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_ht_invoiced'; + } + if (empty($totalarray['val']['p.total_ht_invoiced'])) { + $totalarray['val']['p.total_ht_invoiced'] = $totalInvoicedHT; + } else { + $totalarray['val']['p.total_ht_invoiced'] += $totalInvoicedHT; + } + } + // Amount invoiced TTC + if (!empty($arrayfields['p.total_invoiced']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'p.total_invoiced'; + } + if (empty($totalarray['val']['p.total_invoiced'])) { + $totalarray['val']['p.total_invoiced'] = $totalInvoicedTTC; + } else { + $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_tva']['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; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->user_entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] = $total_margin; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] = $total_margin; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); - } else { - $totalarray['val']['total_mark_rate'] = ''; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date cloture - if (!empty($arrayfields['p.date_cloture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['p.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['p.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Date cloture + if (!empty($arrayfields['p.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + // Note public + if (!empty($arrayfields['p.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['p.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['p.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + + print ''."\n"; } - - print ''."\n"; - $i++; } diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index fe4895ad2f8..4a772dae1d2 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -119,7 +119,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php index 37c0f8d5e58..8aa72d9c43f 100644 --- a/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php +++ b/htdocs/comm/propal/tpl/linkedobjectblock.tpl.php @@ -52,13 +52,13 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } print ''; - print ''; - print ''; + print ''; print ''; print ''; print ''; } @@ -1898,7 +1928,7 @@ if ($action == 'create' && $usercancreate) { if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } - }; + } print $object->showOptionals($extrafields, 'create', $parameters); } @@ -2339,7 +2369,7 @@ if ($action == 'create' && $usercancreate) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2736,7 +2766,7 @@ if ($action == 'create' && $usercancreate) { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } $numlines = count($object->lines); @@ -2840,7 +2870,7 @@ if ($action == 'create' && $usercancreate) { // Ship $numshipping = 0; if (isModEnabled('expedition')) { - $numshipping = $object->nb_expedition(); + $numshipping = $object->countNbOfShipments(); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && ($object->getNbOfProductsLines() > 0 || !empty($conf->global->STOCK_SUPPORTS_SERVICES))) { if ((isModEnabled('expedition_bon') && $user->rights->expedition->creer) || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->creer)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2c916abda9a..1a879173684 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -28,7 +28,6 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; */ class Orders extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -109,11 +108,11 @@ class Orders extends DolibarrApi * * Return an array with order informations * - * @param int $id ID of order + * @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 + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -299,7 +298,7 @@ class Orders extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id) { @@ -393,13 +392,12 @@ class Orders extends DolibarrApi /** * Update a line to given order * - * @param int $id Id of order to update - * @param int $lineid Id of line to update - * @param array $request_data OrderLine data + * @param int $id Id of order to update + * @param int $lineid Id of line to update + * @param array $request_data OrderLine data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return array|bool */ public function putLine($id, $lineid, $request_data = null) { @@ -458,16 +456,14 @@ class Orders extends DolibarrApi } /** - * Delete a line to given order + * Delete a line of a given order * - * - * @param int $id Id of order to update - * @param int $lineid Id of line to delete + * @param int $id Id of order to update + * @param int $lineid Id of line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -486,9 +482,7 @@ class Orders extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid); + $updateRes = $this->commande->deleteline(DolibarrApiAccess::$user, $lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -501,13 +495,12 @@ class Orders extends DolibarrApi * * Return an array with contact informations * - * @param int $id ID of order - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id ID of order + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return Object Object with cleaned properties * * @url GET {id}/contacts * - * @return array data without useless information - * * @throws RestException */ public function getContacts($id, $type = '') @@ -536,11 +529,10 @@ class Orders extends DolibarrApi * @param int $id Id of order to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -586,7 +578,7 @@ class Orders extends DolibarrApi * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int + * @return array * * @throws RestException 401 * @throws RestException 404 @@ -630,10 +622,9 @@ class Orders extends DolibarrApi /** * Update order general fields (won't touch lines of order) * - * @param int $id Id of order to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of order to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -777,7 +768,6 @@ class Orders extends DolibarrApi */ public function reopen($id) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } @@ -802,12 +792,11 @@ class Orders extends DolibarrApi /** * Classify the order as invoiced. Could be also called setbilled * - * @param int $id Id of the order + * @param int $id Id of the order + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -851,10 +840,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return int */ public function close($id, $notrigger = 0) { @@ -897,10 +885,9 @@ class Orders extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id, $idwarehouse = -1) { @@ -942,12 +929,11 @@ class Orders extends DolibarrApi /** * Create an order using an existing proposal. * - * * @param int $proposalid Id of the proposal + * @return Object Object with cleaned properties * * @url POST /createfromproposal/{proposalid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 73988594e6f..2a462f77bc4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -11,7 +11,7 @@ * Copyright (C) 2014-2015 Marcos García * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2016-2022 Ferran Marcet - * Copyright (C) 2021-2022 Frédéric France + * Copyright (C) 2021-2023 Frédéric France * Copyright (C) 2022 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify @@ -236,6 +236,11 @@ class Commande extends CommonOrder */ public $user_valid; + /** + * @var OrderLine one line of an order + */ + public $line; + /** * @var OrderLine[] */ @@ -306,7 +311,7 @@ class Commande extends CommonOrder '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_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'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>20), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>20), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>25), 'date_commande' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>1, 'position'=>60), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>62), @@ -1173,6 +1178,8 @@ class Commande extends CommonOrder return -1; } } + + return 0; } else { dol_print_error($this->db); $this->db->rollback(); @@ -1272,6 +1279,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1301,6 +1310,7 @@ class Commande extends CommonOrder { global $conf, $hookmanager; + dol_include_once('/multicurrency/class/multicurrency.class.php'); dol_include_once('/core/class/extrafields.class.php'); $error = 0; @@ -1376,6 +1386,29 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) + if (!empty($conf->multicurrency->enabled)) { + if (!empty($object->multicurrency_code)) { + $this->multicurrency_code = $object->multicurrency_code; + } + if (!empty($conf->global->MULTICURRENCY_USE_ORIGIN_TX) && !empty($object->multicurrency_tx)) { + $this->multicurrency_tx = $object->multicurrency_tx; + } + + if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) { + $tmparray = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date_commande); + $this->fk_multicurrency = $tmparray[0]; + $this->multicurrency_tx = $tmparray[1]; + } else { + $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); + } + if (empty($this->fk_multicurrency)) { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } + } + // get extrafields from original line $object->fetch_optionals(); @@ -1403,6 +1436,8 @@ class Commande extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } @@ -2283,17 +2318,13 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Returns a array with expeditions lines number + * Returns an array with expeditions lines number * * @return int Nb of shipments - * - * TODO deprecate, move to Shipping class */ - public function nb_expedition() + public function countNbOfShipments() { - // phpcs:enable $sql = 'SELECT count(*)'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expedition as e'; $sql .= ', '.MAIN_DB_PREFIX.'element_element as el'; @@ -2309,6 +2340,8 @@ class Commande extends CommonOrder } else { dol_print_error($this->db); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2355,58 +2388,45 @@ class Commande extends CommonOrder * * @param User $user User object * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - public function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0, $id = 0) { if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); - $sql = "SELECT fk_product, qty"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet"; - $sql .= " WHERE rowid = ".((int) $lineid); + // Delete line + $line = new OrderLine($this->db); - $result = $this->db->query($sql); - if ($result) { - $obj = $this->db->fetch_object($result); + $line->context = $this->context; - if ($obj) { - $product = new Product($this->db); - $product->id = $obj->fk_product; + // Load data + $line->fetch($lineid); - // Delete line - $line = new OrderLine($this->db); + if ($id > 0 && $line->fk_commande != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } - // For triggers - $line->fetch($lineid); + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; - // Memorize previous line for triggers - $staticline = clone $line; - $line->oldline = $staticline; + if ($line->delete($user) > 0) { + $result = $this->update_price(1); - if ($line->delete($user) > 0) { - $result = $this->update_price(1); - - if ($result > 0) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - return -1; - } - } else { - $this->db->rollback(); - $this->error = $line->error; - return -1; - } + if ($result > 0) { + $this->db->commit(); + return 1; } else { $this->db->rollback(); - return 0; + $this->error = $this->db->lasterror(); + return -1; } } else { $this->db->rollback(); - $this->error = $this->db->lasterror(); + $this->error = $line->error; return -1; } } else { @@ -2490,6 +2510,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -2554,6 +2576,8 @@ class Commande extends CommonOrder return -1 * $error; } } + + return 0; } @@ -3352,7 +3376,7 @@ class Commande extends CommonOrder $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); @@ -3422,7 +3446,7 @@ class Commande extends CommonOrder } // Test we can delete - if ($this->nb_expedition() != 0) { + if ($this->countNbOfShipments() != 0) { $this->errors[] = $langs->trans('SomeShipmentExists'); $error++; } @@ -4043,18 +4067,18 @@ class Commande extends CommonOrder /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -4331,16 +4355,6 @@ class OrderLine extends CommonOrderLine dol_syslog("OrderLine::delete", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - // Remove extrafields - if (!$error) { - $this->id = $this->rowid; - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } - if (!$error && !$notrigger) { // Call trigger $result = $this->call_trigger('LINEORDER_DELETE', $user); @@ -4350,6 +4364,15 @@ class OrderLine extends CommonOrderLine // End call triggers } + // Remove extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } + if (!$error) { $this->db->commit(); return 1; @@ -4583,6 +4606,9 @@ class OrderLine extends CommonOrderLine if (empty($this->remise_percent)) { $this->remise_percent = 0; } + if (empty($this->remise)) { + $this->remise = 0; + } if (empty($this->info_bits)) { $this->info_bits = 0; } @@ -4626,14 +4652,14 @@ class OrderLine extends CommonOrderLine $sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= " , qty=".price2num($this->qty); $sql .= " , ref_ext='".$this->db->escape($this->ref_ext)."'"; - $sql .= " , subprice=".price2num($this->subprice).""; - $sql .= " , remise_percent=".price2num($this->remise_percent).""; - $sql .= " , price=".price2num($this->price).""; // TODO A virer - $sql .= " , remise=".price2num($this->remise).""; // TODO A virer + $sql .= " , subprice=".price2num($this->subprice); + $sql .= " , remise_percent=".price2num($this->remise_percent); + $sql .= " , price=".price2num($this->price); // TODO A virer + $sql .= " , remise=".price2num($this->remise); // TODO A virer if (empty($this->skip_update_total)) { - $sql .= " , total_ht=".price2num($this->total_ht).""; - $sql .= " , total_tva=".price2num($this->total_tva).""; - $sql .= " , total_ttc=".price2num($this->total_ttc).""; + $sql .= " , total_ht=".price2num($this->total_ht); + $sql .= " , total_tva=".price2num($this->total_tva); + $sql .= " , total_ttc=".price2num($this->total_ttc); $sql .= " , total_localtax1=".price2num($this->total_localtax1); $sql .= " , total_localtax2=".price2num($this->total_localtax2); } @@ -4651,10 +4677,10 @@ class OrderLine extends CommonOrderLine $sql .= " , fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); // Multicurrency - $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->rowid); diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 04c16e68aa0..a6202d5d3bf 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -143,7 +143,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 0c35c3489f7..f16ad2ad3d3 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -140,7 +140,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 0acc5b793aa..2abe32aea71 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -94,7 +94,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index e6338903f43..119d88e7cf4 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -9,7 +9,7 @@ * Copyright (C) 2015-2018 Frédéric France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2016-2023 Ferran Marcet * Copyright (C) 2018 Charlene Benke * Copyright (C) 2021 Anthony Berton * @@ -60,6 +60,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'orderlist'; +$mode = GETPOST('mode', 'alpha'); // Search Parameters $search_datecloture_start = GETPOST('search_datecloture_start', 'int'); @@ -235,7 +236,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -413,7 +414,7 @@ if (empty($reshook)) { $desc = dol_concatdesc($desc, $langs->trans("Order").' '.$cmd->ref.' - '.dol_print_date($cmd->date, 'day')); } - if ($lines[$i]->subprice < 0) { + if ($lines[$i]->subprice < 0 && empty($conf->global->INVOICE_KEEP_DISCOUNT_LINES_AS_IN_ORIGIN)) { // Negative line, we create a discount line $discount = new DiscountAbsolute($db); $discount->fk_soc = $objecttmp->socid; @@ -578,6 +579,9 @@ if (empty($reshook)) { // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -679,14 +683,14 @@ if ($action == 'validate' && $permissiontoadd) { $idwarehouse = 0; } if ($objecttmp->valid($user, $idwarehouse)) { - setEventMessage($langs->trans('hasBeenValidated', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('hasBeenValidated', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($objecttmp->error, $objecttmp->errors, 'errors'); + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -710,14 +714,14 @@ if ($action == 'shipped' && $permissiontoadd) { if ($objecttmp->fetch($checked)) { if ($objecttmp->statut == 1 || $objecttmp->statut == 2) { if ($objecttmp->cloture($user)) { - setEventMessage($langs->trans('PassedInClosedStatus', $objecttmp->ref), 'mesgs'); + setEventMessages($langs->trans('PassedInClosedStatus', $objecttmp->ref), null, 'mesgs'); } else { - setEventMessage($langs->trans('CantBeClosed'), 'errors'); + setEventMessages($langs->trans('CantBeClosed'), null, 'errors'); $error++; } } else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorIsNotADraft', $objecttmp->ref), 'errors'); + setEventMessages($langs->trans('ErrorIsNotADraft', $objecttmp->ref), null, 'errors'); $error++; } } else { @@ -1131,7 +1135,9 @@ if ($resql) { llxHeader('', $title, $help_url); $param = ''; - + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1305,7 +1311,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlist' && $permissiontoadd); // Lines of title fields print '
'; @@ -1320,6 +1329,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1515,16 +1526,16 @@ if ($resql) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print '
'; + print ''; } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; } // State if (!empty($arrayfields['state.nom']['checked'])) { print ''; } // Country @@ -1712,18 +1723,18 @@ if ($resql) { } // Status billed if (!empty($arrayfields['c.facture']['checked'])) { - print ''; } // Import key if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; } // Status if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; } // Action column @@ -1896,7 +1907,7 @@ if ($resql) { print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['c.fk_statut']['checked'])) { - print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'right '); } if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); @@ -1969,6 +1980,9 @@ if ($resql) { $generic_commande->note_public = $obj->note_public; $generic_commande->note_private = $obj->note_private; + $generic_commande->thirdparty = $companystatic; + + $projectstatic->id = $obj->project_id; $projectstatic->ref = $obj->project_ref; $projectstatic->title = $obj->project_label; @@ -1981,655 +1995,669 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print ''; - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; } - print ''; - } + } else { + print ''; - // Ref - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Ref customer - if (!empty($arrayfields['c.ref_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project label - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias name - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Order date - if (!empty($arrayfields['c.date_commande']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Plannned date of delivery - if (!empty($arrayfields['c.date_delivery']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Shipping Method - if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment terms - if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment mode - if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Channel - if (!empty($arrayfields['c.fk_input_reason']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net - if (!empty($arrayfields['c.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; - } - if (isset($totalarray['val']['c.total_ht'])) { - $totalarray['val']['c.total_ht'] += $obj->total_ht; - } else { - $totalarray['val']['c.total_ht'] = $obj->total_ht; - } - } - - // Amount VAT - if (!empty($arrayfields['c.total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; - } - if (isset($totalarray['val']['c.total_tva'])) { - $totalarray['val']['c.total_tva'] += $obj->total_tva; - } else { - $totalarray['val']['c.total_tva'] = $obj->total_tva; - } - } - - // Amount TTC / gross - if (!empty($arrayfields['c.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; - } - if (isset($totalarray['val']['c.total_ttc'])) { - $totalarray['val']['c.total_ttc'] += $obj->total_ttc; - } else { - $totalarray['val']['c.total_ttc'] = $obj->total_ttc; - } - } - - // Currency - if (!empty($arrayfields['c.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT/net in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT in foreign currency - if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC / gross in foreign currency - if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Sales representatives - if (!empty($arrayfields['sale_representative']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] += $marginInfo['total_margin']; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount HT/net + if (!empty($arrayfields['c.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ht'; + } + if (isset($totalarray['val']['c.total_ht'])) { + $totalarray['val']['c.total_ht'] += $obj->total_ht; } else { - $totalarray['val']['total_mark_rate'] = ''; + $totalarray['val']['c.total_ht'] = $obj->total_ht; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_tva'; + } + if (isset($totalarray['val']['c.total_tva'])) { + $totalarray['val']['c.total_tva'] += $obj->total_tva; + } else { + $totalarray['val']['c.total_tva'] = $obj->total_tva; + } } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount TTC / gross + if (!empty($arrayfields['c.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'c.total_ttc'; + } + if (isset($totalarray['val']['c.total_ttc'])) { + $totalarray['val']['c.total_ttc'] += $obj->total_ttc; + } else { + $totalarray['val']['c.total_ttc'] = $obj->total_ttc; + } } - } - // Date cloture - if (!empty($arrayfields['c.date_cloture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Note public - if (!empty($arrayfields['c.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Note private - if (!empty($arrayfields['c.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Amount HT/net in foreign currency + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT in foreign currency + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC / gross in foreign currency + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Show shippable Icon (this creates subloops, so may be slow) - if (!empty($arrayfields['shippable']['checked'])) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Sales representatives + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - // Get local and virtual stock and store it into cache - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { - $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock() - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; - $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Show shippable Icon (this creates subloops, so may be slow) + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['c.facture']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Import key - if (!empty($arrayfields['c.import_key']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Status - if (!empty($arrayfields['c.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; } - - print "\n"; - - $total += $obj->total_ht; - $subtotal += $obj->total_ht; $i++; } diff --git a/htdocs/commande/list_det.php b/htdocs/commande/list_det.php new file mode 100644 index 00000000000..d5b0336b95a --- /dev/null +++ b/htdocs/commande/list_det.php @@ -0,0 +1,2190 @@ + + * Copyright (C) 2004-2019 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Christophe Battarel + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015 Marcos García + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016-2021 Ferran Marcet + * Copyright (C) 2018 Charlene Benke + * Copyright (C) 2021-2022 Anthony Berton + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/commande/list.php + * \ingroup commande + * \brief Page to list orders + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +if (!empty($conf->margin->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php'; +} +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("orders", 'sendings', 'deliveries', 'companies', 'compta', 'bills', 'stocks', 'products')); + +$action = GETPOST('action', 'aZ09'); +$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') : 'orderlistdet'; +$productobuy = GETPOST('productobuy', 'alpha'); +$productonly = GETPOST('productonly', 'alpha'); +$disablelinefree = GETPOST('disablelinefree', 'alpha'); + +$search_datecloture_start = GETPOST('search_datecloture_start', 'int'); +if (empty($search_datecloture_start)) { + $search_datecloture_start = dol_mktime(0, 0, 0, GETPOST('search_datecloture_startmonth', 'int'), GETPOST('search_datecloture_startday', 'int'), GETPOST('search_datecloture_startyear', 'int')); +} +$search_datecloture_end = GETPOST('search_datecloture_end', 'int'); +if (empty($search_datecloture_end)) { + $search_datecloture_end = dol_mktime(23, 59, 59, GETPOST('search_datecloture_endmonth', 'int'), GETPOST('search_datecloture_endday', 'int'), GETPOST('search_datecloture_endyear', 'int')); +} +$search_dateorder_start = dol_mktime(0, 0, 0, GETPOST('search_dateorder_start_month', 'int'), GETPOST('search_dateorder_start_day', 'int'), GETPOST('search_dateorder_start_year', 'int')); +$search_dateorder_end = dol_mktime(23, 59, 59, GETPOST('search_dateorder_end_month', 'int'), GETPOST('search_dateorder_end_day', 'int'), GETPOST('search_dateorder_end_year', 'int')); +$search_datedelivery_start = dol_mktime(0, 0, 0, GETPOST('search_datedelivery_start_month', 'int'), GETPOST('search_datedelivery_start_day', 'int'), GETPOST('search_datedelivery_start_year', 'int')); +$search_datedelivery_end = dol_mktime(23, 59, 59, GETPOST('search_datedelivery_end_month', 'int'), GETPOST('search_datedelivery_end_day', 'int'), GETPOST('search_datedelivery_end_year', 'int')); +$search_product_category = GETPOST('search_product_category', 'int'); + +// Détail commande +$search_refProduct = GETPOST('search_refProduct', 'alpha'); +$search_descProduct = GETPOST('search_descProduct', 'alpha'); + +$search_ref = GETPOST('search_ref', 'alpha') != '' ?GETPOST('search_ref', 'alpha') : GETPOST('sref', 'alpha'); +$search_ref_customer = GETPOST('search_ref_customer', 'alpha'); +$search_company = GETPOST('search_company', 'alpha'); +$search_company_alias = GETPOST('search_company_alias', 'alpha'); +$search_town = GETPOST('search_town', 'alpha'); +$search_zip = GETPOST('search_zip', 'alpha'); +$search_state = GETPOST("search_state", 'alpha'); +$search_country = GETPOST("search_country", 'int'); +$search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); +$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_warehouse = GETPOST('search_warehouse', 'int'); +$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 = GETPOST("search_categ_cus", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$search_billed = GETPOSTISSET('search_billed') ? GETPOST('search_billed', 'int') : GETPOST('billed', 'int'); +$search_status = GETPOST('search_status', 'int'); +$search_btn = GETPOST('button_search', 'alpha'); +$search_remove_btn = GETPOST('button_removefilter', 'alpha'); +$search_project_ref = GETPOST('search_project_ref', 'alpha'); +$search_project = GETPOST('search_project', 'alpha'); +$search_shippable = GETPOST('search_shippable', 'aZ09'); +$search_fk_cond_reglement = GETPOST("search_fk_cond_reglement", 'int'); +$search_fk_shipping_method = GETPOST("search_fk_shipping_method", 'int'); +$search_fk_mode_reglement = GETPOST("search_fk_mode_reglement", 'int'); +$search_fk_input_reason = GETPOST("search_fk_input_reason", 'int'); + +// Security check +$id = (GETPOST('orderid') ?GETPOST('orderid', 'int') : GETPOST('id', 'int')); +if ($user->socid) { + $socid = $user->socid; +} +$result = restrictedArea($user, 'commande', $id, ''); + +$diroutputmassaction = $conf->commande->multidir_output[$conf->entity].'/temp/massgeneration/'.$user->id; + +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST('sortfield', 'aZ09comma'); +$sortorder = GETPOST('sortorder', 'aZ09comma'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) { + $sortfield = 'pr.ref'; +} +if (!$sortorder) { + $sortorder = 'ASC'; +} + +$show_shippable_command = GETPOST('show_shippable_command', 'aZ09'); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$object = new Commande($db); +$hookmanager->initHooks(array('orderlistdetail')); +$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_'); + +// List of fields to search into when doing a "search in all" +$fieldstosearchall = array( + 'c.ref'=>'Ref', + 'c.ref_client'=>'RefCustomerOrder', + 'pd.description'=>'Description', + 's.nom'=>"ThirdParty", + 's.name_alias'=>"AliasNameShort", + 's.zip'=>"Zip", + 's.town'=>"Town", + 'c.note_public'=>'NotePublic', +); +if (empty($user->socid)) { + $fieldstosearchall["c.note_private"] = "NotePrivate"; +} + +$checkedtypetiers = 0; +$arrayfields = array( + // Détail commande + 'pr.ref'=> array('label'=>'ProductRef', 'checked'=>1, 'position'=>1), + 'pr.desc'=> array('label'=>'ProductDescription', 'checked'=>1, 'position'=>1), + 'cdet.qty'=> array('label'=>'QtyOrdered', 'checked'=>1, 'position'=>1), + 'c.ref'=>array('label'=>"Ref", 'checked'=>1, 'position'=>5), + 'c.ref_client'=>array('label'=>"RefCustomerOrder", 'checked'=>-1, 'position'=>10), + 'p.ref'=>array('label'=>"ProjectRef", 'checked'=>-1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>20), + 'p.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1), 'position'=>25), + 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), + 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1, 'position'=>31), + 's.town'=>array('label'=>"Town", 'checked'=>-1, 'position'=>35), + 's.zip'=>array('label'=>"Zip", 'checked'=>-1, 'position'=>40), + 'state.nom'=>array('label'=>"StateShort", 'checked'=>0, 'position'=>45), + 'country.code_iso'=>array('label'=>"Country", 'checked'=>0, 'position'=>50), + 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers, 'position'=>55), + 'c.date_commande'=>array('label'=>"OrderDateShort", 'checked'=>1, 'position'=>60), + 'c.date_delivery'=>array('label'=>"DateDeliveryPlanned", 'checked'=>1, 'enabled'=>empty($conf->global->ORDER_DISABLE_DELIVERY_DATE), 'position'=>65), + 'c.fk_shipping_method'=>array('label'=>"SendingMethod", 'checked'=>-1, 'position'=>66 , 'enabled'=>!empty($conf->expedition->enabled)), + 'c.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>-1, 'position'=>67), + 'c.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>-1, 'position'=>68), + 'c.fk_input_reason'=>array('label'=>"Channel", 'checked'=>-1, 'position'=>69), + 'cdet.total_ht'=>array('label'=>"AmountHT", 'checked'=>1, 'position'=>75), + 'c.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0, 'position'=>80), + 'cdet.total_ttc'=>array('label'=>"AmountTTC", 'checked'=>0, 'position'=>85), + 'c.multicurrency_code'=>array('label'=>'Currency', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>90), + 'c.multicurrency_tx'=>array('label'=>'CurrencyRate', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>95), + 'c.multicurrency_total_ht'=>array('label'=>'MulticurrencyAmountHT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>100), + 'c.multicurrency_total_vat'=>array('label'=>'MulticurrencyAmountVAT', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>105), + 'c.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(empty($conf->multicurrency->enabled) ? 0 : 1), 'position'=>110), + 'c.fk_warehouse'=>array('label'=>'Warehouse', 'checked'=>0, 'enabled'=>(empty($conf->stock->enabled) && empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER) ? 0 : 1), 'position'=>110), + 'u.login'=>array('label'=>"Author", 'checked'=>1, 'position'=>115), + 'sale_representative'=>array('label'=>"SaleRepresentativesOfThirdParty", 'checked'=>0, 'position'=>116), + 'total_pa' => array('label' => (getDolGlobalString('MARGIN_TYPE') == '1' ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARGIN_RATES) ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (empty($conf->margin->enabled) || !$user->rights->margins->liretous || empty($conf->global->DISPLAY_MARK_RATES) ? 0 : 1)), + 'c.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>120), + 'c.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>125), + 'c.date_cloture'=>array('label'=>"DateClosing", 'checked'=>0, 'position'=>130), + 'c.note_public'=>array('label'=>'NotePublic', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PUBLIC_NOTES)), 'position'=>135), + 'c.note_private'=>array('label'=>'NotePrivate', 'checked'=>0, 'enabled'=>(empty($conf->global->MAIN_LIST_ALLOW_PRIVATE_NOTES)), 'position'=>140), + 'shippable'=>array('label'=>"Shippable", 'checked'=>1,'enabled'=>(!empty($conf->expedition->enabled)), 'position'=>990), + 'c.facture'=>array('label'=>"Billed", 'checked'=>1, 'enabled'=>(empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)), 'position'=>995), + 'c.import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>999), + 'c.fk_statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) +); + +// Extra fields +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; + +$object->fields = dol_sort_array($object->fields, 'position'); +$arrayfields = dol_sort_array($arrayfields, 'position'); + + + +/* + * Actions + */ + +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { + $massaction = ''; +} + +$parameters = array('socid'=>$socid); +$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'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + $productobuy = ''; + $productonly = ''; + $disablelinefree = ''; + $search_categ = ''; + $search_user = ''; + $search_sale = ''; + $search_product_category = ''; + $search_refProduct = ''; + $search_descProduct = ''; + $search_ref = ''; + $search_ref_customer = ''; + $search_company = ''; + $search_company_alias = ''; + $search_town = ''; + $search_zip = ""; + $search_state = ""; + $search_type = ''; + $search_country = ''; + $search_type_thirdparty = ''; + $search_total_ht = ''; + $search_total_vat = ''; + $search_total_ttc = ''; + $search_warehouse = ''; + $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 = ''; + $search_datedelivery_start = ''; + $search_datedelivery_end = ''; + $search_project_ref = ''; + $search_project = ''; + $search_status = ''; + $search_billed = ''; + $toselect = array(); + $search_array_options = array(); + $search_categ_cus = 0; + $search_datecloture_start = ''; + $search_datecloture_end = ''; + $search_fk_cond_reglement = ''; + $search_fk_shipping_method = ''; + $search_fk_mode_reglement = ''; + $search_fk_input_reason = ''; + } + 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')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'Commande'; + $objectlabel = 'Orders'; + $permissiontoread = $user->rights->commande->lire; + $permissiontoadd = $user->rights->commande->creer; + $permissiontodelete = $user->rights->commande->supprimer; + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + $permissiontovalidate = $user->rights->commande->order_advance->validate; + $permissiontoclose = $user->rights->commande->order_advance->close; + $permissiontocancel = $user->rights->commande->order_advance->annuler; + $permissiontosendbymail = $user->rights->commande->order_advance->send; + } else { + $permissiontovalidate = $user->rights->commande->creer; + $permissiontoclose = $user->rights->commande->creer; + $permissiontocancel = $user->rights->commande->creer; + $permissiontosendbymail = $user->rights->commande->creer; + } + $uploaddir = $conf->commande->multidir_output[$conf->entity]; + $triggersendname = 'ORDER_SENTBYMAIL'; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + +// Closed records +// if (!$error && $massaction === 'setbilled' && $permissiontoclose) { + +// } + +/* + * View + */ + +$now = dol_now(); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formmargin = null; +if (!empty($conf->margin->enabled)) { + $formmargin = new FormMargin($db); +} +$companystatic = new Societe($db); +$formcompany = new FormCompany($db); +$projectstatic = new Project($db); + +$title = $langs->trans("Orders"); +$help_url = "EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes"; +// llxHeader('',$title,$help_url); + +$sql = 'SELECT'; +if ($sall || $search_product_category > 0 || $search_user > 0) { + $sql = 'SELECT DISTINCT'; +} +$sql .= ' s.rowid as socid, s.nom as name, s.name_alias as alias, s.email, s.phone, s.fax, s.address, s.town, s.zip, s.fk_pays, s.client, s.code_client,'; +$sql .= " typent.code as typent_code,"; +$sql .= " state.code_departement as state_code, state.nom as state_name,"; +$sql .= " country.code as country_code,"; +$sql .= ' c.rowid as c_rowid, c.ref, 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.total_ht as c_total_ht, c.total_tva as c_total_tva, c.total_ttc as c_total_ttc, c.fk_warehouse as warehouse,'; +$sql .= ' c.date_valid, c.date_commande, c.note_public, 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,'; +$sql .= ' u.login, u.lastname, u.firstname, u.email as user_email, u.statut as user_statut, u.entity, u.photo, u.office_phone, u.office_fax, u.user_mobile, u.job, u.gender,'; +$sql .= ' c.fk_cond_reglement,c.deposit_percent,c.fk_mode_reglement,c.fk_shipping_method,'; +$sql .= ' c.fk_input_reason, c.import_key'; + +// Détail commande +$sql .= ', cdet.rowid, cdet.description, cdet.qty, cdet.product_type, cdet.fk_product, cdet.total_ht, cdet.total_tva, cdet.total_ttc, '; +$sql .= ' pr.rowid as product_rowid, pr.ref as product_ref, pr.label as product_label, pr.barcode as product_barcode, pr.tobatch as product_batch, pr.tosell as product_status, pr.tobuy as product_status_buy'; + +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ", cc.fk_categorie, cc.fk_soc"; +} +// 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 : ''); + } +} +// 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.'societe as s'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = s.fk_departement)"; +if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cc ON s.rowid = cc.fk_soc"; // We'll need this table joined to the select in order to filter by categ +} + +// Détail commande +$sql .= ', '.MAIN_DB_PREFIX.'commandedet as cdet'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commande as c ON cdet.fk_commande=c.rowid'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as pr ON pr.rowid=cdet.fk_product'; + +if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_extrafields as ef on (c.rowid = ef.fk_object)"; +} +if ($sall || $search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'commandedet as pd ON c.rowid=pd.fk_commande'; +} +if ($search_product_category > 0) { + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=pd.fk_product'; +} +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = c.fk_projet"; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON c.fk_user_author = u.rowid'; + +// We'll need this table joined to the select in order to filter by sale +if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +} +if ($search_user > 0) { + $sql .= ", ".MAIN_DB_PREFIX."element_contact as ec"; + $sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc"; +} + +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + +$sql .= ' WHERE c.fk_soc = s.rowid'; +$sql .= ' AND c.entity IN ('.getEntity('commande').')'; +$sql .= ' AND cdet.product_type <> 9'; + +if (!empty($productobuy)) { + $sql .= " AND pr.tobuy = 1"; +} +if (!empty($productonly)) { + $sql .= " AND (cdet.product_type = 0 OR cdet.product_type = 1)"; +} +if (!empty($disablelinefree)) { + $sql .= " AND cdet.fk_product IS NOT NULL"; +} +if ($search_product_category > 0) { + $sql .= " AND cp.fk_categorie = ".((int) $search_product_category); +} +if ($socid > 0) { + $sql .= ' AND s.rowid = '.((int) $socid); +} +if (empty($user->rights->societe->client->voir) && !$socid) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); +} +if ($search_refProduct) { + $sql .= natural_search('pr.ref', $search_refProduct); +} +if ($search_descProduct) { + $sql .= natural_search('pr.label', $search_descProduct); + $sql .= natural_search('cdet.description', $search_descProduct); +} +if ($search_ref) { + $sql .= natural_search('c.ref', $search_ref); +} +if ($search_ref_customer) { + $sql .= natural_search('c.ref_client', $search_ref_customer); +} +if ($sall) { + $sql .= natural_search(array_keys($fieldstosearchall), $sall); +} +if ($search_billed != '' && $search_billed >= 0) { + $sql .= ' AND c.facture = '.((int) $search_billed); +} +if ($search_status <> '') { + if ($search_status <= 3 && $search_status >= -1) { // status from -1 to 3 are real status (other are virtual combination) + if ($search_status == 1 && empty($conf->expedition->enabled)) { + $sql .= ' AND c.fk_statut IN (1,2)'; // If module expedition disabled, we include order with status 'sending in process' into 'validated' + } else { + $sql .= ' AND c.fk_statut = '.((int) $search_status); // brouillon, validee, en cours, annulee + } + } + if ($search_status == -2) { // To process + //$sql.= ' AND c.fk_statut IN (1,2,3) AND c.facture = 0'; + $sql .= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + } + if ($search_status == -3) { // To bill + //$sql.= ' AND c.fk_statut in (1,2,3)'; + //$sql.= ' AND c.facture = 0'; // invoice not created + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed + } + if ($search_status == -4) { // "validate and in progress" + $sql .= ' AND (c.fk_statut IN (1,2))'; // validated, in process + } +} + +if ($search_datecloture_start) { + $sql .= " AND c.date_cloture >= '".$db->idate($search_datecloture_start)."'"; +} +if ($search_datecloture_end) { + $sql .= " AND c.date_cloture <= '".$db->idate($search_datecloture_end)."'"; +} +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 (".$db->sanitize($search_country).')'; +} +if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $sql .= " AND s.fk_typent IN (".$db->sanitize($search_type_thirdparty).')'; +} +if ($search_company) { + $sql .= natural_search('s.nom', $search_company); +} +if ($search_company_alias) { + $sql .= natural_search('s.name_alias', $search_company_alias); +} +if ($search_sale > 0) { + $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $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 = ".((int) $search_user); +} +if ($search_total_ht != '') { + $sql .= natural_search('cdet.total_ht', $search_total_ht, 1); +} +if ($search_total_vat != '') { + $sql .= natural_search('cdet.total_tva', $search_total_vat, 1); +} +if ($search_total_ttc != '') { + $sql .= natural_search('cdet.total_ttc', $search_total_ttc, 1); +} +if ($search_warehouse != '' && $search_warehouse > 0) { + $sql .= natural_search('c.fk_warehouse', $search_warehouse, 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(array("u.login", "u.firstname", "u.lastname"), $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 = ".((int) $search_categ_cus); +} +if ($search_categ_cus == -2) { + $sql .= " AND cc.fk_categorie IS NULL"; +} +if ($search_fk_cond_reglement > 0) { + $sql .= " AND c.fk_cond_reglement = ".((int) $search_fk_cond_reglement); +} +if ($search_fk_shipping_method > 0) { + $sql .= " AND c.fk_shipping_method = ".((int) $search_fk_shipping_method); +} +if ($search_fk_mode_reglement > 0) { + $sql .= " AND c.fk_mode_reglement = ".((int) $search_fk_mode_reglement); +} +if ($search_fk_input_reason > 0) { + $sql .= " AND c.fk_input_reason = ".((int) $search_fk_input_reason); +} + +// 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; + +// Add HAVING from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListHaving', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= empty($hookmanager->resPrint) ? "" : " HAVING 1=1 ".$hookmanager->resPrint; + +$sql .= $db->order($sortfield, $sortorder); + +// Count total nb of records +$nbtotalofrecords = ''; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + $page = 0; + $offset = 0; + } +} + +$sql .= $db->plimit($limit + 1, $offset); +//print $sql; + +$resql = $db->query($sql); +if ($resql) { + if ($socid > 0) { + $soc = new Societe($db); + $soc->fetch($socid); + $title = $langs->trans('ListOrderLigne').' - '.$soc->name; + if (empty($search_company)) { + $search_company = $soc->name; + } + } else { + $title = $langs->trans('ListOrderLigne'); + } + if (strval($search_status) == '0') { + $title .= ' - '.$langs->trans('StatusOrderDraftShort'); + } + if ($search_status == 1) { + $title .= ' - '.$langs->trans('StatusOrderValidatedShort'); + } + if ($search_status == 2) { + $title .= ' - '.$langs->trans('StatusOrderSentShort'); + } + if ($search_status == 3) { + $title .= ' - '.$langs->trans('StatusOrderToBillShort'); + } + if ($search_status == -1) { + $title .= ' - '.$langs->trans('StatusOrderCanceledShort'); + } + if ($search_status == -2) { + $title .= ' - '.$langs->trans('StatusOrderToProcessShort'); + } + if ($search_status == -3) { + $title .= ' - '.$langs->trans('StatusOrderValidated').', '.(empty($conf->expedition->enabled) ? '' : $langs->trans("StatusOrderSent").', ').$langs->trans('StatusOrderToBill'); + } + if ($search_status == -4) { + $title .= ' - '.$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"); + } + + $num = $db->num_rows($resql); + + $arrayofselected = is_array($toselect) ? $toselect : array(); + + if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/commande/card.php?id='.$id); + exit; + } + + llxHeader('', $title, $help_url); + + $param = ''; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($sall) { + $param .= '&sall='.urlencode($sall); + } + if ($socid > 0) { + $param .= '&socid='.urlencode($socid); + } + if ($search_status != '') { + $param .= '&search_status='.urlencode($search_status); + } + if ($search_datecloture_start) { + $param .= '&search_datecloture_startday='.dol_print_date($search_datecloture_start, '%d').'&search_datecloture_startmonth='.dol_print_date($search_datecloture_start, '%m').'&search_datecloture_startyear='.dol_print_date($search_datecloture_start, '%Y'); + } + if ($search_datecloture_end) { + $param .= '&search_datecloture_endday='.dol_print_date($search_datecloture_end, '%d').'&search_datecloture_endmonth='.dol_print_date($search_datecloture_end, '%m').'&search_datecloture_endyear='.dol_print_date($search_datecloture_end, '%Y'); + } + if ($search_dateorder_start) { + $param .= '&search_dateorder_start_day='.dol_print_date($search_dateorder_start, '%d').'&search_dateorder_start_month='.dol_print_date($search_dateorder_start, '%m').'&search_dateorder_start_year='.dol_print_date($search_dateorder_start, '%Y'); + } + if ($search_dateorder_end) { + $param .= '&search_dateorder_end_day='.dol_print_date($search_dateorder_end, '%d').'&search_dateorder_end_month='.dol_print_date($search_dateorder_end, '%m').'&search_dateorder_end_year='.dol_print_date($search_dateorder_end, '%Y'); + } + if ($search_datedelivery_start) { + $param .= '&search_datedelivery_start_day='.dol_print_date($search_datedelivery_start, '%d').'&search_datedelivery_start_month='.dol_print_date($search_datedelivery_start, '%m').'&search_datedelivery_start_year='.dol_print_date($search_datedelivery_start, '%Y'); + } + if ($search_datedelivery_end) { + $param .= '&search_datedelivery_end_day='.dol_print_date($search_datedelivery_end, '%d').'&search_datedelivery_end_month='.dol_print_date($search_datedelivery_end, '%m').'&search_datedelivery_end_year='.dol_print_date($search_datedelivery_end, '%Y'); + } + if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); + } + if ($search_company) { + $param .= '&search_company='.urlencode($search_company); + } + if ($search_company_alias) { + $param .= '&search_company_alias='.urlencode($search_company_alias); + } + if ($search_ref_customer) { + $param .= '&search_ref_customer='.urlencode($search_ref_customer); + } + if ($search_user > 0) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_sale > 0) { + $param .= '&search_sale='.urlencode($search_sale); + } + 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_warehouse != '') { + $param .= '&search_warehouse='.urlencode($search_warehouse); + } + if ($search_login) { + $param .= '&search_login='.urlencode($search_login); + } + 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_project_ref >= 0) { + $param .= "&search_project_ref=".urlencode($search_project_ref); + } + if ($search_town != '') { + $param .= '&search_town='.urlencode($search_town); + } + if ($search_zip != '') { + $param .= '&search_zip='.urlencode($search_zip); + } + if ($search_state != '') { + $param .= '&search_state='.urlencode($search_state); + } + if ($search_country != '') { + $param .= '&search_country='.urlencode($search_country); + } + if ($search_type_thirdparty && $search_type_thirdparty != '-1') { + $param .= '&search_type_thirdparty='.urlencode($search_type_thirdparty); + } + if ($search_product_category != '') { + $param .= '&search_product_category='.urlencode($search_product_category); + } + if (($search_categ_cus > 0) || ($search_categ_cus == -2)) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); + } + if ($show_files) { + $param .= '&show_files='.urlencode($show_files); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_billed != '') { + $param .= '&search_billed='.urlencode($search_billed); + } + if ($search_fk_cond_reglement > 0) { + $param .= '&search_fk_cond_reglement='.urlencode($search_fk_cond_reglement); + } + if ($search_fk_shipping_method > 0) { + $param .= '&search_fk_shipping_method='.urlencode($search_fk_shipping_method); + } + if ($search_fk_mode_reglement > 0) { + $param .= '&search_fk_mode_reglement='.urlencode($search_fk_mode_reglement); + } + if ($search_fk_input_reason > 0) { + $param .= '&search_fk_input_reason='.urlencode($search_fk_input_reason); + } + if (!empty($productobuy)) { + $param .= '&productobuy='.urlencode($productobuy); + } + if (!empty($productonly)) { + $param .= '&productonly='.urlencode($productonly); + } + if (!empty($disablelinefree)) { + $param .= '&disablelinefree='.urlencode($disablelinefree); + } + + // Add $param from extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + + // Add $param from hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook + $param .= $hookmanager->resPrint; + + // List of mass actions available + $arrayofmassactions = array( + 'GenerateOrdersSuppliers'=>img_picto('', 'doc', 'class="pictofixedwidth"').$langs->trans("GenerateOrdersSupplie"), + ); + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + + $url = DOL_URL_ROOT.'/commande/card.php?action=create'; + if (!empty($socid)) { + $url .= '&socid='.$socid; + } + $newcardbutton = '';//dolGetButtonTitle($langs->trans('NewOrder'), '', 'fa fa-plus-circle', $url, '', $contextpage == 'orderlistdet' && $permissiontoadd); + + // Lines of title fields + print ''; + if ($optioncss != '') { + print ''; + } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'order', 0, $newcardbutton, '', $limit, 0, 0, 1); + + $topicmail = "SendOrderRef"; + $modelmail = "order_send"; + $objecttmp = new Commande($db); + $trackid = 'ord'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + + if ($sall) { + foreach ($fieldstosearchall as $key => $val) { + $fieldstosearchall[$key] = $langs->trans($val); + } + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + } + + $moreforfilter = ''; + + $moreforfilter .= ''; + $moreforfilter .= ''; + $moreforfilter .= ''; + $moreforfilter .= '
'; + + // If the user can view prospects other than his' + if ($user->rights->user->user->lire) { + $langs->load("commercial"); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + // If the user can view other users + if ($user->rights->user->user->lire) { + $moreforfilter .= '
'; + $tmptitle = $langs->trans('LinkedToSpecificUsers'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$form->select_dolusers($search_user, 'search_user', $tmptitle, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + // If the user can view prospects other than his' + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) { + include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('IncludingProductWithTag'); + $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$form->selectarray('search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0, '', 0, 0, 0, 0, 'maxwidth300 widthcentpercentminusx', 1); + $moreforfilter .= '
'; + } + if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $moreforfilter .= '
'; + $tmptitle = $langs->trans('CustomersProspectsCategoriesShort'); + $moreforfilter .= img_picto($tmptitle, 'category', 'class="pictofixedwidth"').$formother->select_categories('customer', $search_categ_cus, 'search_categ_cus', 1, $tmptitle, 'maxwidth300 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + if (!empty($conf->stock->enabled) && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct = new FormProduct($db); + $moreforfilter .= '
'; + $tmptitle = $langs->trans('Warehouse'); + $moreforfilter .= img_picto($tmptitle, 'stock', 'class="pictofixedwidth"').$formproduct->selectWarehouses($search_warehouse, 'search_warehouse', '', 1, 0, 0, $tmptitle, 0, 0, array(), 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= '
'; + } + + + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; + } else { + $moreforfilter = $hookmanager->resPrint; + } + + if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + print '
'; + } + + $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; + $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields + $selectedfields .= $form->showCheckAddButtons('checkforselect', 1); + + if (GETPOST('autoselectall', 'int')) { + $selectedfields .= ''; + } + + print '
'; + print '
'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").''.$num.''; print ''; print '
'.$langs->trans("LastCustomersBills", ($num <= $MAXLIST ? "" : $MAXLIST)).''.$langs->trans("AllBills").''.$num.''.img_picto($langs->trans("Statistics"), 'stats').'
'; @@ -1492,9 +1495,14 @@ if ($object->id > 0) { //print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); print ''.dol_print_date($db->jdate($objp->df), 'day').''.dol_print_date($db->jdate($objp->df), 'day').'!!!!!!'.dol_print_date($db->jdate($objp->dl), 'day').'!!!'; print price($objp->total_ht); diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 67af97cfe12..b748cac3df4 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -65,7 +65,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $now = dol_now(); // Security check -$socid = GETPOST("socid", 'int'); +//$socid = GETPOST("socid", 'int'); if ($user->socid > 0) { $action = ''; $id = $user->socid; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index dde6e3204d6..c39e4fbf834 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -675,7 +675,7 @@ if ($object->fetch($id) >= 0) { // Date last update print ''; - print dol_print_date($obj->tms, 'dayhour'); + print dol_print_date(dol_stringtotime($obj->tms), 'dayhour'); print '
'.$mailstatic->getNomUrl(1).''.dol_trunc($obj->title, 38).''.(!empty($obj->title) ? dol_trunc($obj->title, 38) : '').''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).'
'.$langs->trans('SendingMethod').''; print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); - print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'.$langs->trans('NotePublic').''; - $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : null)); + $note_public = $object->getDefaultCreateValueFor('note_public', (!empty($objectsrc) ? $objectsrc->note_public : (!empty($conf->global->PROPALE_ADDON_NOTE_PUBLIC_DEFAULT) ? $conf->global->PROPALE_ADDON_NOTE_PUBLIC_DEFAULT : null)), 'restricthtml'); $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); @@ -2309,7 +2340,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2776,7 +2807,7 @@ if ($action == 'create') { } if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $object->thirdparty, $lineid, 1); } // Form to add new line diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index cf675e01b62..5e0e2c31e19 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -49,7 +49,7 @@ class Proposals extends DolibarrApi */ public function __construct() { - global $db, $conf; + global $db; $this->db = $db; $this->propal = new Propal($this->db); } @@ -59,9 +59,9 @@ class Proposals extends DolibarrApi * * Return an array with commercial proposal informations * - * @param int $id ID of commercial proposal - * @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 + * @param int $id ID of commercial proposal + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @throws RestException */ @@ -76,8 +76,8 @@ class Proposals extends DolibarrApi * 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 + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -93,9 +93,9 @@ class Proposals extends DolibarrApi * * 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 + * @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 Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -111,11 +111,11 @@ class Proposals extends DolibarrApi * * 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 + * @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 Object Object with cleaned properties * * @throws RestException */ @@ -289,7 +289,7 @@ class Proposals extends DolibarrApi * * @url GET {id}/lines * - * @return int + * @return array */ public function getLines($id, $sqlfilters = '') { @@ -461,7 +461,7 @@ class Proposals extends DolibarrApi } if (empty($errors)) { $this->db->commit(); - return count($request_data); + return $updateRes; } else { $this->db->rollback(); throw new RestException(400, implode(", ", $errors)); @@ -471,13 +471,12 @@ class Proposals extends DolibarrApi /** * Update a line of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to update - * @param array $request_data Commercial proposal line data + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to update + * @param array $request_data Commercial proposal line data + * @return Object|false Object with cleaned properties * * @url PUT {id}/lines/{lineid} - * - * @return object */ public function putLine($id, $lineid, $request_data = null) { @@ -548,13 +547,12 @@ class Proposals extends DolibarrApi * Delete a line of given commercial proposal * * - * @param int $id Id of commercial proposal to update - * @param int $lineid Id of line to delete + * @param int $id Id of commercial proposal to update + * @param int $lineid Id of line to delete + * @return Object|false Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -573,9 +571,7 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->propal->deleteline($lineid); + $updateRes = $this->propal->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -589,11 +585,10 @@ class Proposals extends DolibarrApi * @param int $id Id of commercial proposal to update * @param int $contactid Id of contact to add * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -623,20 +618,24 @@ class Proposals extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->propal; + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the proposal' + ) + ); } /** * Delete a contact type of given commercial proposal * - * @param int $id Id of commercial proposal to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of commercial proposal to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -675,10 +674,9 @@ class Proposals extends DolibarrApi /** * Update commercial proposal general fields (won't touch lines of commercial proposal) * - * @param int $id Id of commercial proposal to update - * @param array $request_data Datas - * - * @return int + * @param int $id Id of commercial proposal to update + * @param array $request_data Datas + * @return Object Object with cleaned properties */ public function put($id, $request_data = null) { @@ -722,7 +720,6 @@ class Proposals extends DolibarrApi * Delete commercial proposal * * @param int $id Commercial proposal ID - * * @return array */ public function delete($id) @@ -755,10 +752,9 @@ class Proposals extends DolibarrApi * Set a proposal to draft * * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft - * - * @return array */ public function settodraft($id) { @@ -807,6 +803,7 @@ class Proposals extends DolibarrApi * * @param int $id Commercial proposal ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object Object with cleaned properties * * @url POST {id}/validate * @@ -814,8 +811,6 @@ class Proposals extends DolibarrApi * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error - * - * @return array */ public function validate($id, $notrigger = 0) { @@ -860,10 +855,9 @@ class Proposals extends DolibarrApi * @param int $status Must be 2 (accepted) or 3 (refused) {@min 2}{@max 3} * @param string $note_private Add this mention at end of private note * @param int $notrigger Disabled triggers + * @return Object Object with cleaned properties * * @url POST {id}/close - * - * @return array */ public function close($id, $status, $note_private = '', $notrigger = 0) { @@ -905,10 +899,9 @@ class Proposals extends DolibarrApi * Set a commercial proposal billed. Could be also called setbilled * * @param int $id Commercial proposal ID + * @return Object Object with cleaned properties * * @url POST {id}/setinvoiced - * - * @return array */ public function setinvoiced($id) { @@ -949,6 +942,7 @@ class Proposals extends DolibarrApi * * @param array $data Array with data to verify * @return array + * * @throws RestException */ private function _validate($data) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 1b3df25c7d2..c4328328f18 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -301,7 +301,7 @@ class Propal extends CommonObject '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), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'position'=>23), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'position'=>23), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>"isModEnabled('project')", '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), @@ -454,6 +454,8 @@ class Propal extends CommonObject $this->lines[] = $line; } + + return 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -981,9 +983,10 @@ class Propal extends CommonObject * Delete detail line * * @param int $lineid Id of line to delete + * @param int $id Id of object (for a check) * @return int >0 if OK, <0 if KO */ - public function deleteline($lineid) + public function deleteline($lineid, $id = 0) { global $user; @@ -992,9 +995,20 @@ class Propal extends CommonObject $line = new PropaleLigne($this->db); - // For triggers + $line->context = $this->context; + + // Load data $line->fetch($lineid); + if ($id > 0 && $line->fk_propal != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; + if ($line->delete($user) > 0) { $this->update_price(1); @@ -1491,6 +1505,8 @@ class Propal extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1752,7 +1768,7 @@ class Propal extends CommonObject $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -2108,6 +2124,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2164,6 +2182,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2235,6 +2255,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2417,9 +2439,9 @@ class Propal extends CommonObject $this->db->rollback(); return -1 * $error; } - } else { - return -1; } + + return -1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2480,6 +2502,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -2542,6 +2566,8 @@ class Propal extends CommonObject return -1 * $error; } } + + return -1; } @@ -2879,7 +2905,7 @@ class Propal extends CommonObject * @param int $offset For pagination * @param string $sortfield Sort criteria * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK + * @return array|int -1 if KO, array with result if OK */ public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { @@ -2958,8 +2984,8 @@ class Propal extends CommonObject /** * Returns an array with id and ref of related invoices * - * @param int $id Id propal - * @return array Array of invoices id + * @param int $id Id propal + * @return array|int Array of invoices id */ public function InvoiceArrayList($id) { @@ -3860,18 +3886,18 @@ class Propal extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'propal' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3890,6 +3916,42 @@ class Propal extends CommonObject return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'fk_project')) { + $return .= ' | '.$this->fk_project.''; + } + if (property_exists($this, 'author')) { + $return .= '
'.$this->author.''; + } + if (property_exists($this, 'total_ht')) { + $return .='
'.$langs->trans("AmountHT").' : '.price($this->total_ht).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } /** @@ -4444,17 +4506,17 @@ class PropaleLigne extends CommonObjectLine $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", qty='".price2num($this->qty)."'"; - $sql .= ", subprice=".price2num($this->subprice).""; - $sql .= ", remise_percent=".price2num($this->remise_percent).""; - $sql .= ", price=".(float) price2num($this->price).""; // TODO A virer - $sql .= ", remise=".(float) price2num($this->remise).""; // TODO A virer + $sql .= ", subprice=".price2num($this->subprice); + $sql .= ", remise_percent=".price2num($this->remise_percent); + $sql .= ", price=".(float) price2num($this->price); // TODO A virer + $sql .= ", remise=".(float) price2num($this->remise); // TODO A virer $sql .= ", info_bits='".$this->db->escape($this->info_bits)."'"; if (empty($this->skip_update_total)) { - $sql .= ", total_ht=".price2num($this->total_ht).""; - $sql .= ", total_tva=".price2num($this->total_tva).""; - $sql .= ", total_ttc=".price2num($this->total_ttc).""; - $sql .= ", total_localtax1=".price2num($this->total_localtax1).""; - $sql .= ", total_localtax2=".price2num($this->total_localtax2).""; + $sql .= ", total_ht=".price2num($this->total_ht); + $sql .= ", total_tva=".price2num($this->total_tva); + $sql .= ", total_ttc=".price2num($this->total_ttc); + $sql .= ", total_localtax1=".price2num($this->total_localtax1); + $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); $sql .= ", buy_price_ht=".price2num($this->pa_ht); @@ -4470,10 +4532,10 @@ class PropaleLigne extends CommonObjectLine $sql .= ", fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit); // Multicurrency - $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); @@ -4520,9 +4582,9 @@ class PropaleLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET"; - $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " total_ht=".price2num($this->total_ht, 'MT'); + $sql .= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT'); $sql .= " WHERE rowid = ".((int) $this->rowid); dol_syslog("PropaleLigne::update_total", LOG_DEBUG); diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 42f3f34f8d4..45f2d175f9a 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -149,7 +149,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index f1d1d7ef644..f1b6b2221e6 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -147,7 +147,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index 986601a91bc..8a1d2afaabd 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -94,7 +94,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index ed86a61d7bd..cc507041ac6 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -16,6 +16,7 @@ * Copyright (C) 2019-2021 Alexandre Spangaro * Copyright (C) 2021 Anthony Berton * Copyright (C) 2021 Frédéric France + * Copyright (C) 2022 Josep Lluís Amador * * 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 @@ -61,20 +62,23 @@ if (isModEnabled("expedition")) { $langs->loadLangs(array('sendings')); } +// Get Parameters $socid = GETPOST('socid', 'int'); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09'); $massaction = GETPOST('massaction', 'alpha'); $show_files = GETPOST('show_files', 'int'); -$confirm = GETPOST('confirm', 'alpha'); -$toselect = GETPOST('toselect', 'array'); +$confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); +$toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'proposallist'; +$mode = GETPOST('mode', 'alpha'); -$search_user = GETPOST('search_user', 'int'); -$search_sale = GETPOST('search_sale', 'int'); -$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); +// Search Fields +$search_user = GETPOST('search_user', 'int'); +$search_sale = GETPOST('search_sale', 'int'); +$search_ref = GETPOST('sf_ref') ?GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_refcustomer = GETPOST('search_refcustomer', 'alpha'); - $search_refproject = GETPOST('search_refproject', 'alpha'); $search_project = GETPOST('search_project', 'alpha'); @@ -138,15 +142,15 @@ $search_date_signature_endyear = GETPOST('search_date_signature_endyear', 'int') $search_date_signature_start = dol_mktime(0, 0, 0, $search_date_signature_startmonth, $search_date_signature_startday, $search_date_signature_startyear); $search_date_signature_end = dol_mktime(23, 59, 59, $search_date_signature_endmonth, $search_date_signature_endday, $search_date_signature_endyear); - $search_status = GETPOST('search_status', 'alpha'); + $optioncss = GETPOST('optioncss', 'alpha'); $object_statut = GETPOST('search_statut', 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $mesg = (GETPOST("msg") ? GETPOST("msg") : GETPOST("mesg")); - +// Pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -261,6 +265,7 @@ foreach ($object->fields as $key => $val) { $fieldstosearchall['t.'.$key] = $val['label']; } }*/ + // Definition of array of fields for columns /*$arrayfields = array(); foreach ($object->fields as $key => $val) { @@ -276,9 +281,11 @@ foreach ($object->fields as $key => $val) { ); } }*/ + // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; +// Permissions $permissiontoread = $user->rights->propal->lire; $permissiontoadd = $user->rights->propal->creer; $permissiontodelete = $user->rights->propal->supprimer; @@ -305,7 +312,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -610,7 +617,9 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON p.fk_user_author = u.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as pr ON pr.rowid = p.fk_projet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_availability as ava on (ava.rowid = p.fk_availability)"; // We'll need this table joined to the select in order to filter by sale -if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { +if ($search_sale == -2) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON (sc.fk_soc = p.fk_soc)"; +} elseif ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } if ($search_user > 0) { @@ -746,7 +755,9 @@ if ($search_date_delivery_start) { if ($search_date_delivery_end) { $sql .= " AND p.date_livraison <= '".$db->idate($search_date_delivery_end)."'"; } -if ($search_sale > 0) { +if ($search_sale == -2) { + $sql .= " AND sc.fk_user IS NULL"; +} elseif ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } if ($search_user > 0) { @@ -859,6 +870,9 @@ if ($resql) { } $param = '&search_status='.urlencode($search_status); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1067,6 +1081,9 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton = dolGetButtonTitle($langs->trans('NewPropal'), '', 'fa fa-plus-circle', $url, '', $user->rights->propal->creer); // Fields title search @@ -1080,6 +1097,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'propal', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1117,7 +1135,7 @@ if ($resql) { $langs->load("commercial"); $moreforfilter .= '
'; $tmptitle = $langs->trans('ThirdPartiesOfSaleRepresentative'); - $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx'); + $moreforfilter .= img_picto($tmptitle, 'user', 'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale, 'search_sale', $user, 0, $tmptitle, 'maxwidth250 widthcentpercentminusx', 1); $moreforfilter .= '
'; } // If the user can view prospects other than his' @@ -1381,8 +1399,8 @@ if ($resql) { } if (!empty($arrayfields['u.login']['checked'])) { // Author - print '
'; - print ''; + print ''; + print ''; print ''; - $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status maxwidth125 onrightofpage'); + print ''; + $formpropal->selectProposalStatus($search_status, 1, 0, 1, 'customer', 'search_statut', 'search_status width100 onrightofpage'); print '
'; + print '
'; + } + // Output Kanban + $userstatic->fetch($obj->fk_user_author); + $objectstatic->author = $userstatic->getNomUrl(1); + $objectstatic->fk_project = $projectstatic->getNomUrl(1); + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; - 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; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; - } - print ''; - - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { - $warnornote .= img_warning($langs->trans("Late")); - } - if ($warnornote) { - print ''; - } - // Other picto tool - print '
'; - print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); - print ''; - print $warnornote; print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; - - print "
'; - print dol_escape_htmltag($obj->ref_client); - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print dol_escape_htmltag($projectstatic->title); - } - print ''; - print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - print $obj->alias; - print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - print $typenArray[$obj->typent_code]; - print ''; - print dol_print_date($db->jdate($obj->dp), 'day'); - print "'.dol_print_date($db->jdate($obj->dfv), 'day'); - print ' '.dol_print_date($db->jdate($obj->ddelivery), 'day'); - print ' '.dol_print_date($db->jdate($obj->dsignature), 'day'); - print ' '; - $form->form_availability('', $obj->availability, 'none', 1); - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - if ($obj->fk_input_reason > 0) { - print $form->cache_demand_reason[$obj->fk_input_reason]['label']; - } - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($totalInvoicedHT)."'.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_tva)."'.price($obj->multicurrency_total_ttc)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedTTC)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + if (!$i) { + $totalarray['nbfield']++; } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + } + + if (!empty($arrayfields['p.ref']['checked'])) { + print '
'; + + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + if ($obj->status == Propal::STATUS_VALIDATED && $db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) { + $warnornote .= img_warning($langs->trans("Late")); + } + if ($warnornote) { + print ''; + } + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1, '', '', 0, 1, (isset($conf->global->PROPAL_LIST_SHOW_NOTES) ? $conf->global->PROPAL_LIST_SHOW_NOTES : 1)); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->propal->multidir_output[$obj->propal_entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "
'; + print dol_escape_htmltag($obj->ref_client); + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print dol_escape_htmltag($projectstatic->title); + } + print ''; + print $companystatic->getNomUrl(1, 'customer', 0, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + print $obj->alias; + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->dp), 'day'); + print "'.dol_print_date($db->jdate($obj->dfv), 'day'); + print ' '.dol_print_date($db->jdate($obj->ddelivery), 'day'); + print ' '.dol_print_date($db->jdate($obj->dsignature), 'day'); + print ' '; + $form->form_availability('', $obj->availability, 'none', 1); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + if ($obj->fk_input_reason > 0) { + print $form->cache_demand_reason[$obj->fk_input_reason]['label']; + } + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.price($totalInvoicedHT)."'.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_tva)."'.price($obj->multicurrency_total_ttc)."'.price($multicurrency_totalInvoicedHT)."'.price($multicurrency_totalInvoicedTTC)."'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; } - //print ''; + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''.$objectstatic->getLibStatut(5).''; - 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; + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''.$objectstatic->getLibStatut(5).''; + 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 ''; + } + print '
'.$langs->trans("Proposal"); + print ''.$langs->trans("Proposal"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$objectlink->id; print ' '; } print ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 383cf7581e9..c37be999366 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -475,6 +475,7 @@ if (empty($reshook)) { // Note that $action and $object may be modified by hook $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { @@ -676,13 +677,28 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); - $tva_tx = ''; + } + + $tva_tx = GETPOST('tva_tx', 'alpha'); + + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; } $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); + $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); if (empty($remise_percent)) { $remise_percent = 0; @@ -746,7 +762,6 @@ if (empty($reshook)) { // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit - // Ecrase $tva_tx par celui du produit // Ecrase $base_price_type par celui du produit if (!empty($idprod) && $idprod > 0) { $prod = new Product($db); @@ -755,11 +770,11 @@ if (empty($reshook)) { $label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : ''); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ $pu_ht = $prod->price; $pu_ttc = $prod->price_ttc; @@ -985,11 +1000,11 @@ if (empty($reshook)) { $desc = dol_htmlcleanlastbr($desc); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1075,6 +1090,20 @@ if (empty($reshook)) { $qty = price2num(GETPOST('qty', 'alpha'), 'MS'); + // Prepare a price equivalent for minimum price check + $pu_equivalent = $pu_ht; + $pu_equivalent_ttc = $pu_ttc; + $currency_tx = $object->multicurrency_tx; + + // Check if we have a foreing currency + // If so, we update the pu_equiv as the equivalent price in base currency + if ($pu_ht == '' && $pu_ht_devise != '' && $currency_tx != '') { + $pu_equivalent = $pu_ht_devise * $currency_tx; + } + if ($pu_ttc == '' && $pu_ttc_devise != '' && $currency_tx != '') { + $pu_equivalent_ttc = $pu_ttc_devise * $currency_tx; + } + // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) { @@ -1106,7 +1135,7 @@ if (empty($reshook)) { $special_code = 3; } - $remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $remise_percent = GETPOST('remise_percent') != '' ? price2num(GETPOST('remise_percent'), '', 2) : 0; // Check minimum price $productid = GETPOST('productid', 'int'); @@ -1128,12 +1157,12 @@ if (empty($reshook)) { $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : ''); if ($usermustrespectpricemin) { - if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { + if ($pu_equivalent && $price_min && ((price2num($pu_equivalent) * (1 - $remise_percent / 100)) < price2num($price_min))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; $action = 'editline'; - } elseif ($pu_ttc && $price_min_ttc && ((price2num($pu_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { + } elseif ($pu_equivalent_ttc && $price_min_ttc && ((price2num($pu_equivalent_ttc) * (1 - $remise_percent / 100)) < price2num($price_min_ttc))) { $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min_ttc, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); setEventMessages($mesg, null, 'errors'); $error++; @@ -1833,7 +1862,8 @@ if ($action == 'create' && $usercancreate) { // Shipping Method if (isModEnabled('expedition')) { print '
'.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dolly', 'class="pictofixedwidth"').$form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); + $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print '
'; - print ''; + print ''; print ''; + print ''; print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); print ''; + print ''; print ''; + print ''; $liststatus = array( Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), @@ -1733,7 +1744,7 @@ if ($resql) { -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") ); - print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'; - 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 ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - if (!$i) { - $totalarray['nbfield']++; + + print $generic_commande->getKanbanView(''); + + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; - print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); - - print ''.$obj->ref_client.''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print $projectstatic->title; - } - print ''; - print $getNomUrl_cache[$obj->socid]; - - // If module invoices enabled and user with invoice creation permissions - if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { - if ($user->rights->facture->creer) { - if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { - print ' '; - print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 (!$i) { + $totalarray['nbfield']++; + } + print ''; + print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + + print ''; - print $obj->alias; - print ''; - if ($obj->fk_parent > 0) { - if (!isset($company_url_list[$obj->fk_parent])) { - $companyparent = new Societe($db); - $res = $companyparent->fetch($obj->fk_parent); - if ($res > 0) { - $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); - } - } - if (isset($company_url_list[$obj->fk_parent])) { - print $company_url_list[$obj->fk_parent]; + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''.$obj->ref_client.''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - // Warning late icon and note - if ($generic_commande->hasDelay()) { - print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); - } - print ''; - print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); - print ''; - $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); - print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); - print ''; - $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); - print ''; - $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$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)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + print '
'; + if ($obj->project_id > 0) { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if ($user->rights->facture->creer) { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; } - //print ''; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print ''.price($marginInfo['pa_total']).''; + print $obj->alias; + print ''.price($marginInfo['total_margin']).''; + if ($obj->fk_parent > 0) { + if (!isset($company_url_list[$obj->fk_parent])) { + $companyparent = new Societe($db); + $res = $companyparent->fetch($obj->fk_parent); + if ($res > 0) { + $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); + } + } + if (isset($company_url_list[$obj->fk_parent])) { + print $company_url_list[$obj->fk_parent]; + } + } + print "'.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''; + print $obj->town; + print ''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + print ''.price($obj->total_ht)."'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''.price($obj->total_tva)."'; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.price($obj->total_ttc)."'; - print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); - print ''.$obj->multicurrency_code.' - '.$langs->trans('Currency'.$obj->multicurrency_code)."'; - print dol_string_nohtmltag($obj->note_public); - print ''; + $form->form_multicurrency_rate($_SERVER['PHP_SELF'].'?id='.$obj->rowid, $obj->multicurrency_tx, 'none', $obj->multicurrency_code); + print "'; - print dol_string_nohtmltag($obj->note_private); - print ''.price($obj->multicurrency_total_ht)."'.price($obj->multicurrency_total_vat)."'.price($obj->multicurrency_total_ttc)."'; - if (!empty($show_shippable_command) && isModEnabled('stock')) { - if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { - $generic_commande->getLinesArray(); // Load array ->lines - $generic_commande->loadExpeditions(); // Load array ->expeditions + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; - $numlines = count($generic_commande->lines); // Loop on each line of order - for ($lig = 0; $lig < $numlines; $lig++) { - if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { - $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; - } else { - $reliquat = $generic_commande->lines[$lig]->qty; + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; } - if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service - $nbprod++; // order contains real products - $generic_product->id = $generic_commande->lines[$lig]->fk_product; + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($show_shippable_command) && isModEnabled('stock')) { + if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions + + $numlines = count($generic_commande->lines); // Loop on each line of order + for ($lig = 0; $lig < $numlines; $lig++) { + if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; } else { - $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; - $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + $reliquat = $generic_commande->lines[$lig]->qty; } + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $generic_commande->lines[$lig]->fk_product; - if ($reliquat > $generic_product->stock_reel) { - $notshippable++; - } - if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; - $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; - } else { // BUGGED CODE. - // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. - // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE - // Detailed virtual stock, looks bugged, uncomplete and need heavy load. - // stock order and stock order_supplier - $stock_order = 0; - $stock_order_supplier = 0; - if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? - if (isModEnabled('commande')) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { - $generic_product->load_stats_commande(0, '1,2'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; - } else { - $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { + $generic_product->load_stock('nobatch,warehouseopen'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } else { + $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } + + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (isModEnabled('commande')) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + } + $stock_order = $generic_product->stats_commande['qty']; } - $stock_order = $generic_product->stats_commande['qty']; + if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + } + } + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; } if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { - $generic_product->load_stats_commande_fournisseur(0, '3'); - $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; - } else { - $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; - } - $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; } - $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); - $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; - if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { - $warning++; - $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } - if ($reliquat > $generic_product->stock_reel) { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } else { - $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; - } - if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || isModEnabled("supplier_order")) { - $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; - } - $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); - $text_info .= '
'; } } + if ($notshippable == 0) { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + } else { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + } } - if ($notshippable == 0) { - $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); - $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; - } else { - $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); - $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + + if ($nbprod) { + print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); + } + if ($warning) { // Always false in default mode + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); } } - - if ($nbprod) { - print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); - } - if ($warning) { // Always false in default mode - print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); + print '
'.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; - 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; + // Billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''.yn($obj->billed).''.dol_escape_htmltag($obj->import_key).''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + 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 ''; + } + print '
'."\n"; + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + print ''; + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + } + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + } + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + } + // Project title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + } + // Thirpdarty + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print ''; + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + } + // Company type + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + } + // Date order + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + } + // Payment term + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.total_vat']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + // Warehouse + print ''; + } + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + // Currency + print ''; + } + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + // Currency rate + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + // Amount VAT + print ''; + } + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + // Amount + print ''; + } + if (!empty($arrayfields['u.login']['checked'])) { + // Author + print ''; + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields); + $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + } + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + } + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + } + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + } + // Shippable + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + } + // Status billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + } + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + print "\n"; + + // Fields title + print ''; + + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + + // Détail commande + if (!empty($arrayfields['pr.ref']['checked'])) { + print_liste_field_titre($arrayfields['pr.ref']['label'], $_SERVER["PHP_SELF"], 'pr.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['pr.desc']['checked'])) { + print_liste_field_titre($arrayfields['pr.desc']['label'], $_SERVER["PHP_SELF"], 'pr.desc', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.qty']['checked'])) { + print_liste_field_titre($arrayfields['cdet.qty']['label'], $_SERVER["PHP_SELF"], 'cdet.qty', '', $param, '', $sortfield, $sortorder); + } + + if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], 'c.ref', '', $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.ref_client']['checked'])) { + print_liste_field_titre($arrayfields['c.ref_client']['label'], $_SERVER["PHP_SELF"], 'c.ref_client', '', $param, '', $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.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], 's.name_alias', '', $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, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['typent.code']['checked'])) { + print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_commande']['checked'])) { + print_liste_field_titre($arrayfields['c.date_commande']['label'], $_SERVER["PHP_SELF"], 'c.date_commande', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print_liste_field_titre($arrayfields['c.date_delivery']['label'], $_SERVER["PHP_SELF"], 'c.date_livraison', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_shipping_method']['label'], $_SERVER["PHP_SELF"], "c.fk_shipping_method", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_cond_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "c.fk_mode_reglement", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_input_reason']['label'], $_SERVER["PHP_SELF"], "c.fk_input_reason", "", $param, '', $sortfield, $sortorder); + } + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ht']['label'], $_SERVER["PHP_SELF"], 'cdet.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"], 'cdet.total_tva', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print_liste_field_titre($arrayfields['cdet.total_ttc']['label'], $_SERVER["PHP_SELF"], 'cdet.total_ttc', '', $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_warehouse']['label'], "", '', '', $param, '', $sortfield, $sortorder); + } + 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); + } + if (!empty($arrayfields['sale_representative']['checked'])) { + print_liste_field_titre($arrayfields['sale_representative']['label'], $_SERVER["PHP_SELF"], "", "", "$param", '', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_pa']['checked'])) { + print_liste_field_titre($arrayfields['total_pa']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin']['checked'])) { + print_liste_field_titre($arrayfields['total_margin']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_margin_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); + } + + $totalarray = array( + 'nbfield' => 0, + 'val' => array( + 'cdet.total_ht' => 0, + 'cdet.total_tva' => 0, + 'cdet.total_ttc' => 0, + ), + 'pos' => array(), + ); + // 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, + 'totalarray' => &$totalarray, + ); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (!empty($arrayfields['c.datec']['checked'])) { + print_liste_field_titre($arrayfields['c.datec']['label'], $_SERVER["PHP_SELF"], "c.date_creation", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.tms']['checked'])) { + print_liste_field_titre($arrayfields['c.tms']['label'], $_SERVER["PHP_SELF"], "c.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['c.date_cloture']['label'], $_SERVER["PHP_SELF"], "c.date_cloture", "", $param, '', $sortfield, $sortorder, 'center nowrap '); + } + if (!empty($arrayfields['c.note_public']['checked'])) { + print_liste_field_titre($arrayfields['c.note_public']['label'], $_SERVER["PHP_SELF"], "c.note_public", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['c.note_private']['checked'])) { + print_liste_field_titre($arrayfields['c.note_private']['label'], $_SERVER["PHP_SELF"], "c.note_private", "", $param, '', $sortfield, $sortorder, 'right '); + } + if (!empty($arrayfields['shippable']['checked'])) { + print_liste_field_titre($arrayfields['shippable']['label'], $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.facture']['checked'])) { + print_liste_field_titre($arrayfields['c.facture']['label'], $_SERVER["PHP_SELF"], 'c.facture', '', $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.import_key']['checked'])) { + print_liste_field_titre($arrayfields['c.import_key']['label'], $_SERVER["PHP_SELF"], "c.import_key", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print_liste_field_titre($arrayfields['c.fk_statut']['label'], $_SERVER["PHP_SELF"], "c.fk_statut", "", $param, '', $sortfield, $sortorder, 'center '); + } + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', $param, '', $sortfield, $sortorder, 'maxwidthsearch center '); + } + print ''."\n"; + + $total = 0; + $subtotal = 0; + $productstat_cache = array(); + $productstat_cachevirtual = array(); + $getNomUrl_cache = array(); + + $generic_commande = new Commande($db); + $generic_product = new Product($db); + $userstatic = new User($db); + $i = 0; + + $with_margin_info = false; + if (!empty($conf->margin->enabled) && ( + !empty($arrayfields['total_pa']['checked']) + || !empty($arrayfields['total_margin']['checked']) + || !empty($arrayfields['total_margin_rate']['checked']) + || !empty($arrayfields['total_mark_rate']['checked']) + ) + ) { + $with_margin_info = true; + } + $total_ht = 0; + $total_margin = 0; + + + // Détail commande + $totalqty = 0; + + $totalarray = array(); + $totalarray['nbfield'] = 0; + $totalarray['val']['cdet.total_tva'] = 0; + $totalarray['val']['cdet.total_ttc'] = 0; + $imaxinloop = ($limit ? min($num, $limit) : $num); + while ($i < $imaxinloop) { + $obj = $db->fetch_object($resql); + + $notshippable = 0; + $warning = 0; + $text_info = ''; + $text_warning = ''; + $nbprod = 0; + + // Print SubTotal + if (empty($i)) { + $oldref = $obj->product_ref; + } + if ($oldref != $obj->product_ref) { + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + $oldref = $obj->product_ref; + } + + $companystatic->id = $obj->socid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->alias; + $companystatic->client = $obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->email = $obj->email; + $companystatic->phone = $obj->phone; + $companystatic->address = $obj->address; + $companystatic->zip = $obj->zip; + $companystatic->town = $obj->town; + $companystatic->country_code = $obj->country_code; + if (!isset($getNomUrl_cache[$obj->socid])) { + $getNomUrl_cache[$obj->socid] = $companystatic->getNomUrl(1, 'customer'); + } + + $generic_commande->id = $obj->c_rowid; + $generic_commande->ref = $obj->ref; + $generic_commande->statut = $obj->fk_statut; + $generic_commande->billed = $obj->billed; + $generic_commande->date = $db->jdate($obj->date_commande); + $generic_commande->date_livraison = $db->jdate($obj->date_delivery); // deprecated + $generic_commande->delivery_date = $db->jdate($obj->date_delivery); + $generic_commande->ref_client = $obj->ref_client; + $generic_commande->total_ht = $obj->c_total_ht; + $generic_commande->total_tva = $obj->c_total_tva; + $generic_commande->total_ttc = $obj->c_total_ttc; + $generic_commande->note_public = $obj->note_public; + $generic_commande->note_private = $obj->note_private; + + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + + $marginInfo = array(); + if ($with_margin_info === true) { + $generic_commande->fetch_lines(); + $marginInfo = $formmargin->getMarginInfosArray($generic_commande); + $total_ht += $obj->total_ht; + $total_margin += $marginInfo['total_margin']; + } + + print ''; + + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Détail commande + // Product Ref + if (!empty($arrayfields['pr.ref']['checked'])) { + if (!empty($obj->product_rowid)) { + $generic_product->id = $obj->product_rowid; + $generic_product->ref = $obj->product_ref; + $generic_product->label = $obj->product_label; + $generic_product->status = $obj->product_status; + $generic_product->status_buy = $obj->product_status_buy; + $generic_product->status_batch = $obj->product_batch; + $generic_product->barcode = $obj->product_barcode; + print ''; + } else { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product Description + if (!empty($arrayfields['pr.desc']['checked'])) { + // print ''; + !empty($obj->product_label) ? $labelproduct = $obj->product_label : $labelproduct = $obj->description; + print ''; + + if (!$i) { + $totalarray['nbfield']++; + } + } + // Product QtyOrdered + if (!empty($arrayfields['cdet.qty']['checked'])) { + print ''; + if (isset($totalarray['val']['cdet.qty'])) { + $totalarray['val']['cdet.qty'] += $obj->qty; + } else { + $totalarray['val']['cdet.qty'] = $obj->qty; + } + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.qty'; + } + } + + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref customer + if (!empty($arrayfields['c.ref_client']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project label + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Order date + if (!empty($arrayfields['c.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Plannned date of delivery + if (!empty($arrayfields['c.date_delivery']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Shipping Method + if (!empty($arrayfields['c.fk_shipping_method']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment terms + if (!empty($arrayfields['c.fk_cond_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['c.fk_mode_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Channel + if (!empty($arrayfields['c.fk_input_reason']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cdet.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ht'; + } + if (isset($totalarray['val']['cdet.total_ht'])) { + $totalarray['val']['cdet.total_ht'] += $obj->total_ht; + } else { + $totalarray['val']['cdet.total_ht'] = $obj->total_ht; + } + } + // Amount VAT + if (!empty($arrayfields['c.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_tva'; + } + $totalarray['val']['cdet.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cdet.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cdet.total_ttc'; + } + $totalarray['val']['cdet.total_ttc'] += $obj->total_ttc; + } + // Warehouse + if (!empty($arrayfields['c.fk_warehouse']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Currency + if (!empty($arrayfields['c.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['c.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['c.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['c.multicurrency_total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['c.multicurrency_total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date cloture + if (!empty($arrayfields['c.date_cloture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note public + if (!empty($arrayfields['c.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['c.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Show shippable Icon (this creates subloops, so may be slow) + if (!empty($arrayfields['shippable']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Billed + if (!empty($arrayfields['c.facture']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Import key + if (!empty($arrayfields['c.import_key']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['c.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // $totalarray['nbfield']--; + // $totalarray['nbfield']--; + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; + $i++; + } + + // Show total line + include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + + // If no record found + if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print ''; + } + + $db->free($resql); + + $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); + $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->select_country($search_country, 'search_country', '', 0, 'minwidth100imp maxwidth100'); + print ''; + print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT), '', 1); + print ''; + print '
'; + print $form->selectDate($search_dateorder_start ? $search_dateorder_start : -1, 'search_dateorder_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_dateorder_end ? $search_dateorder_end : -1, 'search_dateorder_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_start ? $search_datedelivery_start : -1, 'search_datedelivery_start_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datedelivery_end ? $search_datedelivery_end : -1, 'search_datedelivery_end_', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + $form->selectShippingMethod($search_fk_shipping_method, 'search_fk_shipping_method', '', 1, '', 1); + print ''; + $form->select_conditions_paiements($search_fk_cond_reglement, 'search_fk_cond_reglement', 1, 1, 1); + print ''; + $form->select_types_paiements($search_fk_mode_reglement, 'search_fk_mode_reglement', '', 0, 1, 1, 0, -1); + print ''; + $form->selectInputReason($search_fk_input_reason, 'search_fk_input_reason', '', 1, '', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print $form->selectMultiCurrency($search_multicurrency_code, 'search_multicurrency_code', 1); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $form->selectDate($search_datecloture_start ? $search_datecloture_start : -1, 'search_datecloture_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search_datecloture_end ? $search_datecloture_end : -1, 'search_datecloture_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; + print ''; + print ''; + //print $form->selectyesno('search_shippable', $search_shippable, 1, 0, 1, 1); + if (!empty($conf->global->ORDER_SHIPABLE_STATUS_DISABLED_BY_DEFAULT)) { + print ''; + print $langs->trans('ShowShippableStatus'); + } else { + $show_shippable_command = 1; + } + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, 0, 1, 1); + print ''; + print ''; + $liststatus = array( + Commande::STATUS_DRAFT=>$langs->trans("StatusOrderDraftShort"), + Commande::STATUS_VALIDATED=>$langs->trans("StatusOrderValidated"), + Commande::STATUS_SHIPMENTONPROCESS=>$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CLOSED=>$langs->trans("StatusOrderDelivered"), + -3=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort").'+'.$langs->trans("StatusOrderDelivered"), + -2=>$langs->trans("StatusOrderValidatedShort").'+'.$langs->trans("StatusOrderSentShort"), + Commande::STATUS_CANCELED=>$langs->trans("StatusOrderCanceledShort") + ); + print $form->selectarray('search_status', $liststatus, $search_status, -5, 0, 0, '', 0, 0, 0, '', 'maxwidth125', 1); + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + 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 ''; + } + print ''.$generic_product->getNomUrl(1).'Ligne libre'.$obj->description.''.dol_escape_htmltag($labelproduct).''.$obj->qty.''; + print $generic_commande->getNomUrl(1, ($search_status != 2 ? 0 : $obj->fk_statut), 0, 0, 0, 1, 1); + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->commande->multidir_output[$conf->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($generic_commande->element, $filename, $filedir); + + print ''.$obj->ref_client.''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print $projectstatic->title; + } + print ''; + print $getNomUrl_cache[$obj->socid]; + + // If module invoices enabled and user with invoice creation permissions + if (isModEnabled('facture') && !empty($conf->global->ORDER_BILLING_ALL_CUSTOMER)) { + if ($user->rights->facture->creer) { + if (($obj->fk_statut > 0 && $obj->fk_statut < 3) || ($obj->fk_statut == 3 && $obj->billed == 0)) { + print ' '; + print img_picto($langs->trans("CreateInvoiceForThisCustomer").' : '.$companystatic->name, 'object_bill', 'hideonsmartphone').''; + } + } + } + print ''; + print $obj->alias; + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + // Warning late icon and note + if ($generic_commande->hasDelay()) { + print img_picto($langs->trans("Late").' : '.$generic_commande->showDelay(), "warning"); + } + print ''; + print dol_print_date($db->jdate($obj->date_delivery), 'dayhour'); + print ''; + $form->formSelectShippingMethod('', $obj->fk_shipping_method, 'none', 1); + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', 1, $obj->deposit_percent); + print ''; + $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1); + print ''; + $form->formInputReason($_SERVER['PHP_SELF'], $obj->fk_input_reason, 'none', ''); + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'; + if ($obj->warehouse > 0) { + print img_picto('', 'stock', 'class="paddingrightonly"'); + } + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'], $obj->warehouse, 'none'); + print "'.$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)."'; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); + } else { + print ' '; + } + print "'; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_cloture), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($show_shippable_command) && !empty($conf->stock->enabled)) { + if (($obj->fk_statut > $generic_commande::STATUS_DRAFT) && ($obj->fk_statut < $generic_commande::STATUS_CLOSED)) { + $generic_commande->getLinesArray(); // Load array ->lines + $generic_commande->loadExpeditions(); // Load array ->expeditions + + $numlines = count($generic_commande->lines); // Loop on each line of order + for ($lig = 0; $lig < $numlines; $lig++) { + if (isset($generic_commande->expeditions[$generic_commande->lines[$lig]->id])) { + $reliquat = $generic_commande->lines[$lig]->qty - $generic_commande->expeditions[$generic_commande->lines[$lig]->id]; + } else { + $reliquat = $generic_commande->lines[$lig]->qty; + } + if ($generic_commande->lines[$lig]->product_type == 0 && $generic_commande->lines[$lig]->fk_product > 0) { // If line is a product and not a service + $nbprod++; // order contains real products + $generic_product->id = $generic_commande->lines[$lig]->fk_product; + + // Get local and virtual stock and store it into cache + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product])) { + $generic_product->load_stock('nobatch'); // ->load_virtual_stock() is already included into load_stock() + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_reel; + $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } else { + $generic_product->stock_reel = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stock_reel']; + $generic_product->stock_theorique = $productstat_cachevirtual[$generic_commande->lines[$lig]->fk_product]['stock_reel'] = $generic_product->stock_theorique; + } + + if ($reliquat > $generic_product->stock_reel) { + $notshippable++; + } + if (empty($conf->global->SHIPPABLE_ORDER_ICON_IN_LIST)) { // Default code. Default should be this case. + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->product_ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_info .= ' - '.$langs->trans("Stock").': '.$generic_product->stock_reel.''; + $text_info .= ' - '.$langs->trans("VirtualStock").': '.$generic_product->stock_theorique.''; + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } else { // BUGGED CODE. + // DOES NOT TAKE INTO ACCOUNT MANUFACTURING. THIS CODE SHOULD BE USELESS. PREVIOUS CODE SEEMS COMPLETE. + // COUNT STOCK WHEN WE SHOULD ALREADY HAVE VALUE + // Detailed virtual stock, looks bugged, uncomplete and need heavy load. + // stock order and stock order_supplier + $stock_order = 0; + $stock_order_supplier = 0; + if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) || !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { // What about other options ? + if (!empty($conf->commande->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'])) { + $generic_product->load_stats_commande(0, '1,2'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer'] = $generic_product->stats_commande['qty']; + } else { + $generic_product->stats_commande['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_customer']; + } + $stock_order = $generic_product->stats_commande['qty']; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + if (empty($productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'])) { + $generic_product->load_stats_commande_fournisseur(0, '3'); + $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier'] = $generic_product->stats_commande_fournisseur['qty']; + } else { + $generic_product->stats_commande_fournisseur['qty'] = $productstat_cache[$generic_commande->lines[$lig]->fk_product]['stats_order_supplier']; + } + $stock_order_supplier = $generic_product->stats_commande_fournisseur['qty']; + } + } + $text_info .= $reliquat.' x '.$generic_commande->lines[$lig]->ref.' '.dol_trunc($generic_commande->lines[$lig]->product_label, 20); + $text_stock_reel = $generic_product->stock_reel.'/'.$stock_order; + if ($stock_order > $generic_product->stock_reel && !($generic_product->stock_reel < $generic_commande->lines[$lig]->qty)) { + $warning++; + $text_warning .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ($reliquat > $generic_product->stock_reel) { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } else { + $text_info .= ''.$langs->trans('Available').' : '.$text_stock_reel.''; + } + if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) { + $text_info .= ' '.$langs->trans('SupplierOrder').' : '.$stock_order_supplier; + } + $text_info .= ($reliquat != $generic_commande->lines[$lig]->qty ? ' ('.$langs->trans("QtyInOtherShipments").' '.($generic_commande->lines[$lig]->qty - $reliquat).')' : ''); + $text_info .= '
'; + } + } + } + if ($notshippable == 0) { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'green paddingleft'); + $text_info = $text_icon.' '.$langs->trans('Shippable').'
'.$text_info; + } else { + $text_icon = img_picto('', 'dolly', '', false, 0, 0, '', 'error paddingleft'); + $text_info = $text_icon.' '.$langs->trans('NonShippable').'
'.$text_info; + } + } + + if ($nbprod) { + print $form->textwithtooltip('', $text_info, 2, 1, $text_icon, '', 2); + } + if ($warning) { // Always false in default mode + print $form->textwithtooltip('', $langs->trans('NotEnoughForAllOrders').'
'.$text_warning, 2, 1, img_picto('', 'error'), '', 2); + } + } + print '
'.yn($obj->billed).''.$obj->import_key.''.$generic_commande->LibStatut($obj->fk_statut, $obj->billed, 5, 1).''; + 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 ''; + } + print '
'.$langs->trans("NoRecordFound").'
'."\n"; + print ''; + + print ''."\n"; + + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_orders', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); +} else { + dol_print_error($db); +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index e84dd5ad6e1..57eb073bba3 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -113,7 +113,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 819a6ecb74f..a6a1fde3851 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -46,12 +46,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { $trclass .= ' liste_sub_total'; } echo '
'.$langs->trans("CustomerOrder"); + echo ''.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; - echo ''.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.$objectlink->ref_client.''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 2f2f5816ae1..af8d626eba1 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -376,6 +376,9 @@ if (($action == 'searchfiles' || $action == 'dl')) { $nofile['country_code'] = $objd->country_code; $nofile['vatnum'] = $objd->vatnum; $nofile['sens'] = $objd->sens; + $nofile['currency'] = $objd->currency; + $nofile['link'] = ''; + $nofile['name'] = ''; $filesarray[$nofile['item'].'_'.$nofile['id']] = $nofile; } else { @@ -396,6 +399,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { $file['country_code'] = $objd->country_code; $file['vatnum'] = $objd->vatnum; $file['sens'] = $objd->sens; + $file['currency'] = $objd->currency; // Save record into array (only the first time it is found) if (empty($filesarray[$file['item'].'_'.$file['id']])) { @@ -415,6 +419,7 @@ if (($action == 'searchfiles' || $action == 'dl')) { 'relpathnamelang' => $langs->trans($file['item']).'/'.$file['name'], 'modulepart' => $modulepart, 'subdir' => $subdir, + 'currency' => $file['currency'] ); //var_dump($file['item'].'_'.$file['id']); //var_dump($filesarray[$file['item'].'_'.$file['id']]['files']); diff --git a/htdocs/compta/ajaxpayment.php b/htdocs/compta/ajaxpayment.php index aeb8d164928..a0c45ff0ed0 100644 --- a/htdocs/compta/ajaxpayment.php +++ b/htdocs/compta/ajaxpayment.php @@ -72,6 +72,10 @@ if (is_array($remains)) { unset($remains[$key]); } } +} elseif ($remains) { + $remains = array(price2num($remains)); +} else { + $remains = array(); } // Treatment @@ -109,7 +113,7 @@ if ($currentInvId) { // Here to breakdown $result -= $amountToBreakdown; // And canceled substraction has been replaced by breakdown } // else there's no need to calc anything, just reset the field (result is still < 0) } - $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount).""; // Param will exist only if an img has been clicked + $toJsonArray['amount_'.$currentInvId] = price2num($currentAmount); // Param will exist only if an img has been clicked } $toJsonArray['makeRed'] = ($totalRemaining < price2num($result) || price2num($result) < 0) ? true : false; diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index b0514c71ee6..6c961e85af9 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -1134,8 +1134,8 @@ if ($resql) { } // Conciliated if (!empty($arrayfields['b.conciliated']['checked'])) { - print ''; - print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1); + print ''; + print $form->selectyesno('search_conciliated', $search_conciliated, 1, false, 1, 1, 'search_status onrightofpage maxwidth75'); print ''.$langs->trans($val).'
'.$langs->trans($ibankey).'
'.$langs->trans($bickey).'
'.$langs->trans("SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation").'
'.$langs->trans("BankAccountDomiciliation").''; print '
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankName").'
'.$langs->trans($val).'
'; + print ''; $array = array( 'opened'=>$langs->trans("Opened"), 'closed'=>$langs->trans("Closed") @@ -584,224 +593,236 @@ foreach ($accounts as $key => $type) { $lastcurrencycode = $objecttmp->currency_code; } - print '
'; - 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($objecttmp->id, $arrayofselected)) { - $selected = 1; + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + print $objecttmp->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; + 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($objecttmp->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''.$objecttmp->getNomUrl(1).''.dol_escape_htmltag($objecttmp->label).''; - print $objecttmp->type_lib[$objecttmp->type]; - print ''.dol_escape_htmltag($objecttmp->number).''; - if (isModEnabled('accounting') && !empty($objecttmp->account_number)) { - $accountingaccount = new AccountingAccount($db); - $accountingaccount->fetch('', $objecttmp->account_number, 1); - print ''; - print $accountingaccount->getNomUrl(0, 1, 1, '', 0); - print ''; - } else { - print ''.$objecttmp->account_number.''; - } - print ''; - if (isModEnabled('accounting')) { - if (empty($objecttmp->fk_accountancy_journal)) { - print img_warning($langs->trans("Mandatory")); - } else { - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objecttmp->fk_accountancy_journal); - print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + // Ref + if (!empty($arrayfields['b.ref']['checked'])) { + print ''.$objecttmp->getNomUrl(1).''; - print $objecttmp->currency_code; - print ''; - if ($conciliate == -2) { - print ''.$langs->trans("CashAccount").''; - } elseif ($conciliate == -3) { - print ''.$langs->trans("Closed").''; - } elseif (empty($objecttmp->rappro)) { - print ''.$langs->trans("ConciliationDisabled").''; - } else { - $result = $objecttmp->load_board($user, $objecttmp->id); - if (is_numeric($result) && $result < 0) { - setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); - } else { - print ''; - print ''; - print $result->nbtodo; + // Label + if (!empty($arrayfields['b.label']['checked'])) { + print ''.dol_escape_htmltag($objecttmp->label).''; + print $objecttmp->type_lib[$objecttmp->type]; + print ''.dol_escape_htmltag($objecttmp->number).''; + if (isModEnabled('accounting') && !empty($objecttmp->account_number)) { + $accountingaccount = new AccountingAccount($db); + $accountingaccount->fetch('', $objecttmp->account_number, 1); + print ''; + print $accountingaccount->getNomUrl(0, 1, 1, '', 0); print ''; - print ''; - if ($result->nbtodolate) { - print ''; - print ' '.$result->nbtodolate; + } else { + print ''.$objecttmp->account_number.''; + } + print ''; + if (isModEnabled('accounting')) { + if (empty($objecttmp->fk_accountancy_journal)) { + print img_warning($langs->trans("Mandatory")); + } else { + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objecttmp->fk_accountancy_journal); + print $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + } else { + print ''; + } + print ''; + print $objecttmp->currency_code; + print ''; + if ($conciliate == -2) { + print ''.$langs->trans("CashAccount").''; + } elseif ($conciliate == -3) { + print ''.$langs->trans("Closed").''; + } elseif (empty($objecttmp->rappro)) { + print ''.$langs->trans("ConciliationDisabled").''; + } else { + $result = $objecttmp->load_board($user, $objecttmp->id); + if (is_numeric($result) && $result < 0) { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + } else { + print ''; + print ''; + print $result->nbtodo; print ''; + print ''; + if ($result->nbtodolate) { + print ''; + print ' '.$result->nbtodolate; + print ''; + } } } - } - print ''; - print dol_print_date($objecttmp->date_creation, 'dayhour'); - print ''; - print dol_print_date($objecttmp->date_update, 'dayhour'); - print ''.$objecttmp->getLibStatut(5).''; - print ''; - print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; - print ''; - print ''; - 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($objecttmp->id, $arrayofselected)) { - $selected = 1; + print '
'; + print dol_print_date($objecttmp->date_creation, 'dayhour'); + print ''; + print dol_print_date($objecttmp->date_update, 'dayhour'); + print ''.$objecttmp->getLibStatut(5).''; + print ''; + print ''.price($solde, 0, $langs, 1, -1, -1, $objecttmp->currency_code).''; + print ''; + print ''; + 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($objecttmp->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
".$refcomp."'.price(abs($total_ttc))."  '.price($total_ttc)."'.price($solde).'
'; print '
'; print $formaccounting->select_account($search_accountancy_account, 'search_accountancy_account', 1, array(), 1, 1, 'maxwidth200'); @@ -475,7 +485,7 @@ if ($resql) { } // Subledger account - if ($arrayfields['subledger']['checked']) { + if (!empty($arrayfields['subledger']['checked'])) { print '
'; print '
'; print $formaccounting->select_auxaccount($search_accountancy_subledger, 'search_accountancy_subledger', 1, 'maxwidth200'); @@ -484,7 +494,7 @@ if ($resql) { } // Debit - if ($arrayfields['debit']['checked']) { + if (!empty($arrayfields['debit']['checked'])) { print '
'; print ''; print '
'.(($offset * $limit) + $i).''.$variousstatic->getNomUrl(1)."
'; + print '
'; } - } + // Output Kanban - // Label payment - if ($arrayfields['label']['checked']) { - print '
'.$variousstatic->label."
'.dol_print_date($obj->datep, 'day')."'.(($offset * $limit) + $i).''.dol_print_date($obj->datev, 'day')."'; - if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code); - print ' '; - } - print $obj->num_payment; - print ''; - if ($obj->fk_project > 0) { - $proj->fetch($obj->fk_project); - print $proj->getNomUrl(1); - } - print ''; - if ($obj->bid > 0) { - $accountstatic->id = $obj->bid; - $accountstatic->ref = $obj->bref; - $accountstatic->number = $obj->bnumber; - - if (isModEnabled('accounting')) { - $accountstatic->account_number = $obj->bank_account_number; - $accountingjournal->fetch($obj->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + // Ref + if ($arrayfields['ref']['checked']) { + print ''.$variousstatic->getNomUrl(1)."'.$variousstatic->label."'.dol_print_date($obj->datep, 'day')."'.dol_print_date($obj->datev, 'day')."'; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ' '; + } + print $obj->num_payment; + print ''; + if ($obj->fk_project > 0) { + $proj->fetch($obj->fk_project); + print $proj->getNomUrl(1); + } + print ''; + if ($obj->bid > 0) { + $accountstatic->id = $obj->bid; + $accountstatic->ref = $obj->bref; + $accountstatic->number = $obj->bnumber; + + if (isModEnabled('accounting')) { + $accountstatic->account_number = $obj->bank_account_number; + $accountingjournal->fetch($obj->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + + $accountstatic->label = $obj->blabel; + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''.$bankline->getNomUrl(1).''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.length_accounta($obj->subledger_account).''; + if ($obj->sens == 0) { + print ''.price($obj->amount).''; + $totalarray['val']['total_deb'] += $obj->amount; + } + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; + } + print ''; + if ($obj->sens == 1) { + print ''.price($obj->amount).''; + $totalarray['val']['total_cred'] += $obj->amount; + } + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; + } + print '
'.$bankline->getNomUrl(1).''.$accountingaccount->getNomUrl(0, 1, 1, '', 1).''.length_accounta($obj->subledger_account).''; - if ($obj->sens == 0) { - print ''.price($obj->amount).''; - $totalarray['val']['total_deb'] += $obj->amount; - } - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_deb'; - } - print ''; - if ($obj->sens == 1) { - print ''.price($obj->amount).''; - $totalarray['val']['total_cred'] += $obj->amount; - } - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_cred'; - } - print '
'; + print '
'; } - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } + $object->posmodule = $obj->posmodule; + $object->cash = $obj->cash; + $object->opening = $obj->opening; + $object->year_close = $obj->year_close; + $object->cheque = $obj->cheque; - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - if (!empty($arrayfields['t.'.$key]['checked'])) { - print 'getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; - 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($object->id, $arrayofselected)) { - $selected = 1; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'; - print ''; - // Year NP - print ''; @@ -335,72 +335,97 @@ if ($modecompta == 'CREANCES-DETTES') { // Previous Fiscal year (N-1) foreach ($sommes as $code => $det) { - $vars[$code] = $det['NP']; + $vars[$code] = empty($det['NP']) ? 0 : $det['NP']; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); - //var_dump($result); - //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, '1'); - //var_dump($r); + if (preg_match('/[a-z]/i', $result)) { + $r = 'Error bad formula: '.$result; + $rshort = 'Err'; + print ''; + } else { + //var_dump($result); + //$r = $AccCat->calculate($result); + $r = dol_eval($result, 1, 1, '1'); - print ''; + print ''; + } // Year N $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...) - $sommes[$code]['NP'] += $r; + if (empty($sommes[$code]['NP'])) { + $sommes[$code]['NP'] = $r; + } else { + $sommes[$code]['NP'] += $r; + } // Current fiscal year (N) if (is_array($sommes) && !empty($sommes)) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['N']; + $vars[$code] = empty($det['N']) ? 0 : $det['N']; } } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); - print ''; - $sommes[$code]['N'] += $r; + print ''; + if (empty($sommes[$code]['N'])) { + $sommes[$code]['N'] = $r; + } else { + $sommes[$code]['N'] += $r; + } // Detail by month foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['M'][$k]; + $vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; - $sommes[$code]['M'][$k] += $r; + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $r; + } else { + $sommes[$code]['M'][$k] += $r; + } } } + foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { foreach ($sommes as $code => $det) { - $vars[$code] = $det['M'][$k]; + $vars[$code] = empty($det['M'][$k]) ? 0 : $det['M'][$k]; } $result = strtr($formula, $vars); + $result = str_replace('--', '+', $result); //$r = $AccCat->calculate($result); - $r = dol_eval($result, 1, 1, 1); + $r = dol_eval($result, 1, 1, '1'); print ''; - $sommes[$code]['M'][$k] += $r; + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $r; + } else { + $sommes[$code]['M'][$k] += $r; + } } } print "\n"; //var_dump($sommes); - } else // normal category - { + } else { // normal category $code = $cat['code']; // Category code we process $totCat = array(); @@ -414,27 +439,37 @@ if ($modecompta == 'CREANCES-DETTES') { // Set $cpts with array of accounts in the category/group $cpts = $AccCat->getCptsCat($cat['rowid']); // We should loop over empty $cpts array, else the category _code_ is used in the formula, which leads to wrong result if the code is a number. - if (empty($cpts)) $cpts[] = array(); - + if (empty($cpts)) { + $cpts[] = array(); + } $arrayofaccountforfilter = array(); foreach ($cpts as $i => $cpt) { // Loop on each account. - $arrayofaccountforfilter[] = $cpt['account_number']; + if (isset($cpt['account_number'])) { + $arrayofaccountforfilter[] = $cpt['account_number']; + } } // N-1 if (!empty($arrayofaccountforfilter)) { - $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0); - + $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, empty($cat['dc']) ? 0 : $cat['dc']); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultNP = 0; } else { - foreach ($cpts as $i => $cpt) { // Loop on each account. + foreach ($cpts as $i => $cpt) { // Loop on each account found $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']]; - $totCat['NP'] += $resultNP; - $sommes[$code]['NP'] += $resultNP; + if (empty($totCat['NP'])) { + $totCat['NP'] = $resultNP; + } else { + $totCat['NP'] += $resultNP; + } + if (empty($sommes[$code]['NP'])) { + $sommes[$code]['NP'] = $resultNP; + } else { + $sommes[$code]['NP'] += $resultNP; + } $totPerAccount[$cpt['account_number']]['NP'] = $resultNP; } } @@ -456,63 +491,88 @@ if ($modecompta == 'CREANCES-DETTES') { } //var_dump($monthtoprocess.'_'.$yeartoprocess); - $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess); - if ($return < 0) { - setEventMessages(null, $AccCat->errors, 'errors'); - $resultM = 0; + if (isset($cpt['account_number'])) { + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, empty($cat['dc']) ? 0 : $cat['dc'], 'nofilter', $monthtoprocess, $yeartoprocess); + if ($return < 0) { + setEventMessages(null, $AccCat->errors, 'errors'); + $resultM = 0; + } else { + $resultM = $AccCat->sdc; + } } else { - $resultM = $AccCat->sdc; + $resultM = 0; + } + if (empty($totCat['M'][$k])) { + $totCat['M'][$k] = $resultM; + } else { + $totCat['M'][$k] += $resultM; + } + if (empty($sommes[$code]['M'][$k])) { + $sommes[$code]['M'][$k] = $resultM; + } else { + $sommes[$code]['M'][$k] += $resultM; + } + if (isset($cpt['account_number'])) { + $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; } - $totCat['M'][$k] += $resultM; - $sommes[$code]['M'][$k] += $resultM; - $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM; $resultN += $resultM; } - $totCat['N'] += $resultN; - $sommes[$code]['N'] += $resultN; - $totPerAccount[$cpt['account_number']]['N'] = $resultN; + if (empty($totCat)) { + $totCat['N'] = $resultN; + } else { + $totCat['N'] += $resultN; + } + if (empty($sommes[$code]['N'])) { + $sommes[$code]['N'] = $resultN; + } else { + $sommes[$code]['N'] += $resultN; + } + if (isset($cpt['account_number'])) { + $totPerAccount[$cpt['account_number']]['N'] = $resultN; + } } // Now output columns for row $code ('VTE', 'MAR', ...) - print ""; + print ''; // Column group - print ''; // Label of group - print ''; print ''; - print ''; + print ''; // Each month foreach ($totCat['M'] as $k => $v) { @@ -531,30 +591,48 @@ if ($modecompta == 'CREANCES-DETTES') { // Loop on detail of all accounts to output the detail if ($showaccountdetail != 'no') { foreach ($cpts as $i => $cpt) { - $resultNP = $totPerAccount[$cpt['account_number']]['NP']; - $resultN = $totPerAccount[$cpt['account_number']]['N']; + if (isset($cpt['account_number'])) { + $resultNP = $totPerAccount[$cpt['account_number']]['NP']; + $resultN = $totPerAccount[$cpt['account_number']]['N']; + } else { + $resultNP = 0; + $resultN = 0; + } if ($showaccountdetail == 'all' || $resultN != 0) { print ''; print ''; - print ''; print ''; - print ''; + print ''; // Make one call for each month foreach ($months as $k => $v) { if (($k + 1) >= $date_startmonth) { - $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + if (isset($cpt['account_number'])) { + $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + } else { + $resultM = 0; + } print ''; } } foreach ($months as $k => $v) { if (($k + 1) < $date_startmonth) { - $resultM = $totPerAccount[$cpt['account_number']]['M'][$k]; + if (isset($cpt['account_number'])) { + $resultM = empty($totPerAccount[$cpt['account_number']]['M'][$k]) ? 0 : $totPerAccount[$cpt['account_number']]['M'][$k]; + } else { + $resultM = 0; + } print ''; } } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 7c644c63e38..adb525c7d5e 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -557,7 +557,7 @@ if ($id > 0) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -632,7 +632,7 @@ if ($id > 0) { print '
'; + print ''; - if ($action != 'editretainedwarranty' && $user->rights->facture->creer) { + if ($action != 'editretainedwarranty' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } print '
'; print $langs->trans('RetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setretainedwarranty'), 1).'
'; print '
'; - if ($action == 'editretainedwarranty') { + if ($action == 'editretainedwarranty' && $object->statut == Facture::STATUS_DRAFT) { print '
'; print ''; print ''; @@ -4704,7 +4703,7 @@ if ($action == 'create') { print ''; - if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantypaymentterms' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4715,7 +4714,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantypaymentterms') { + if ($action == 'editretainedwarrantypaymentterms' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -4739,7 +4738,7 @@ if ($action == 'create') { print '
'; print $langs->trans('PaymentConditionsShortRetainedWarranty'); print 'id.'">'.img_edit($langs->trans('setPaymentConditionsShortRetainedWarranty'), 1).'
'; - if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer) { + if ($action != 'editretainedwarrantydatelimit' && $user->rights->facture->creer && $object->statut == Facture::STATUS_DRAFT) { print ''; } @@ -4750,7 +4749,7 @@ if ($action == 'create') { $defaultDate = $object->date; } - if ($action == 'editretainedwarrantydatelimit') { + if ($action == 'editretainedwarrantydatelimit' && $object->statut == Facture::STATUS_DRAFT) { //date('Y-m-d',$object->date_lim_reglement) print ''; print ''; @@ -5423,7 +5422,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); + $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); } // Form to add new line diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 4c1392e28eb..bae53bce6a8 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -65,9 +65,9 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of invoice - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -81,9 +81,9 @@ class Invoices extends DolibarrApi * * 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, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @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, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref/{ref} * @@ -99,9 +99,9 @@ class Invoices extends DolibarrApi * * 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, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @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, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @url GET ref_ext/{ref_ext} * @@ -117,11 +117,11 @@ class Invoices extends DolibarrApi * * 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, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @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, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ @@ -325,12 +325,11 @@ class Invoices extends DolibarrApi /** * Create an invoice using an existing order. * - * * @param int $orderid Id of the order + * @return Object Object with cleaned properties * * @url POST /createfromorder/{orderid} * - * @return int * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -338,7 +337,6 @@ class Invoices extends DolibarrApi */ public function createInvoiceFromOrder($orderid) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; if (!DolibarrApiAccess::$user->rights->commande->lire) { @@ -368,11 +366,10 @@ class Invoices extends DolibarrApi /** * Get lines of an invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array Array of lines * * @url GET {id}/lines - * - * @return int */ public function getLines($id) { @@ -399,14 +396,13 @@ class Invoices extends DolibarrApi /** * Update a line to a given invoice * - * @param int $id Id of invoice to update - * @param int $lineid Id of line to update - * @param array $request_data InvoiceLine data + * @param int $id Id of invoice to update + * @param int $lineid Id of line to update + * @param array $request_data InvoiceLine data + * @return Object Object with cleaned properties * * @url PUT {id}/lines/{lineid} * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 Invoice not found @@ -472,14 +468,13 @@ class Invoices extends DolibarrApi /** * Add a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Id of contact to add - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @param int $id Id of invoice to update + * @param int $contactid Id of contact to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * @return array * * @url POST {id}/contact/{contactid}/{type} * - * @return int - * * @throws RestException 401 * @throws RestException 404 */ @@ -509,20 +504,24 @@ class Invoices extends DolibarrApi throw new RestException(500, 'Error when added the contact'); } - return $this->_cleanObjectDatas($this->invoice); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the invoice' + ) + ); } /** * Delete a contact type of given invoice * - * @param int $id Id of invoice to update - * @param int $contactid Row key of the contact in the array contact_ids. - * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @param int $id Id of invoice to update + * @param int $contactid Row key of the contact in the array contact_ids. + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER). + * @return Object Object with cleaned properties * * @url DELETE {id}/contact/{contactid}/{type} * - * @return array - * * @throws RestException 401 * @throws RestException 404 * @throws RestException 500 System error @@ -561,13 +560,12 @@ class Invoices extends DolibarrApi /** * Deletes a line of a given invoice * - * @param int $id Id of invoice - * @param int $lineid Id of the line to delete + * @param int $id Id of invoice + * @param int $lineid Id of the line to delete + * @return Object Object with cleaned properties * * @url DELETE {id}/lines/{lineid} * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -575,7 +573,6 @@ class Invoices extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -592,9 +589,7 @@ class Invoices extends DolibarrApi throw new RestException(404, 'Invoice not found'); } - // TODO Check the lineid $lineid is a line of ojbect - - $updateRes = $this->invoice->deleteline($lineid); + $updateRes = $this->invoice->deleteline($lineid, $id); if ($updateRes > 0) { return $this->get($id); } else { @@ -605,9 +600,9 @@ class Invoices extends DolibarrApi /** * Update invoice * - * @param int $id Id of invoice to update - * @param array $request_data Datas - * @return int + * @param int $id Id of invoice to update + * @param array $request_data Datas + * @return Object|false Object with cleaned properties */ public function put($id, $request_data = null) { @@ -648,8 +643,8 @@ class Invoices extends DolibarrApi /** * Delete invoice * - * @param int $id Invoice ID - * @return array + * @param int $id Invoice ID + * @return array */ public function delete($id) { @@ -829,11 +824,10 @@ class Invoices extends DolibarrApi * * @param int $id Order ID * @param int $idwarehouse Warehouse ID + * @return Object Object with cleaned properties * * @url POST {id}/settodraft * - * @return array - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -887,10 +881,9 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @param int $idwarehouse Warehouse ID * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @return Object|false Object with cleaned properties * * @url POST {id}/validate - * - * @return array */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { @@ -932,11 +925,10 @@ class Invoices extends DolibarrApi * @param int $id Order ID * @param string $close_code Code filled if we classify to 'Paid completely' when payment is not complete (for escompte for example) * @param string $close_note Comment defined if we classify to 'Paid' when payment is not complete (for escompte for example) + * @return Object Object with cleaned properties * * @url POST {id}/settopaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -981,12 +973,11 @@ class Invoices extends DolibarrApi /** * Sets an invoice as unpaid * - * @param int $id Order ID + * @param int $id Order ID + * @return Object Object with cleaned properties * * @url POST {id}/settounpaid * - * @return array An invoice object - * * @throws RestException 304 * @throws RestException 401 * @throws RestException 404 @@ -1031,10 +1022,9 @@ class Invoices extends DolibarrApi * Get discount from invoice * * @param int $id Id of invoice + * @return Object Object with cleaned properties * * @url GET {id}/discount - * - * @return mixed */ public function getDiscount($id) { @@ -1069,10 +1059,10 @@ class Invoices extends DolibarrApi /** * Create a discount (credit available) for a credit note or a deposit. * - * @param int $id Invoice ID - * @url POST {id}/markAsCreditAvailable + * @param int $id Invoice ID + * @return Object Object with cleaned properties * - * @return array An invoice object + * @url POST {id}/markAsCreditAvailable * * @throws RestException 304 * @throws RestException 401 @@ -1241,11 +1231,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of discount + * @return int * * @url POST {id}/usediscount/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1253,7 +1242,6 @@ class Invoices extends DolibarrApi */ public function useDiscount($id, $discountid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } @@ -1288,11 +1276,10 @@ class Invoices extends DolibarrApi * * @param int $id Id of invoice * @param int $discountid Id of a discount coming from a credit note + * @return int * * @url POST {id}/usecreditnote/{discountid} * - * @return int - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1300,7 +1287,6 @@ class Invoices extends DolibarrApi */ public function useCreditNote($id, $discountid) { - require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1333,12 +1319,11 @@ class Invoices extends DolibarrApi /** * Get list of payments of a given invoice * - * @param int $id Id of invoice + * @param int $id Id of invoice + * @return array * * @url GET {id}/payments * - * @return array - * * @throws RestException 400 * @throws RestException 401 * @throws RestException 404 @@ -1395,8 +1380,6 @@ class Invoices extends DolibarrApi */ public function addPayment($id, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '') { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1509,6 +1492,7 @@ class Invoices extends DolibarrApi * @url POST /paymentsdistributed * * @return int Payment ID + * * @throws RestException 400 * @throws RestException 401 * @throws RestException 403 @@ -1516,8 +1500,6 @@ class Invoices extends DolibarrApi */ public function addPaymentDistributed($arrayofamounts, $datepaye, $paymentid, $closepaidinvoices, $accountid, $num_payment = '', $comment = '', $chqemetteur = '', $chqbank = '', $ref_ext = '', $accepthigherpayment = false) { - global $conf; - require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (!DolibarrApiAccess::$user->rights->facture->creer) { @@ -1645,6 +1627,7 @@ class Invoices extends DolibarrApi * @url PUT payments/{id} * * @return array + * * @throws RestException 400 Bad parameters * @throws RestException 401 Not allowed * @throws RestException 404 Not found @@ -1708,8 +1691,8 @@ class Invoices extends DolibarrApi /** * Validate fields before create or update object * - * @param array|null $data Datas to validate - * @return array + * @param array|null $data Datas to validate + * @return array * * @throws RestException */ @@ -1733,7 +1716,7 @@ class Invoices extends DolibarrApi * * @param int $id ID of template invoice * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @return Object Object with cleaned properties * * @url GET templates/{id} * @@ -1749,11 +1732,11 @@ class Invoices extends DolibarrApi * * 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, -1: Do not return contacts/adddesses - * @return array|mixed data without useless information + * @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, -1: Do not return contacts/adddesses + * @return Object Object with cleaned properties * * @throws RestException */ diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 3a586dfc3e5..269c5267ab3 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -169,7 +169,7 @@ class FactureRec extends CommonInvoice 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>20, 'index'=>1), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>25), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>25), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>30), //'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), 'remise' =>array('type'=>'double', 'label'=>'Remise', 'enabled'=>1, 'visible'=>-1, 'position'=>40), @@ -188,13 +188,12 @@ class FactureRec extends CommonInvoice 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>105), 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110), 'modelpdf' =>array('type'=>'varchar(255)', 'label'=>'Modelpdf', 'enabled'=>1, 'visible'=>-1, 'position'=>115), - 'date_last_gen' =>array('type'=>'varchar(7)', 'label'=>'Last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>120), - 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'Unit frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>125), 'date_when' =>array('type'=>'datetime', 'label'=>'Date when', 'enabled'=>1, 'visible'=>-1, 'position'=>130), 'date_last_gen' =>array('type'=>'datetime', 'label'=>'Date last gen', 'enabled'=>1, 'visible'=>-1, 'position'=>135), 'nb_gen_done' =>array('type'=>'integer', 'label'=>'Nb gen done', 'enabled'=>1, 'visible'=>-1, 'position'=>140), 'nb_gen_max' =>array('type'=>'integer', 'label'=>'Nb gen max', 'enabled'=>1, 'visible'=>-1, 'position'=>145), 'frequency' =>array('type'=>'integer', 'label'=>'Frequency', 'enabled'=>1, 'visible'=>-1, 'position'=>150), + 'unit_frequency' =>array('type'=>'varchar(2)', 'label'=>'UnitFrequency', 'enabled'=>1, 'visible'=>-1, 'position'=>152), 'usenewprice' =>array('type'=>'integer', 'label'=>'UseNewPrice', 'enabled'=>1, 'visible'=>0, 'position'=>155), 'revenuestamp' =>array('type'=>'double(24,8)', 'label'=>'RevenueStamp', 'enabled'=>1, 'visible'=>-1, 'position'=>160, 'isameasure'=>1), 'auto_validate' =>array('type'=>'integer', 'label'=>'Auto validate', 'enabled'=>1, 'visible'=>-1, 'position'=>165), @@ -1771,35 +1770,35 @@ class FactureRec extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_rec' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old product id + * @param int $dest_id New product id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facturedet_rec' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 87d28de8756..561ebf3e9ed 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1330,6 +1330,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1463,6 +1465,8 @@ class Facture extends CommonInvoice $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } @@ -1956,14 +1960,14 @@ class Facture extends CommonInvoice $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON f.fk_incoterms = i.rowid'; if ($rowid) { - $sql .= " WHERE f.rowid=".((int) $rowid); + $sql .= " WHERE f.rowid = ".((int) $rowid); } else { $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; // Don't use entity if you use rowid if ($ref) { - $sql .= " AND f.ref='".$this->db->escape($ref)."'"; + $sql .= " AND f.ref = '".$this->db->escape($ref)."'"; } if ($ref_ext) { - $sql .= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; + $sql .= " AND f.ref_ext = '".$this->db->escape($ref_ext)."'"; } } @@ -4078,7 +4082,7 @@ class Facture extends CommonInvoice * * @param int $idline id of line to check * @param float $situation_percent progress percentage need to be test - * @return false if KO, true if OK + * @return bool false if KO, true if OK */ public function checkProgressLine($idline, $situation_percent) { @@ -4097,7 +4101,7 @@ class Facture extends CommonInvoice if ($obj === null) { return true; } else { - return $situation_percent < $obj->situation_percent; + return ($situation_percent < $obj->situation_percent); } } @@ -4148,9 +4152,10 @@ class Facture extends CommonInvoice * Delete line in database * * @param int $rowid Id of line to delete + * @param int $id Id of object (for a check) * @return int <0 if KO, >0 if OK */ - public function deleteline($rowid) + public function deleteline($rowid, $id = 0) { global $user; @@ -4161,6 +4166,22 @@ class Facture extends CommonInvoice return -1; } + $line = new FactureLigne($this->db); + + $line->context = $this->context; + + // Load line + $result = $line->fetch($rowid); + if (!($result > 0)) { + dol_print_error($this->db, $line->error, $line->errors); + return -1; + } + + if ($id > 0 && $line->fk_facture != $id) { + $this->error = 'ErrorLineIDDoesNotMatchWithObjectID'; + return -1; + } + $this->db->begin(); // Free discount linked to invoice line @@ -4176,15 +4197,9 @@ class Facture extends CommonInvoice return -1; } - $line = new FactureLigne($this->db); - - $line->context = $this->context; - - // For triggers - $result = $line->fetch($rowid); - if (!($result > 0)) { - dol_print_error($this->db, $line->error, $line->errors); - } + // Memorize previous line for triggers + $staticline = clone $line; + $line->oldline = $staticline; if ($line->delete($user) > 0) { $result = $this->update_price(1); @@ -4213,7 +4228,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_remise($user, $remise, $notrigger = 0) { @@ -4228,7 +4243,7 @@ class Facture extends CommonInvoice * @param User $user User that set discount * @param double $remise Discount * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function setDiscount($user, $remise, $notrigger = 0) { @@ -4280,6 +4295,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } @@ -4345,6 +4362,8 @@ class Facture extends CommonInvoice return -1 * $error; } } + + return 0; } /** @@ -4636,8 +4655,8 @@ class Facture extends CommonInvoice * Invoices matching the following rules are returned: * (validated + payment on process) or classified (payed completely or payed partiely) + not already replaced + not already a credit note * - * @param int $socid Id thirdparty - * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) + * @param int $socid Id thirdparty + * @return array|int Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ public function list_qualified_avoir_invoices($socid = 0) { @@ -4711,8 +4730,8 @@ class Facture extends CommonInvoice /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Object user - * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK + * @param User $user Object user + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ public function load_board($user) { @@ -5190,18 +5209,18 @@ class Facture extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -5731,6 +5750,40 @@ class Facture extends CommonInvoice } else { dol_print_error($this->db); } + + return array(); + } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= '
'.$this->socid.''; + } + if (property_exists($this, 'fk_user_author')) { + $return .= '
'.$this->fk_user_author.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; } } @@ -6264,7 +6317,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); - $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) + $sql .= ", buy_price_ht=".(($this->pa_ht || (string) $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=".((int) $this->rang); @@ -6375,11 +6428,11 @@ class FactureLigne extends CommonInvoiceLine // Update line in database $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; - $sql .= " total_ht=".price2num($this->total_ht).""; - $sql .= ",total_tva=".price2num($this->total_tva).""; - $sql .= ",total_localtax1=".price2num($this->total_localtax1).""; - $sql .= ",total_localtax2=".price2num($this->total_localtax2).""; - $sql .= ",total_ttc=".price2num($this->total_ttc).""; + $sql .= " total_ht=".price2num($this->total_ht); + $sql .= ",total_tva=".price2num($this->total_tva); + $sql .= ",total_localtax1=".price2num($this->total_localtax1); + $sql .= ",total_localtax2=".price2num($this->total_localtax2); + $sql .= ",total_ttc=".price2num($this->total_ttc); $sql .= " WHERE rowid = ".((int) $this->rowid); dol_syslog(get_class($this)."::update_total", LOG_DEBUG); diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3ad533b6d3b..4da9dbb1559 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -137,7 +137,7 @@ class PaymentTerm // extends CommonObject $sql .= " ".(!isset($this->libelle_facture) ? 'NULL' : "'".$this->db->escape($this->libelle_facture)."'").","; $sql .= " ".(!isset($this->type_cdr) ? 'NULL' : "'".$this->db->escape($this->type_cdr)."'").","; $sql .= " ".(!isset($this->nbjour) ? 'NULL' : "'".$this->db->escape($this->nbjour)."'").","; - $sql .= " ".(!isset($this->decalage) ? 'NULL' : "'".$this->db->escape($this->decalage)."'").""; + $sql .= " ".(!isset($this->decalage) ? 'NULL' : "'".$this->db->escape($this->decalage)."'"); $sql .= ")"; $this->db->begin(); @@ -316,7 +316,7 @@ class PaymentTerm // extends CommonObject $sql .= " libelle_facture=".(isset($this->libelle_facture) ? "'".$this->db->escape($this->libelle_facture)."'" : "null").","; $sql .= " type_cdr=".(isset($this->type_cdr) ? $this->type_cdr : "null").","; $sql .= " nbjour=".(isset($this->nbjour) ? $this->nbjour : "null").","; - $sql .= " decalage=".(isset($this->decalage) ? $this->decalage : "null").""; + $sql .= " decalage=".(isset($this->decalage) ? $this->decalage : "null"); $sql .= " WHERE rowid = ".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index b367301911d..2548284f97f 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 5cec55e2439..526bbe02068 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -152,7 +152,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 1ea28b295c3..0619d629385 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -108,7 +108,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php index ae9e4c2959b..0471b97c038 100644 --- a/htdocs/compta/facture/invoicetemplate_list.php +++ b/htdocs/compta/facture/invoicetemplate_list.php @@ -94,6 +94,7 @@ $search_date_when_end = dol_mktime(23, 59, 59, $search_date_when_endmonth, $sear $search_recurring = GETPOST('search_recurring', 'int'); $search_frequency = GETPOST('search_frequency', 'alpha'); $search_unit_frequency = GETPOST('search_unit_frequency', 'alpha'); +$search_nb_gen_done = GETPOST('search_nb_gen_done', 'aplha'); $search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -236,6 +237,7 @@ if (empty($reshook)) { $search_recurring = ''; $search_frequency = ''; $search_unit_frequency = ''; + $search_nb_gen_done = ''; $search_status = ''; $search_array_options = array(); } @@ -334,7 +336,11 @@ if ($search_frequency != '') { $sql .= natural_search('f.frequency', $search_frequency, 1); } if ($search_unit_frequency != '') { - $sql .= ' AND f.frequency > 0'.natural_search('f.unit_frequency', $search_unit_frequency); + $sql .= ' AND f.frequency > 0'; + $sql .= natural_search('f.unit_frequency', $search_unit_frequency); +} +if ($search_nb_gen_done != '') { + $sql .= natural_search("f.nb_gen_done", $search_nb_gen_done, 1); } if ($search_status != '' && $search_status >= -1) { if ($search_status == 0) { @@ -458,6 +464,9 @@ if ($resql) { if ($search_unit_frequency != '') { $param .= '&search_unit_frequency='.urlencode($search_unit_frequency); } + if ($search_nb_gen_done != '') { + $param .= '&search_nb_gen_done='.urlencode($search_nb_gen_done); + } if ($search_status != '') { $param .= '&search_status='.urlencode($search_status); } @@ -561,6 +570,7 @@ if ($resql) { if (!empty($arrayfields['f.nb_gen_done']['checked'])) { // Nb generation print ''; } // Date invoice @@ -728,7 +738,7 @@ if ($resql) { } } if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 698f131aa09..0b5903c54c4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -75,6 +75,7 @@ $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'invoicelist'; +$mode = GETPOST('mode', 'alpha'); if ($contextpage == 'poslist') { $optioncss = 'print'; @@ -299,7 +300,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $massaction = ''; } -$parameters = array('socid'=>$socid); +$parameters = array('socid'=>$socid, 'arrayfields'=>&$arrayfields); $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'); @@ -843,7 +844,7 @@ if (!empty($searchCategoryProductList)) { } } } -$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array();; +$searchCategoryCustomerList = $search_categ_cus ? array($search_categ_cus) : array(); $searchCategoryCustomerOperator = 0; // Search for tag/category ($searchCategoryCustomerList is an array of ID) if (!empty($searchCategoryCustomerList)) { @@ -974,6 +975,9 @@ if ($resql) { } $param = '&socid='.urlencode($socid); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1185,6 +1189,9 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', $user->hasRight("facture", "creer")); } @@ -1204,6 +1211,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($langs->trans('BillsCustomers').' '.($socid > 0 ? ' '.$soc->name : ''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bill', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -1590,9 +1598,9 @@ if ($resql) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; } // Action column @@ -1894,645 +1902,660 @@ if ($resql) { $total_margin += $marginInfo['total_margin']; } - print 'ref)); - print 'parent.place=\''.$place.'\''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print 'ref)); + print 'parent.place=\''.$place.'\''; } - print ''; + print '});"'; } - print ''; - } + print '>'; - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - } - // Ref - if (!empty($arrayfields['f.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Customer ref - if (!empty($arrayfields['f.ref_client']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['f.type']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.datef']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.date_valid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project ref - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project title - if (!empty($arrayfields['p.title']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Parent company - if (!empty($arrayfields['s2.nom']['checked'])) { - print ''; + } + + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + } + + // Ref + if (!empty($arrayfields['f.ref']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ""; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Staff - if (!empty($arrayfields['staff.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment terms - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Module Source - if (!empty($arrayfields['f.module_source']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // POS Terminal - if (!empty($arrayfields['f.pos_source']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['f.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; - } - $totalarray['val']['f.total_tva'] += $obj->total_tva; - } - // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; - } - $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; - } - // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; - } - $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; - } - // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $obj->total_ttc; - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; + if (!$i) { + $totalarray['nbfield']++; } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->office_phone = $val['office_phone']; - $userstatic->office_fax = $val['office_fax']; - $userstatic->user_mobile = $val['user_mobile']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; + } + + // Type + if (!empty($arrayfields['f.type']['checked'])) { + print '
"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.datef']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.date_valid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date limit + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project ref + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project title + if (!empty($arrayfields['p.title']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Parent company + if (!empty($arrayfields['s2.nom']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Staff + if (!empty($arrayfields['staff.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['f.retained_warranty']['checked'])) { - print ''; - } + // Payment mode + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; + // Payment terms + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 0, '', -1, -1, 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; - } - $totalarray['val']['totalam'] += $totalpay; - } - // Pending amount - if (!empty($arrayfields['rtp']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; + // Module Source + if (!empty($arrayfields['f.module_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; - } - $totalarray['val']['rtp'] += $remaintopay; - } + // POS Terminal + if (!empty($arrayfields['f.pos_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } - // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $obj->total_ht; } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Amount VAT + if (!empty($arrayfields['f.total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_tva'; + } + $totalarray['val']['f.total_tva'] += $obj->total_tva; + } + // Amount LocalTax1 + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } + $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; + } + // Amount LocalTax2 + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } + $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; + } + // Amount TTC + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $obj->total_ttc; } - } - // 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']++; - } - } + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; - // Pending amount - if (!empty($arrayfields['multicurrency_rtp']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Total buying or cost price - if (!empty($arrayfields['total_pa']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total margin - if (!empty($arrayfields['total_margin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; - } - $totalarray['val']['total_margin'] += $marginInfo['total_margin']; - } - // Total margin rate - if (!empty($arrayfields['total_margin_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Total mark rate - if (!empty($arrayfields['total_mark_rate']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; - } - if ($i >= $imaxinloop - 1) { - if (!empty($total_ht)) { - $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date closing - if (!empty($arrayfields['f.date_closing']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['f.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['f.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Template Invoice - if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; + + if (!empty($arrayfields['f.retained_warranty']['checked'])) { + print ''; + } + + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } + $totalarray['val']['totalam'] += $totalpay; + } + + // Pending amount + if (!empty($arrayfields['rtp']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } + $totalarray['val']['rtp'] += $remaintopay; + } + + + // Currency + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print '\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']++; + } + } + + // Total buying or cost price + if (!empty($arrayfields['total_pa']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total margin + if (!empty($arrayfields['total_margin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_margin'; + } + $totalarray['val']['total_margin'] += $marginInfo['total_margin']; + } + // Total margin rate + if (!empty($arrayfields['total_margin_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Total mark rate + if (!empty($arrayfields['total_mark_rate']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'total_mark_rate'; + } + if ($i >= $imaxinloop - 1) { + if (!empty($total_ht)) { + $totalarray['val']['total_mark_rate'] = price2num($total_margin * 100 / $total_ht, 'MT'); + } else { + $totalarray['val']['total_mark_rate'] = ''; + } + } + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date closing + if (!empty($arrayfields['f.date_closing']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['f.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['f.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Template Invoice + if (!empty($arrayfields['f.fk_fac_rec_source']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column (Show the massaction button only when this page is not opend from the Extended POS) + + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } + print "\n"; } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column (Show the massaction button only when this page is not opend from the Extended POS) - - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; - $i++; } diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index af08c6163e2..40f8b969fac 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -130,7 +130,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 195b04a2ed5..790dc9e26ca 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -375,7 +375,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -742,8 +742,8 @@ if ($object->id > 0) { print ''; print ''; - if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT_SHOW_BUTTON)) { - // TODO Replace this with a checkbox for each payment mode: "Send request to PaymentModeManager immediatly..." + if (getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT_SHOW_OLD_BUTTON')) { // This is hidden, prefer to use mode enabled with STRIPE_SEPA_DIRECT_DEBIT + // TODO Replace this with a checkbox for each payment mode: "Send request to XXX immediatly..." print "
"; //add stripe sepa button $buttonlabel = $langs->trans("MakeWithdrawRequestStripe"); @@ -781,14 +781,14 @@ if ($object->id > 0) { if ($type == 'bank-transfer') { print '
'.$langs->trans("DoCreditTransferBeforePayments"); - if (isModEnabled('stripe')) { + if (isModEnabled('stripe') && getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')) { print ' '.$langs->trans("DoStandingOrdersBeforePayments2"); } print ' '.$langs->trans("DoStandingOrdersBeforePayments3"); print '

'; } else { print '
'.$langs->trans("DoStandingOrdersBeforePayments"); - if (isModEnabled('stripe')) { + if (isModEnabled('stripe') && getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')) { print ' '.$langs->trans("DoStandingOrdersBeforePayments2"); } print ' '.$langs->trans("DoStandingOrdersBeforePayments3"); @@ -807,13 +807,13 @@ if ($object->id > 0) { print '
'; print ''; print ''; - print ''; if ($type == 'bank-transfer') { print ''; } else { print ''; } print ''; + print ''; print ''; $sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,"; @@ -864,9 +864,10 @@ if ($object->id > 0) { // Amount print ''; - // Ref of SEPA request + // Date process print ''; + // Link to make payment now print ''; + // print ''; + // Actions print ''; + // Date print '\n"; + // User print ''; + // Amount print ''; + // Date process + print '\n"; + + // Link to payment request done print '\n"; + // print ''; - print '\n"; - + // Actions print ''; print "\n"; diff --git a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php index 6a16f4fa641..ca782052ff4 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblock.tpl.php @@ -67,7 +67,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { break; } print ''; - print ''; + print ''; print ''; print ''; print ' - + '; - - // Num ref cheque - print ''; + $checkdepositstatic->nbcheque = $objp->nbcheque; + $checkdepositstatic->amount = $objp->amount; + $checkdepositstatic->date_bordereau = $objp->date_bordereau; - // Date - print ''; // TODO Use date hour + $account = new Account($db); + $account->fetch($objp->bid); + $checkdepositstatic->account_id = $account->getNomUrl(1); - // Bank - print ''; + } } else { - print ' '; + print ''; + + // Num ref cheque + print ''; + + // Date + print ''; // TODO Use date hour + + // Bank + print ''; + + // Number of cheques + print ''; + + // Amount + print ''; + + // Statut + print ''; + + print ''; + + print "\n"; } - print ''; - - // Number of cheques - print ''; - - // Amount - print ''; - - // Statut - print ''; - - print ''; - - print "\n"; $i++; } } else { diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 658f2c150f1..6db18f6aa55 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -513,6 +513,7 @@ foreach ($arrayfields as $column) { $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -620,7 +621,11 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } $totalarray['pos'][$checkedCount] = 'amount'; - $totalarray['val']['amount'] += $objp->amount; + if (empty($totalarray['val']['amount'])) { + $totalarray['val']['amount'] = $objp->amount; + } else { + $totalarray['val']['amount'] += $objp->amount; + } } // Status diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 39bac75ba0c..11f7f1e454f 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -46,8 +46,6 @@ $confirm = GETPOST('confirm', 'aZ09'); if ($user->socid) { $socid = $user->socid; } -// TODO ajouter regle pour restreindre acces paiement -//$result = restrictedArea($user, 'facture', $id,''); $object = new PaymentSocialContribution($db); if ($id > 0) { @@ -57,13 +55,15 @@ if ($id > 0) { } } +$result = restrictedArea($user, 'payment_sc', $id, ''); + /* * Actions */ // Delete payment -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('tax', 'charges', 'supprimer')) { $db->begin(); $result = $object->delete($user); @@ -77,6 +77,16 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char } } +/*if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('tax', 'charges', 'creer')) { + $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); + $res = $object->update_date($datepaye); + if ($res === 0) { + setEventMessages($langs->trans('PaymentDateUpdateSucceeded'), null, 'mesgs'); + } else { + setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); + } +}*/ + /* * View diff --git a/htdocs/compta/prelevement/card.php b/htdocs/compta/prelevement/card.php index c9f90b8b240..33a4409bac9 100644 --- a/htdocs/compta/prelevement/card.php +++ b/htdocs/compta/prelevement/card.php @@ -272,7 +272,7 @@ if ($id > 0 || $ref) { print $formconfirm; - if (empty($object->date_trans) && $user->rights->prelevement->bons->send && $action == 'settransmitted') { + if (empty($object->date_trans) && (($user->rights->prelevement->bons->send && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->send && $object->type == 'bank-transfer')) && $action == 'settransmitted') { print ''; print ''; print ''; @@ -291,7 +291,7 @@ if ($id > 0 || $ref) { print '
'; } - if (!empty($object->date_trans) && empty($object->date_credit) && $user->rights->prelevement->bons->credit && $action == 'setcredited') { + if (!empty($object->date_trans) && empty($object->date_credit) && (($user->rights->prelevement->bons->credit && $object->type != 'bank-transfer') || ($user->rights->paymentbybanktransfer->debit && $object->type == 'bank-transfer')) && $action == 'setcredited') { $btnLabel = ($object->type == 'bank-transfer') ? $langs->trans("ClassDebited") : $langs->trans("ClassCredited"); print ''; print ''; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 959630a5538..b9d1fd7c54a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -72,6 +72,7 @@ class BonPrelevement extends CommonObject public $date_trans; public $user_trans; + public $method_trans; public $total; public $fetched; @@ -83,6 +84,15 @@ class BonPrelevement extends CommonObject public $invoice_in_error = array(); public $thirdparty_in_error = array(); + public $amount; + public $note; + public $datec; + + public $date_credit; + public $user_credit; + + public $type; + const STATUS_DRAFT = 0; const STATUS_TRANSFERED = 1; const STATUS_CREDITED = 2; // STATUS_CREDITED and STATUS_DEBITED is same. Difference is in ->type @@ -1856,7 +1866,7 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } @@ -1925,7 +1935,7 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); - $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); + $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : (string) $row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1), ' '), 70, 'right', 'UTF-8', 1)).''.$CrLf; } @@ -2397,4 +2407,39 @@ class BonPrelevement extends CommonObject */ return 0; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + + if (property_exists($this, 'date_echeance')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->date_echeance), 'day').''; + } + if (property_exists($this, 'total')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->total).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->statut, 5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 0093db77c32..6ed518f7f2f 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -167,17 +167,17 @@ class LignePrelevement /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'prelevement_lignes' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/compta/prelevement/create.php b/htdocs/compta/prelevement/create.php index 37a2d74c5e3..598b86fcda3 100644 --- a/htdocs/compta/prelevement/create.php +++ b/htdocs/compta/prelevement/create.php @@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/prelevement.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -74,6 +75,8 @@ if ($type == 'bank-transfer') { $error = 0; $option = ""; +$mesg = ''; + /* * Actions @@ -225,14 +228,14 @@ if ($type == 'bank-transfer') { $title = $langs->trans("NbOfInvoiceToPayByBankTransfer"); } -print '
'; -print ''; +print ''; print ''; -print ''; print ''; @@ -254,20 +257,20 @@ if ($nb) { if ($type == 'bank-transfer') { $title = $langs->trans('BankToPayCreditTransfer').': '; } - print $title; + print ''.$title.''; print img_picto('', 'bank_account'); $default_account = ($type == 'bank-transfer' ? 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' : 'PRELEVEMENT_ID_BANKACCOUNT'); - print $form->select_comptes($conf->global->$default_account, 'id_bankaccount', 0, "courant=1", 0, '', 0, '', 1); - print ' - '; + print $form->select_comptes(getDolGlobalInt($default_account), 'id_bankaccount', 0, "courant=1", 0, '', 0, 'widthcentpercentminusx maxwidth300', 1); + print '     '; if (empty($executiondate)) { $delayindays = 0; if ($type != 'bank-transfer') { - $delayindays = $conf->global->PRELEVEMENT_ADDDAYS; + $delayindays = getDolGlobalInt('PRELEVEMENT_ADDDAYS'); } else { - $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS; + $delayindays = getDolGlobalInt('PAYMENTBYBANKTRANSFER_ADDDAYS'); } $executiondate = dol_time_plus_duree(dol_now(), $delayindays, 'd'); @@ -290,14 +293,14 @@ if ($nb) { print ''; print ''; } - print ''; + print ''; } else { $title = $langs->trans("CreateAll"); if ($type == 'bank-transfer') { $title = $langs->trans("CreateFileForPaymentByBankTransfer"); } print ''."\n"; - print ''."\n"; + print ''."\n"; } } else { if ($mysoc->isInEEC()) { @@ -305,18 +308,18 @@ if ($nb) { if ($type == 'bank-transfer') { $title = $langs->trans("CreateSepaFileForPaymentByBankTransfer"); } - print ''.$title."\n"; + print ''.$title."\n"; if ($type != 'bank-transfer') { $title = $langs->trans("CreateForSepaRCUR"); - print ''.$title."\n"; + print ''.$title."\n"; } } else { $title = $langs->trans("CreateAll"); if ($type == 'bank-transfer') { $title = $langs->trans("CreateFileForPaymentByBankTransfer"); } - print ''.$title."\n"; + print ''.$title."\n"; } } } else { @@ -326,7 +329,9 @@ if ($nb) { $titlefortab = $langs->transnoentitiesnoconv("PaymentByBankTransfers"); $title = $langs->trans("CreateFileForPaymentByBankTransfer"); } - print ''.$title."\n"; + print ''; + print $title; + print "\n"; } print "\n"; @@ -341,6 +346,9 @@ print '
'; */ $sql = "SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,"; +if ($type == 'bank-transfer') { + $sql .= " f.ref_supplier,"; +} $sql .= " pfd.rowid as request_row_id, pfd.date_demande, pfd.amount"; if ($type == 'bank-transfer') { $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,"; @@ -417,9 +425,13 @@ if ($resql) { $tradinvoice = "SupplierInvoice"; } + print '
'; print '
'; print $langs->trans('RetainedWarrantyDateLimit'); print 'id.'">'.img_edit($langs->trans('setretainedwarrantyDateLimit'), 1).''; + print ''; print ''.$companystatic->getNomUrl(1, 'customer').''.$companystatic->getNomUrl(1, 'customer').''; + print ''; $liststatus = array('0'=>$langs->trans("BillShortStatusDraft"), '0,1'=>$langs->trans("BillShortStatusDraft").'+'.$langs->trans("BillShortStatusNotPaid"), '1'=>$langs->trans("BillShortStatusNotPaid"), '1,2'=>$langs->trans("BillShortStatusNotPaid").'+'.$langs->trans("BillShortStatusPaid"), '2'=>$langs->trans("BillShortStatusPaid"), '3'=>$langs->trans("BillShortStatusCanceled")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'width100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'; + print '
'; } - print '});"'; - } - print '>'; - - - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print '
'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; + // Output Kanban + $facturestatic->socid = $companystatic->getNomUrl(1, 'company', 15); + $userstatic->fetch($obj->fk_user_author); + $facturestatic->fk_user_author = $userstatic->getNomUrl(1); + print $facturestatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'.(($offset * $limit) + $i).''; - - print ''; - - print ''; - print ''; - print '
'; - if ($contextpage == 'poslist') { - print dol_escape_htmltag($obj->ref); - } else { - print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); - } - - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; - print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); - print '
'; - - print "
'; - print dol_escape_htmltag($obj->ref_client); - print ''; - print $facturestatic->getLibType(2); - print "'; - print dol_print_date($db->jdate($obj->datef), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); - } - print ''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($obj->project_id > 0) { - print dol_escape_htmltag($projectstatic->title); - } - print ''; - if ($contextpage == 'poslist') { - print dol_escape_htmltag($companystatic->name); - } else { - print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - } - print ''; - print dol_escape_htmltag($companystatic->name_alias); - print ''; - if ($obj->fk_parent > 0) { - if (!isset($company_url_list[$obj->fk_parent])) { - $companyparent = new Societe($db); - $res = $companyparent->fetch($obj->fk_parent); - if ($res > 0) { - $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; } + print ''; } - if (isset($company_url_list[$obj->fk_parent])) { - print $company_url_list[$obj->fk_parent]; + print ''.(($offset * $limit) + $i).''; + + print ''; + + print ''; + print ''; + print '
'; + if ($contextpage == 'poslist') { + print dol_escape_htmltag($obj->ref); + } else { + print $facturestatic->getNomUrl(1, '', 200, 0, '', 0, 1); + } + + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->id; + print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir); + print '
'; + + print "
'; - print dol_escape_htmltag($obj->town); - print ''; - print dol_escape_htmltag($obj->zip); - print '".dol_escape_htmltag($obj->state_name)."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (!is_array($typenArray) || count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) { - $conf->cache['staff'] = $formcompany->effectif_array(1); - } - print $conf->cache['staff'][$obj->staff_code]; - print ''; - print $s; - print ''; - print $s; - print ''; - print dol_escape_htmltag($obj->module_source); - print ''; - print dol_escape_htmltag($obj->pos_source); - print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - if ($userstatic->id) { - print $userstatic->getNomUrl(-1); - } else { - print ' '; - } - print "'; - if ($obj->socid > 0) { - $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); + // Customer ref + if (!empty($arrayfields['f.ref_client']['checked'])) { + print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; + print $facturestatic->getLibType(2); + print "'; + print dol_print_date($db->jdate($obj->datef), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''.dol_print_date($datelimit, 'day'); + if ($facturestatic->hasDelay()) { + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); + } + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($obj->project_id > 0) { + print dol_escape_htmltag($projectstatic->title); + } + print ''; + if ($contextpage == 'poslist') { + print dol_escape_htmltag($companystatic->name); + } else { + print $companystatic->getNomUrl(1, 'customer', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } + print ''; + print dol_escape_htmltag($companystatic->name_alias); + print ''; + if ($obj->fk_parent > 0) { + if (!isset($company_url_list[$obj->fk_parent])) { + $companyparent = new Societe($db); + $res = $companyparent->fetch($obj->fk_parent); + if ($res > 0) { + $company_url_list[$obj->fk_parent] = $companyparent->getNomUrl(1); } - //print ''; + } + if (isset($company_url_list[$obj->fk_parent])) { + print $company_url_list[$obj->fk_parent]; } } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print "'; + print dol_escape_htmltag($obj->town); + print ''; + print dol_escape_htmltag($obj->zip); + print '".dol_escape_htmltag($obj->state_name)."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (!is_array($typenArray) || count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if (!is_array($conf->cache['staff']) || count($conf->cache['staff']) == 0) { + $conf->cache['staff'] = $formcompany->effectif_array(1); + } + print $conf->cache['staff'][$obj->staff_code]; + print ''.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : ' ').''; + print $s; + print ''.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').''; + print $s; + print ''; - print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); - print ''; + print dol_escape_htmltag($obj->module_source); + print ''; + print dol_escape_htmltag($obj->pos_source); + print ''; - if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) { - print $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code); - } else { - print dol_escape_htmltag($obj->multicurrency_code); + // Amount HT + if (!empty($arrayfields['f.total_ht']['checked'])) { + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - $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 ''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + if ($userstatic->id) { + print $userstatic->getNomUrl(-1); } else { - $totalarray['val']['total_mark_rate'] = ''; + print ' '; + } + print "'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - if (!empty($obj->fk_fac_rec_source)) { - $facrec = new FactureRec($db); - $result = $facrec->fetch($obj->fk_fac_rec_source); - if ($result < 0) { - setEventMessages($facrec->error, $facrec->errors, 'errors'); + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->office_phone = $val['office_phone']; + $userstatic->office_fax = $val['office_fax']; + $userstatic->user_mobile = $val['user_mobile']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); } else { - print $facrec->getNomUrl(); + print ' '; + } + print '
'.(!empty($obj->retained_warranty) ? price($obj->retained_warranty).'%' : ' ').''.(!empty($totalpay) ? price($totalpay, 0, $langs) : ' ').''; + print (!empty($remaintopay) ? price($remaintopay, 0, $langs) : ' '); + print ''; + if (empty($conf->global->MAIN_SHOW_ONLY_CODE_MULTICURRENCY)) { + print $langs->transnoentitiesnoconv('Currency'.$obj->multicurrency_code); + } else { + print dol_escape_htmltag($obj->multicurrency_code); + } + 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 ''.price($marginInfo['pa_total']).''.price($marginInfo['total_margin']).''.(($marginInfo['total_margin_rate'] == '') ? '' : price($marginInfo['total_margin_rate'], null, null, null, null, 2).'%').''.(($marginInfo['total_mark_rate'] == '') ? '' : price($marginInfo['total_mark_rate'], null, null, null, null, 2).'%').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_closing), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + if (!empty($obj->fk_fac_rec_source)) { + $facrec = new FactureRec($db); + $result = $facrec->fetch($obj->fk_fac_rec_source); + if ($result < 0) { + setEventMessages($facrec->error, $facrec->errors, 'errors'); + } else { + print $facrec->getNomUrl(); + } + } + print ''; + print $facturestatic->getLibStatut(5, $paiement); + print "'; + if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $selected = 0; + if (in_array($obj->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'; - print $facturestatic->getLibStatut(5, $paiement); - print "'; - if (($massactionbutton || $massaction) && $contextpage != 'poslist') { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - $selected = 0; - if (in_array($obj->id, $arrayofselected)) { - $selected = 1; - } - print ''; - } - print '
'.$langs->trans("User").''.$langs->trans("Amount").''.$langs->trans("DateProcess").' '.$langs->trans("BankTransferReceipt").''.$langs->trans("WithdrawalReceipt").'  
'.price($obj->amount).''.$langs->trans("OrderWaiting").''; if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { $langs->load("stripe"); @@ -874,8 +875,10 @@ if ($object->id > 0) { } print '-'; print ''; print img_delete(); @@ -929,14 +932,21 @@ if ($object->id > 0) { print '
'.dol_print_date($db->jdate($obj->date_demande), 'day')."'; print $tmpuser->getNomUrl(1, '', 0, 0, 0, 0, 'login'); print ''.price($obj->amount).''.dol_print_date($db->jdate($obj->date_traite), 'day')."'; if ($obj->fk_prelevement_bons > 0) { $withdrawreceipt = new BonPrelevement($db); @@ -946,10 +956,10 @@ if ($object->id > 0) { } print " '.dol_print_date($db->jdate($obj->date_traite), 'day')." 
'.$objectlink->getNomUrl(1).''.$objectlink->getNomUrl(1).''.dol_escape_htmltag($objectlink->ref_client).''.dol_print_date($objectlink->date, 'day').''; diff --git a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php index 1bca663e1ef..c3c774b79e7 100644 --- a/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php +++ b/htdocs/compta/facture/tpl/linkedobjectblockForRec.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?>
trans("RepeatableInvoice"); ?>getNomUrl(1); ?>getNomUrl(1); ?> date_when, 'day'); ?> rights->don->lire)) { $donationstatic->ref = $obj->rowid; $donationstatic->lastname = $obj->lastname; $donationstatic->firstname = $obj->firstname; - $donationstatic->date = $obj->date; + $donationstatic->date = $db->jdate($obj->date); $donationstatic->statut = $obj->status; $donationstatic->status = $obj->status; @@ -742,21 +742,25 @@ if (isModEnabled('facture') && isModEnabled('commande') && $user->hasRight("comm // TODO Mettre ici recup des actions en rapport avec la compta -$resql = ''; -if ($resql) { +$sql = ''; +if ($sql) { print '
'; print ''; print ''.$langs->trans("TasksToDo").''; print "\n"; $i = 0; - while ($i < $db->num_rows($resql)) { - $obj = $db->fetch_object($resql); + $resql = $db->query($sql); + if ($resql) { + $num_rows = $db->num_rows($resql); + while ($i < $num_rows) { + $obj = $db->fetch_object($resql); - print ''; - print ''; - $i++; + print ''; + print ''; + $i++; + } + $db->free($resql); } - $db->free($resql); print "
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'
'.dol_print_date($db->jdate($obj->da), "day").''.$obj->label.'

"; } diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 8b6119db13a..ad80b6d1b6d 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -144,9 +144,12 @@ $form = new Form($db); $title = $langs->trans("LT".$object->ltt)." - ".$langs->trans("Card"); $help_url = ''; -llxHeader('', $title, $helpurl); +llxHeader('', $title, $help_url); if ($action == 'create') { + $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth"), GETPOST("datevday"), GETPOST("datevyear")); + $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth"), GETPOST("datepday"), GETPOST("datepyear")); + print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code)); print '
'."\n"; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index ed467ec91f4..a6db785b779 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -629,4 +629,39 @@ class Localtax extends CommonObject return ''; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= ' | '.$this->label.''; + } + if (property_exists($this, 'datev')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->db->jdate($this->datev), 'day').''; + } + if (property_exists($this, 'datep')) { + $return .= '
'.$langs->trans("DatePayment", '', '', '', '', 5).' : '.dol_print_date($this->db->jdate($this->datep), 'day').''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index ad0b86a161d..f25b476fa94 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -18,11 +18,13 @@ * along with this program. If not, see . */ + /** * \file htdocs/compta/localtax/index.php * \ingroup tax - * \brief Index page of IRPF reports + * \brief Index page of localtax reports */ + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; @@ -257,6 +259,9 @@ llxHeader('', $name); //$textnextyear=" ".img_next().""; //print load_fiche_titre($langs->transcountry($LT,$mysoc->country_code),"$textprevyear ".$langs->trans("Year")." $year_start $textnextyear", 'bill'); +$periodlink = ''; +$exportlink = ''; + report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array(), $calcmode); //report_header($name,'',$textprevyear.$langs->trans("Year")." ".$year_start.$textnextyear,'',$description,$builddate,$exportlink,array(),$calcmode); @@ -269,7 +274,7 @@ print load_fiche_titre($langs->transcountry($LTSummary, $mysoc->country_code), ' print ''; print ''; -print '"; +print '"; if ($CalcLT == 0) { print ''; print ''; @@ -441,16 +446,6 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/localtax/list.php b/htdocs/compta/localtax/list.php index ee2e13e1d57..42f4d326811 100644 --- a/htdocs/compta/localtax/list.php +++ b/htdocs/compta/localtax/list.php @@ -35,7 +35,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'tax', '', '', 'charges'); $ltt = GETPOST("localTaxType", 'int'); - +$mode = GETPOST('mode', 'alpha'); /* * View @@ -49,7 +49,14 @@ $url = DOL_URL_ROOT.'/compta/localtax/card.php?action=create&localTaxType='.$ltt if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); +$param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?localTaxType='.$ltt.'&mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewLocalTaxPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print load_fiche_titre($langs->transcountry($ltt == 2 ? "LT2Payments" : "LT1Payments", $mysoc->country_code), $newcardbutton, 'title_accountancy'); @@ -77,19 +84,36 @@ if ($result) { while ($i < $num) { $obj = $db->fetch_object($result); - print ''; - + $localtax_static->label = $obj->label; $localtax_static->id = $obj->rowid; $localtax_static->ref = $obj->rowid; - print "\n"; - print "\n"; - print '\n"; - print '\n"; + $localtax_static->datev = $obj->datev; + $localtax_static->datep = $obj->datep; + $localtax_static->amount = $obj->amount; + $total = $total + $obj->amount; - print ''; - print "\n"; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; + print "\n"; + print "\n"; + print '\n"; + print '\n"; + print ''; + print "\n"; + } $i++; } print ''; diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 4930ce9e53c..7c68a443feb 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -46,6 +46,11 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); +$socid = GETPOST('socid', 'int'); +if ($socid < 0) { + $socid = 0; +} + $object = new Paiement($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('paymentcard', 'globalcard')); @@ -84,7 +89,7 @@ if ($action == 'setnote' && $user->hasRight('facture', 'paiement')) { } } -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); $result = $object->delete(); @@ -105,7 +110,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->facture-> } } -if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture->paiement) { +if ($action == 'confirm_validate' && $confirm == 'yes' && $user->hasRight('facture', 'paiement')) { $db->begin(); if ($object->validate($user) > 0) { @@ -175,7 +180,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture } } -if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { +if ($action == 'setnum_paiement' && GETPOST('num_paiement') && $user->hasRight('facture', 'paiement')) { $res = $object->update_num(GETPOST('num_paiement')); if ($res === 0) { setEventMessages($langs->trans('PaymentNumberUpdateSucceeded'), null, 'mesgs'); @@ -184,7 +189,7 @@ if ($action == 'setnum_paiement' && GETPOST('num_paiement')) { } } -if ($action == 'setdatep' && GETPOST('datepday')) { +if ($action == 'setdatep' && GETPOST('datepday') && $user->hasRight('facture', 'paiement')) { $datepaye = dol_mktime(GETPOST('datephour', 'int'), GETPOST('datepmin', 'int'), GETPOST('datepsec', 'int'), GETPOST('datepmonth', 'int'), GETPOST('datepday', 'int'), GETPOST('datepyear', 'int')); $res = $object->update_date($datepaye); if ($res === 0) { @@ -193,7 +198,8 @@ if ($action == 'setdatep' && GETPOST('datepday')) { setEventMessages($langs->trans('PaymentDateUpdateFailed'), null, 'errors'); } } -if ($action == 'createbankpayment' && !empty($user->rights->facture->paiement)) { + +if ($action == 'createbankpayment' && $user->hasRight('facture', 'paiement')) { $db->begin(); // Create the record into bank for the amount of payment $object @@ -415,8 +421,6 @@ if ($resql) { $i = 0; $total = 0; - $moreforfilter = ''; - print '
'; print '
'; @@ -511,9 +515,9 @@ if ($resql) { print '
'; if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { - if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') { + if ($user->socid == 0 && $object->statut == 0 && $action == '') { if ($user->rights->facture->paiement) { - print ''.$langs->trans('Valid').''; + print ''.$langs->trans('Valid').''; } } } diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 43443fb292e..1aebdace757 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -485,13 +485,6 @@ if ($action == 'new') { if (count($lines[$bid])) { foreach ($lines[$bid] as $lid => $value) { - //$account_id = $bid; FIXME not used - - // FIXME $accounts[$bid] is a label ! - /*if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1;*/ - print '
'; print ''; print '\n"; @@ -525,8 +518,6 @@ if ($action == 'new') { print ''; print ''; print ''; - - $i++; } } print "
'.$langs->trans("Year")." ".$y."'.$langs->trans("Year")."'.$langs->transcountry($LTCustomer, $mysoc->country_code).''.$langs->transcountry($LTSupplier, $mysoc->country_code).'
'.$langs->trans("ErrorNoAccountancyModuleLoaded").'
'.$langs->trans("FeatureNotYetAvailable").'
'.dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y").'
".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount).'
'; + print '
'; + } + // Output Kanban + print $localtax_static->getKanbanView(''); + if ($i == ($num - 1)) { + print '
'; + print '
".$localtax_static->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount).'
'.$langs->trans("Total").'
'.dol_print_date($value["date"], 'day').''.$value["numero"]."
"; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 3fb82f05cb9..6666f0fe1c4 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -190,8 +190,8 @@ class RemiseCheque extends CommonObject if ($this->id > 0 && $this->errno == 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " SET ref='(PROV".$this->id.")'"; - $sql .= " WHERE rowid=".((int) $this->id).""; + $sql .= " SET ref = '(PROV".$this->id.")'"; + $sql .= " WHERE rowid=".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { @@ -1020,4 +1020,44 @@ class RemiseCheque extends CommonObject return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + if (property_exists($this, 'date_bordereau')) { + $return .= '
'.$langs->trans("DateCreation").' : '.dol_print_date($this->db->jdate($this->date_bordereau), 'day').''; + } + if (property_exists($this, 'nbcheque')) { + $return .= '
'.$langs->trans("Cheque", '', '', '', '', 5).' : '.$this->nbcheque.''; + } + if (property_exists($this, 'account_id')) { + $return .= ' | '.$this->account_id.''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->statut, 5).'
'; + } + if (property_exists($this, 'amount')) { + $return .= ' |
'.$langs->trans("Amount").' : '.price($this->amount).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 054ef800586..38db4fca14b 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -44,6 +44,7 @@ $result = restrictedArea($user, 'banque', '', ''); $search_ref = GETPOST('search_ref', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -149,6 +150,9 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } @@ -160,7 +164,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewCheckDeposit'), '', 'fa fa-plus-circle', $url, '', $user->rights->banque->cheque); print ''; if ($optioncss != '') { @@ -172,6 +179,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + print_barre_liste($langs->trans("MenuChequeDeposits"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit); @@ -220,42 +229,64 @@ if ($resql) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); - print '
'; $checkdepositstatic->id = $objp->rowid; $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); $checkdepositstatic->statut = $objp->statut; - print $checkdepositstatic->getNomUrl(1); - print ''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''; - if ($objp->bid) { - print ''.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.''; + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + print $checkdepositstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; + + print $checkdepositstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''; + if ($objp->bid) { + print ''.img_object($langs->trans("ShowAccount"), 'account').' '.$objp->label.''; + } else { + print ' '; + } + print ''.$objp->nbcheque.''.price($objp->amount).''; + print $checkdepositstatic->LibStatut($objp->statut, 5); + print '
'.$objp->nbcheque.''.price($objp->amount).''; - print $checkdepositstatic->LibStatut($objp->statut, 5); - print '
'.$title.''; -print $nb; +print '
'.$title.''; +print dol_escape_htmltag($nb); print '
'.$langs->trans("AmountTotal").''; -print price($pricetowithdraw); +print ''; +print price($pricetowithdraw, 0, $langs, 1, -1, -1, $conf->currency); print '
'; print ''; print ''; + if ($type == 'bank-transfer') { + print ''; + } print ''; print ''; print ''; @@ -439,17 +451,25 @@ if ($resql) { $bac->fetch(0, $obj->socid); + $invoicestatic->id = $obj->rowid; + $invoicestatic->ref = $obj->ref; + $invoicestatic->ref_supplier = $obj->ref_supplier; + print ''; // Ref invoice - print ''; + if ($type == 'bank-transfer') { + print ''; + } + // Thirdparty - print ''; @@ -510,6 +530,8 @@ if ($resql) { print ''; } print "
'.$langs->trans($tradinvoice).''.$langs->trans("RefSupplier").''.$langs->trans("ThirdParty").''.$langs->trans("RIB").''.$langs->trans("RUM").'
'; - $invoicestatic->id = $obj->rowid; - $invoicestatic->ref = $obj->ref; + print ''; print $invoicestatic->getNomUrl(1, 'withdraw'); print ''; + print dol_escape_htmltag($invoicestatic->ref_supplier); + print ''; + print ''; $thirdpartystatic->fetch($obj->socid); print $thirdpartystatic->getNomUrl(1, 'ban'); print '
'.$langs->trans("None").'
"; + print ""; + print ""; print "
\n"; } else { diff --git a/htdocs/compta/prelevement/factures.php b/htdocs/compta/prelevement/factures.php index 0ed75b5c3b8..cc416d7d530 100644 --- a/htdocs/compta/prelevement/factures.php +++ b/htdocs/compta/prelevement/factures.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/prelevement/factures.php * \ingroup prelevement - * \brief Page liste des factures prelevees + * \brief Page list of invoice paied by direct debit or credit transfer */ // Load Dolibarr environment @@ -174,6 +174,9 @@ if ($id > 0 || $ref) { // List of invoices $sql = "SELECT pf.rowid, p.type,"; $sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,"; +if ($object->type == 'bank-transfer') { + $sql .= " f.ref_supplier,"; +} $sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested"; $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl"; @@ -251,6 +254,9 @@ if ($resql) { print ''; print ''; print_liste_field_titre("Bill", $_SERVER["PHP_SELF"], "p.ref", '', $param, '', $sortfield, $sortorder); + if ($object->type == 'bank-transfer') { + print_liste_field_titre("RefSupplierShort", $_SERVER["PHP_SELF"], "f.ref_supplier", '', $param, '', $sortfield, $sortorder); + } print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder); print_liste_field_titre("AmountInvoice", $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "pl.amount", "", $param, 'class="right"', $sortfield, $sortorder); @@ -282,6 +288,12 @@ if ($resql) { print $invoicetmp->getNomUrl(1); print "\n"; + if ($object->type == 'bank-transfer') { + print '\n"; + } + print '\n"; @@ -322,6 +334,9 @@ if ($resql) { if ($num > 0) { print ''; print ''; + if ($object->type == 'bank-transfer') { + print ''; + } print ''; print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print '\n"; + print $bon->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; - print ''; + print '\n"; - print ''; + + print '\n"; + print ''; + print ''; + + print '\n"; + + + print '\n"; + + print '\n"; + + print '\n"; + + print ''; + + print "\n"; } - print ''; - print img_object($langs->trans($link_title), $link_picto); - print ' '.$obj->invoiceref."\n"; - print ''; - print ''; - - print '\n"; - - - print '\n"; - - print '\n"; - - print '\n"; - - print ''; - - print "\n"; $i++; } } else { diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index 01ef33eea9d..bead580ab31 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -54,6 +54,8 @@ if (!$sortfield) { } $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); + // Get supervariables $statut = GETPOST('statut', 'int'); @@ -147,6 +149,9 @@ if ($result) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -161,6 +166,8 @@ if ($result) { $selectedfields = ''; $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($usercancreate) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewStandingOrder'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php?type='.urlencode($type)); } @@ -176,6 +183,8 @@ if ($result) { print ''; print ''; print ''; + print ''; + if ($type != '') { print ''; } @@ -220,27 +229,41 @@ if ($result) { $directdebitorder->id = $obj->rowid; $directdebitorder->ref = $obj->ref; - $directdebitorder->datec = $obj->datec; - $directdebitorder->amount = $obj->amount; + $directdebitorder->date_echeance = $obj->datec; + $directdebitorder->total = $obj->amount; $directdebitorder->statut = $obj->statut; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print '\n"; + print $directdebitorder->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; - print '\n"; + print '\n"; - print '\n"; + print '\n"; - print ''; + print '\n"; - print ''."\n"; + print ''; - print "\n"; + print ''."\n"; + + print "\n"; + } $i++; } } else { diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 5fdf7220662..54f242edb7c 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -321,7 +321,7 @@ if ($modecompta == 'BOOKKEEPING') { if ($showaccountdetail == 'no') { if ($objp->pcg_type != $oldpcgtype) { - print ''; + print ''; $oldpcgtype = $objp->pcg_type; } } @@ -330,17 +330,17 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ''; print '\n"; - print '\n"; + print '\n"; print "\n"; } else { print ''; print '\n"; - print '\n"; + print '\n"; print "\n"; } @@ -367,7 +367,7 @@ if ($modecompta == 'BOOKKEEPING') { $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere); foreach ($cpts as $j => $cpt) { - $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cpt['dc']); + $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, (empty($cpt['dc']) ? 0 : $cpt['dc'])); if ($return < 0) { setEventMessages(null, $AccCat->errors, 'errors'); $resultN = 0; @@ -380,7 +380,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''; print ''; print ''; - print ''; + print ''; print "\n"; } } @@ -1539,27 +1539,27 @@ print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print ''; if ($modecompta == 'CREANCES-DETTES') { - print ''; + print ''; } elseif ($modecompta == 'RECETTES-DEPENSES') { print ''; } -print ''; +print ''; print ''; print "
'; + print dol_escape_htmltag($invoicetmp->ref_supplier); + print "'; print $thirdpartytmp->getNomUrl(1); print "
'.$langs->trans("Total").'  '; //if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices"); // It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only. diff --git a/htdocs/compta/prelevement/list.php b/htdocs/compta/prelevement/list.php index 4906313cad1..8d9489bbec7 100644 --- a/htdocs/compta/prelevement/list.php +++ b/htdocs/compta/prelevement/list.php @@ -43,6 +43,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'directdebitcredittransferlinelist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'alpha'); $type = GETPOST('type', 'aZ09'); @@ -188,12 +189,18 @@ if ($result) { $param = "&statut=".urlencode($statut); $param .= "&search_bon=".urlencode($search_bon); + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if ($type == 'bank-transfer') { $param .= '&type=bank-transfer'; } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); print"\n\n"; print '
'."\n"; @@ -206,6 +213,8 @@ if ($result) { print ''; print ''; print ''; + print ''; + if ($type != '') { print ''; } @@ -214,7 +223,7 @@ if ($result) { if ($type == 'bank-transfer') { $title = $langs->trans("CreditTransferLines"); } - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1); $moreforfilter = ''; @@ -262,61 +271,77 @@ if ($result) { $bon->id = $obj->rowid; $bon->ref = $obj->ref; $bon->statut = $obj->status; + $bon->date_echeance = $obj->datec; + $bon->total = $obj->amount; $company->id = $obj->socid; $company->name = $obj->name; $company->email = $obj->email; $company->code_client = $obj->code_client; - print '
'; + print '
'; + } + // Output Kanban - print '
'; - print $bon->getNomUrl(1); - print "
'; - print $line->LibStatut($obj->statut_ligne, 2); - print " "; - print ''; - print substr('000000'.$obj->rowid_ligne, -6); - print ''; + print $bon->getNomUrl(1); + print "'; - $link_to_bill = '/compta/facture/card.php?facid='; - $link_title = 'Invoice'; - $link_picto = 'bill'; - if ($type == 'bank-transfer') { - $link_to_bill = '/fourn/facture/card.php?facid='; - $link_title = 'SupplierInvoice'; - $link_picto = 'supplier_invoice'; + print ''; + print $line->LibStatut($obj->statut_ligne, 2); + print " "; + print ''; + print substr('000000'.$obj->rowid_ligne, -6); + print ''; + $link_to_bill = '/compta/facture/card.php?facid='; + $link_title = 'Invoice'; + $link_picto = 'bill'; + if ($type == 'bank-transfer') { + $link_to_bill = '/fourn/facture/card.php?facid='; + $link_title = 'SupplierInvoice'; + $link_picto = 'supplier_invoice'; + } + print ''; + print img_object($langs->trans($link_title), $link_picto); + print ' '.$obj->invoiceref."'; + print $company->getNomUrl(1); + print "'; + $link_to_tab = '/comm/card.php?socid='; + $link_code = $obj->code_client; + if ($type == 'bank-transfer') { + $link_to_tab = '/fourn/card.php?socid='; + $link_code = $obj->code_fournisseur; + } + print ''.$link_code."'.dol_print_date($db->jdate($obj->datec), 'day')."'.price($obj->amount)." 
'; - print $company->getNomUrl(1); - print "'; - $link_to_tab = '/comm/card.php?socid='; - $link_code = $obj->code_client; - if ($type == 'bank-transfer') { - $link_to_tab = '/fourn/card.php?socid='; - $link_code = $obj->code_fournisseur; - } - print ''.$link_code."'.dol_print_date($db->jdate($obj->datec), 'day')."'.price($obj->amount)." 
'; + print '
'; + } + // Output Kanban - print '
'; - print $directdebitorder->getNomUrl(1); - print "
'.dol_print_date($db->jdate($obj->datec), 'day')."'; + print $directdebitorder->getNomUrl(1); + print "'.price($obj->amount)."'.dol_print_date($db->jdate($obj->datec), 'day')."'; - print $bon->LibStatut($obj->statut, 5); - print ''.price($obj->amount)."'; + print $bon->LibStatut($obj->statut, 5); + print '
'.$objp->pcg_type.'
'.dol_escape_htmltag($objp->pcg_type).'
'; - print $objp->pcg_type; - print ($objp->name ? ' ('.$objp->name.')' : ' ('.$langs->trans("Unknown").')'); + print dol_escape_htmltag($objp->pcg_type); + print ($objp->name ? ' ('.dol_escape_htmltag($objp->name).')' : ' ('.$langs->trans("Unknown").')'); print "'.price($objp->amount)."'.price($objp->amount)."
'; - print $objp->pcg_type; + print dol_escape_htmltag($objp->pcg_type); print "'.price($objp->amount)."'.price($objp->amount)."
    '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].''.price($resultN).''.price($resultN).'
'.$langs->trans("Income").''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ht_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).''.price(price2num($total_ttc_income, 'MT')).'
'.$langs->trans("Outcome").''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ht_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).''.price(price2num(-$total_ttc_outcome, 'MT')).'
'.$langs->trans("Profit").''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ht, 'MT')).''.price(price2num($total_ttc, 'MT')).''.price(price2num($total_ttc, 'MT')).'
"; diff --git a/htdocs/compta/resultat/result.php b/htdocs/compta/resultat/result.php index 3f3e14e2d61..e49f06034aa 100644 --- a/htdocs/compta/resultat/result.php +++ b/htdocs/compta/resultat/result.php @@ -184,8 +184,8 @@ llxheader('', $langs->trans('ReportInOut')); $formaccounting = new FormAccounting($db); $form = new Form($db); -$textprevyear = ''.img_previous().''; -$textnextyear = ' '.img_next().''; +$textprevyear = ''.img_previous().''; +$textnextyear = '   '.img_next().''; @@ -309,8 +309,8 @@ if ($modecompta == 'CREANCES-DETTES') { if (!is_array($cats) && $cats < 0) { setEventMessages(null, $AccCat->errors, 'errors'); } elseif (is_array($cats) && count($cats) > 0) { + // Loop on each custom group of accounts foreach ($cats as $cat) { - // Loop on each group if (!empty($cat['category_type'])) { // category calculed // When we enter here, $sommes was filled by group of accounts @@ -319,10 +319,10 @@ if ($modecompta == 'CREANCES-DETTES') { print '
'; + // Code and Label + print ''; print dol_escape_htmltag($cat['code']); - print ''; + print ''; print dol_escape_htmltag($cat['label']); print ''.$rshort.''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).''.price($r).'
'; + print ''; print dol_escape_htmltag($cat['code']); print ''; - print dol_escape_htmltag($cat['label']); + $labeltoshow = dol_escape_htmltag($cat['label']); if (count($cpts) > 0 && !empty($cpts[0])) { // Show example of 5 first accounting accounts $i = 0; foreach ($cpts as $cpt) { if ($i > 5) { - print '...)'; + $labeltoshow .= '...)'; break; } if ($i > 0) { - print ', '; + $labeltoshow .= ', '; } else { - print ' ('; + $labeltoshow .= ' ('; } - print dol_escape_htmltag($cpt['account_number']); + $labeltoshow .= dol_escape_htmltag($cpt['account_number']); $i++; } if ($i <= 5) { - print ')'; + $labeltoshow .= ')'; } } else { - print ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; + $labeltoshow .= ' - '.$langs->trans("GroupIsEmptyCheckSetup").''; } + print ''; + print $labeltoshow; print ''.price($totCat['NP']).''.price($totCat['N']).''.price($totCat['N']).'
'; - print '     '.length_accountg($cpt['account_number']); - print ' - '; - print $cpt['account_label']; + + if (isset($cpt['account_number'])) { + $labeldetail = '     '.length_accountg($cpt['account_number']).' - '.$cpt['account_label']; + } else { + $labeldetail = '-'; + } + + print ''; + print dol_escape_htmltag($labeldetail); print ''.price($resultNP).''.price($resultN).''.price($resultN).''.price($resultM).''.price($resultM).'
'; print '
'; if ($action == 'editmode') { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id'); + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'mode_reglement_id', '', 1, 1); } else { $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->mode_reglement_id, 'none'); } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 37b3540a0f5..3619ebfad7a 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -749,4 +749,41 @@ class ChargeSociales extends CommonObject $this->type = 1; $this->type_label = 'Type of social contribution'; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $conf, $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(0) : $this->ref).''; + if (property_exists($this, 'label')) { + $return .= '  
'.$this->label.'
'; + } + if (property_exists($this, 'date_ech')) { + $return .= '
'.$langs->trans("DateEnd").' : '.dol_print_date($this->date_ech, 'day').''; + } + if (property_exists($this, 'amount')) { + $return .= '
'; + $return .= ''.price($this->amount, 0, $langs, 1, -1, -1, $conf->currency).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->paye, 5, $this->alreadypaid).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 0bf402c6c21..73d101d7ae6 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -365,20 +365,17 @@ class PaymentSocialContribution extends CommonObject // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET"; - - $sql .= " fk_charge=".(isset($this->fk_charge) ? $this->fk_charge : "null").","; + $sql .= " fk_charge=".(isset($this->fk_charge) ? ((int) $this->fk_charge) : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; - $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; - $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " amount=".(isset($this->amount) ? price2num($this->amount) : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? ((int) $this->fk_typepaiement) : "null").","; $sql .= " num_paiement=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; - $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; - $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; - - + $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? ((int) $this->fk_user_creat) : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php index f70ed44de0c..a925fe6968d 100644 --- a/htdocs/compta/sociales/list.php +++ b/htdocs/compta/sociales/list.php @@ -47,6 +47,8 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'sclist'; +$mode = GETPOST('mode', 'alpha'); + $search_ref = GETPOST('search_ref', 'int'); $search_label = GETPOST('search_label', 'alpha'); @@ -294,6 +296,9 @@ $num = $db->num_rows($resql); $i = 0; $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -367,6 +372,8 @@ if ($search_date_limit_endyear) { } $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->rights->tax->charges->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('MenuNewSocialContribution'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/sociales/card.php?action=create'); } @@ -382,6 +389,8 @@ print ''; print ''; print ''; print ''; +print ''; + $center = ''; @@ -501,9 +510,9 @@ if (!empty($arrayfields['cs.amount']['checked'])) { // Filter: Status if (!empty($arrayfields['cs.paye']['checked'])) { - print '
'; + print ''; $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'.(($offset * $limit) + $i).'
'; + print '
'; } - } + // Output Kanban - // Ref - if (!empty($arrayfields['cs.rowid']['checked'])) { - print '
'.$chargesociale_static->getNomUrl(1, '20').'
'.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($typelabeltoshow).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.dol_print_date($db->jdate($obj->periode), 'day').''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if (!empty($obj->fk_user)) { - if (!empty($TLoadedUsers[$obj->fk_user])) { - $ustatic = $TLoadedUsers[$obj->fk_user]; - } else { - $ustatic = new User($db); - $ustatic->fetch($obj->fk_user); - $TLoadedUsers[$obj->fk_user] = $ustatic; + // Line number + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''.(($offset * $limit) + $i).''.$chargesociale_static->getNomUrl(1, '20').''.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($typelabeltoshow).''.dol_print_date($db->jdate($obj->date_ech), 'day').''.dol_print_date($db->jdate($obj->periode), 'day').''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if (!empty($obj->fk_user)) { + if (!empty($TLoadedUsers[$obj->fk_user])) { + $ustatic = $TLoadedUsers[$obj->fk_user]; + } else { + $ustatic = new User($db); + $ustatic->fetch($obj->fk_user); + $TLoadedUsers[$obj->fk_user] = $ustatic; + } + print $ustatic->getNomUrl(-1); + } + print "payment_code)).'">'; + if (!empty($obj->payment_code)) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + } + print ''; + if ($obj->fk_account > 0) { + $bankstatic->id = $obj->fk_account; + $bankstatic->ref = $obj->bref; + $bankstatic->number = $obj->bnumber; + $bankstatic->iban = $obj->iban; + $bankstatic->bic = $obj->bic; + $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $bankstatic->account_number = $obj->account_number; + $bankstatic->clos = $obj->clos; + + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + + $bankstatic->label = $obj->blabel; + print $bankstatic->getNomUrl(1); + } + print ''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
payment_code)).'">'; - if (!empty($obj->payment_code)) { - print $langs->trans("PaymentTypeShort".$obj->payment_code); - } - print ''; - if ($obj->fk_account > 0) { - $bankstatic->id = $obj->fk_account; - $bankstatic->ref = $obj->bref; - $bankstatic->number = $obj->bnumber; - $bankstatic->iban = $obj->iban; - $bankstatic->bic = $obj->bic; - $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); - $bankstatic->account_number = $obj->account_number; - $bankstatic->clos = $obj->clos; - - //$accountingjournal->fetch($obj->fk_accountancy_journal); - //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - - $bankstatic->label = $obj->blabel; - print $bankstatic->getNomUrl(1); - } - print ''.price($obj->amount).''.$chargesociale_static->LibStatut($obj->paye, 5, $obj->alreadypayed).'
'.price($totalpermonth[$j]).''.price(empty($totalpermonth[$j]) ? 0 : $totalpermonth[$j]).''.price($totalpermonth['total']).''.price(empty($totalpermonth['total']) ? 0 : $totalpermonth['total']).'
'; - print ($total_ht[$annee] ?price($total_ht[$annee]) : "0"); + print (empty($total_ht[$annee]) ? '0' : price($total_ht[$annee])); print " '; - print ($total[$annee] ?price($total[$annee]) : "0"); + print (empty($total[$annee]) ? '0' : price($total[$annee])); print " '; print ($percent >= 0 ? "+$percent" : "$percent").'%'; print '-100%+'.$langs->trans('Inf').'%+0%
'; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -389,16 +392,6 @@ if ($refresh === true) { $hookmanager->initHooks(array('externalbalance')); $reshook = $hookmanager->executeHooks('addVatLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - if (!is_array($x_coll) && $coll_listbuy == -1) { - $langs->load("errors"); - print ''; - break; - } - if (!is_array($x_paye) && $coll_listbuy == -2) { - print ''; - break; - } - print ''; print ''; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 1c70cf93c22..c839625a705 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -44,6 +44,7 @@ $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist'; +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref', 'alpha'); $search_label = GETPOST('search_label', 'alpha'); @@ -230,6 +231,9 @@ if (!$resql) { $num = $db->num_rows($resql); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { $param .= '&contextpage='.$contextpage; } @@ -317,7 +321,10 @@ $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewVATPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; @@ -398,9 +405,9 @@ if (!empty($arrayfields['t.amount']['checked'])) { // Status if (!empty($arrayfields['t.status']['checked'])) { - print ''; } @@ -461,116 +468,134 @@ while ($i < min($num, $limit)) { $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; $tva_static->label = $obj->label; + $tva_static->paiementtype = $obj->paye; + $tva_static->type_payment = $obj->payment_code; + $tva_static->datev = $obj->datev; + $tva_static->amount = $obj->amount; - print ''; - - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; - if (!$i) { - $totalarray['nbfield']++; + print $tva_static->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } + } else { + print ''; - // Label - if (!empty($arrayfields['t.label']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date end period - if (!empty($arrayfields['t.datev']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Ref + if (!empty($arrayfields['t.rowid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Date payment - /*if (!empty($arrayfields['t.datep']['checked'])) { - print ''; - if (!$i) $totalarray['nbfield']++; - }*/ - - // Type - if (!empty($arrayfields['t.fk_typepayment']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Label + if (!empty($arrayfields['t.label']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Account - if (!empty($arrayfields['t.fk_account']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Amount - if (!empty($arrayfields['t.amount']['checked'])) { - $total = $total + $obj->amount; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - $totalarray['pos'][$totalarray['nbfield']] = 'amount'; - if (empty($totalarray['val']['amount'])) { - $totalarray['val']['amount'] = $obj->amount; - } else { - $totalarray['val']['amount'] += $obj->amount; - } - } + // Date payment + /*if (!empty($arrayfields['t.datep']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + }*/ - if (!empty($arrayfields['t.status']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Type + if (!empty($arrayfields['t.fk_typepayment']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } + + // Account + if (!empty($arrayfields['t.fk_account']['checked'])) { + print ''; + if (!$i) $totalarray['nbfield']++; + } + + // Amount if (!empty($arrayfields['t.amount']['checked'])) { - $totalarray['pos'][$totalarray['nbfield']] = ''; + $total = $total + $obj->amount; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + $totalarray['pos'][$totalarray['nbfield']] = 'amount'; + if (empty($totalarray['val']['amount'])) { + $totalarray['val']['amount'] = $obj->amount; + } else { + $totalarray['val']['amount'] += $obj->amount; + } } + + if (!empty($arrayfields['t.status']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($arrayfields['t.amount']['checked'])) { + $totalarray['pos'][$totalarray['nbfield']] = ''; + } + } + + // Buttons + print ''; + + print ''; } - // Buttons - print ''; - - print ''; - $i++; } diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 29706f48b49..d0d2211c21c 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -81,7 +81,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -262,11 +262,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); } - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index 846f7440f97..f126b8c32a0 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -115,30 +115,5 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['action_delete'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("DeleteContact"), $langs->trans("ConfirmDeleteContact"), "confirm_delete", '', 0, 1); } } - - if ($action == 'list') { - $this->LoadListDatas($limit, $offset, $sortfield, $sortorder); - } - } - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Fetch datas list and save into ->list_datas - * - * @param int $limit Limit number of responses - * @param int $offset Offset for first response - * @param string $sortfield Sort field - * @param string $sortorder Sort order ('ASC' or 'DESC') - * @return void - */ - public function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { - // phpcs:enable - global $conf, $langs; - - //$this->getFieldList(); - - $this->list_datas = array(); } } diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index c5184a18454..cd94f4ebbac 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -213,11 +213,6 @@ if (empty($reshook)) { $object->town = (string) GETPOST("town", 'alpha'); $object->country_id = (int) GETPOST("country_id", 'int'); $object->state_id = (int) GETPOST("state_id", 'int'); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); if (isModEnabled('socialnetworks')) { foreach ($socialnetworks as $key => $value) { @@ -322,9 +317,6 @@ if (empty($reshook)) { $result = $object->fetch($id); $object->oldcopy = clone $object; - $object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); - $object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); - $result = $object->delete(); // TODO Add $user as first param if ($result > 0) { setEventMessages("RecordDeleted", null, 'mesgs'); @@ -362,7 +354,7 @@ if (empty($reshook)) { if (!$error) { $contactid = GETPOST("contactid", 'int'); $object->fetch($contactid); - $object->fetchRoles($contactid); + $object->fetchRoles(); // Photo save $dir = $conf->societe->multidir_output[$object->entity]."/contact/".$object->id."/photos"; @@ -408,9 +400,6 @@ if (empty($reshook)) { $object->oldcopy = clone $object; - $object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); - $object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); - $object->socid = GETPOST("socid", 'int'); $object->lastname = (string) GETPOST("lastname", 'alpha'); $object->firstname = (string) GETPOST("firstname", 'alpha'); @@ -425,11 +414,6 @@ if (empty($reshook)) { $object->email = (string) GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL); $object->no_email = GETPOST("no_email", "int"); - //$object->jabberid = GETPOST("jabberid", 'alpha'); - //$object->skype = GETPOST("skype", 'alpha'); - //$object->twitter = GETPOST("twitter", 'alpha'); - //$object->facebook = GETPOST("facebook", 'alpha'); - //$object->linkedin = GETPOST("linkedin", 'alpha'); $object->socialnetworks = array(); if (isModEnabled('socialnetworks')) { foreach ($socialnetworks as $key => $value) { @@ -862,23 +846,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } - + // Social network if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } + $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4)); } // Visibility @@ -986,7 +956,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { /* set country at end because it will trigger page refresh */ console.log("Set country id to '.dol_escape_js($objsoc->country_id).'"); $(\'select[name="country_id"]\').val("'.dol_escape_js($objsoc->country_id).'").trigger("change"); /* trigger required to update select2 components */ - }); + }); })'."\n"; print ''."\n"; } @@ -996,8 +966,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; print ''; - print ''; - print ''; if (!empty($backtopage)) { print ''; } @@ -1047,7 +1015,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'; print ''; print '
'; - if ($conf->use_javascript_ajax) { + if (!empty($conf->use_javascript_ajax)) { print ''.$langs->trans('CopyAddressFromSoc').'
'; } print '
'; @@ -1150,22 +1118,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + // Social network if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if ($value['active']) { - print ''; - print ''; - print ''; - print ''; - } elseif (!empty($object->socialnetworks[$key])) { - print ''; - } - } + $object->showSocialNetwork($socialnetworks, ($conf->browser->layout == 'phone' ? 2 : 4)); } // Visibility diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index d535da76199..52ea2b69c8d 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -32,6 +32,7 @@ * \brief File of contacts class */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonsocialnetworks.class.php'; /** @@ -39,6 +40,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Contact extends CommonObject { + use CommonSocialNetworks; + /** * @var string ID to identify managed object */ @@ -130,6 +133,16 @@ class Contact extends CommonObject public $civility_code; public $civility; + /** + * @var int egroupware_id + */ + public $egroupware_id; + + /** + * @var int birthday_alert + */ + public $birthday_alert; + /** * @var string The civilite code, not an integer * @deprecated @@ -137,6 +150,11 @@ class Contact extends CommonObject */ public $civilite; + /** + * @var string fullname + */ + public $fullname; + /** * @var string Address */ @@ -353,9 +371,9 @@ class Contact extends CommonObject $this->fields['fk_soc']['searchall'] = 0; } - if (empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { // Default behaviour - $this->field['fk_stcommcontact']['enabled'] = 0; - $this->field['fk_prospectcontactlevel']['enabled'] = 0; + if (!empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { // Default behaviour + $this->fields['fk_stcommcontact']['enabled'] = 0; + $this->fields['fk_prospectlevel']['enabled'] = 0; } // Unset fields that are disabled @@ -608,7 +626,7 @@ class Contact extends CommonObject $sql .= ", phone_perso = ".(isset($this->phone_perso) ? "'".$this->db->escape($this->phone_perso)."'" : "NULL"); $sql .= ", phone_mobile = ".(isset($this->phone_mobile) ? "'".$this->db->escape($this->phone_mobile)."'" : "NULL"); $sql .= ", priv = '".$this->db->escape($this->priv)."'"; - $sql .= ", fk_prospectcontactlevel = '".$this->db->escape($this->fk_prospectlevel)."'"; + $sql .= ", fk_prospectlevel = '".$this->db->escape($this->fk_prospectlevel)."'"; if (isset($this->stcomm_id)) { $sql .= ", fk_stcommcontact = ".($this->stcomm_id > 0 || $this->stcomm_id == -1 ? $this->stcomm_id : "0"); } @@ -684,22 +702,6 @@ class Contact extends CommonObject $tmpobj->socialnetworks = $this->socialnetworks; $usermustbemodified++; } - // if ($tmpobj->skype != $this->skype) { - // $tmpobj->skype = $this->skype; - // $usermustbemodified++; - // } - // if ($tmpobj->twitter != $this->twitter) { - // $tmpobj->twitter = $this->twitter; - // $usermustbemodified++; - // } - // if ($tmpobj->facebook != $this->facebook) { - // $tmpobj->facebook = $this->facebook; - // $usermustbemodified++; - // } - // if ($tmpobj->linkedin != $this->linkedin) { - // $tmpobj->linkedin = $this->linkedin; - // $usermustbemodified++; - // } if ($usermustbemodified) { $result = $tmpobj->update($user, 0, 1, 1, 1); if ($result < 0) { @@ -832,9 +834,6 @@ class Contact extends CommonObject if ($this->fax && !empty($conf->global->LDAP_CONTACT_FIELD_FAX)) { $info[$conf->global->LDAP_CONTACT_FIELD_FAX] = $this->fax; } - if ($this->skype && !empty($conf->global->LDAP_CONTACT_FIELD_SKYPE)) { - $info[$conf->global->LDAP_CONTACT_FIELD_SKYPE] = $this->skype; - } if ($this->note_private && !empty($conf->global->LDAP_CONTACT_FIELD_DESCRIPTION)) { $info[$conf->global->LDAP_CONTACT_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_private, 2); } @@ -987,7 +986,7 @@ class Contact extends CommonObject $sql .= " c.socialnetworks,"; $sql .= " c.photo,"; $sql .= " c.priv, c.note_private, c.note_public, c.default_lang, c.canvas,"; - $sql .= " c.fk_prospectcontactlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; + $sql .= " c.fk_prospectlevel, c.fk_stcommcontact, st.libelle as stcomm, st.picto as stcomm_picto,"; $sql .= " c.import_key,"; $sql .= " c.datec as date_creation, c.tms as date_modification,"; $sql .= " co.label as country, co.code as country_code,"; @@ -1054,7 +1053,7 @@ class Contact extends CommonObject $this->poste = $obj->poste; $this->statut = $obj->statut; - $this->fk_prospectlevel = $obj->fk_prospectcontactlevel; + $this->fk_prospectlevel = $obj->fk_prospectlevel; $transcode = $langs->trans('StatusProspect'.$obj->fk_stcommcontact); $libelle = ($transcode != 'StatusProspect'.$obj->fk_stcommcontact ? $transcode : $obj->stcomm); @@ -1700,8 +1699,8 @@ class Contact extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { @@ -1712,18 +1711,18 @@ class Contact extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'socpeople', 'societe_contacts' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -1789,6 +1788,8 @@ class Contact extends CommonObject $sql = "SELECT sc.fk_socpeople as id, sc.fk_c_type_contact"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact tc"; $sql .= ", ".MAIN_DB_PREFIX."societe_contacts sc"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."socpeople sp"; + $sql .= " ON sc.fk_socpeople = sp.rowid AND sp.statut = 1"; $sql .= " WHERE sc.fk_soc =".((int) $this->socid); $sql .= " AND sc.fk_c_type_contact=tc.rowid"; $sql .= " AND tc.element = '".$this->db->escape($element)."'"; @@ -2115,4 +2116,48 @@ class Contact extends CommonObject } return 0; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + //var_dump($this->photo);exit; + if (property_exists($this, 'photo') && !is_null($this->photo)) { + $return.= Form::showphoto('contact', $this, 0, 60, 0, 'photokanban photoref photowithmargin photologintooltip', 'small', 0, 1); + } else { + $return .= img_picto('', $this->picto); + } + $return .= ''; + $return .= '
'; + $return .= '
'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'
'; + + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } + /*if (property_exists($this, 'phone_pro') && !empty($this->phone_pro)) { + $return .= '
'.img_picto($langs->trans("Phone"), 'phone'); + $return .= ' '.$this->phone_pro.''; + }*/ + /*if (method_exists($this, 'LibPubPriv')) { + $return .= '
'.$langs->trans("Visibility").''; + $return .= ' : '.$this->LibPubPriv($this->priv).''; + }*/ + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index e8c4174af71..f34c477ff71 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -53,6 +53,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contactlist'; +$mode = GETPOST('mode', 'alpha'); // Security check $id = GETPOST('id', 'int'); @@ -72,6 +73,7 @@ $search_firstlast_only = GETPOST("search_firstlast_only", 'alpha'); $search_lastname = GETPOST("search_lastname", 'alpha'); $search_firstname = GETPOST("search_firstname", 'alpha'); $search_societe = GETPOST("search_societe", 'alpha'); +$search_societe_alias = GETPOST("search_societe_alias", 'alpha'); $search_poste = GETPOST("search_poste", 'alpha'); $search_phone_perso = GETPOST("search_phone_perso", 'alpha'); $search_phone_pro = GETPOST("search_phone_pro", 'alpha'); @@ -99,10 +101,10 @@ $search_type = GETPOST('search_type', 'alpha'); $search_address = GETPOST('search_address', 'alpha'); $search_zip = GETPOST('search_zip', 'alpha'); $search_town = GETPOST('search_town', 'alpha'); -$search_import_key = GETPOST("search_import_key", "alpha"); +$search_import_key = GETPOST("search_import_key", 'alpha'); $search_country = GETPOST("search_country", 'intcomma'); $search_roles = GETPOST("search_roles", 'array'); -$search_level = GETPOST("search_level", "array"); +$search_level = GETPOST("search_level", 'array'); $search_stcomm = GETPOST('search_stcomm', 'int'); if ($search_status === '') { @@ -192,6 +194,7 @@ foreach ($object->fields as $key => $val) { // Add none object fields for "search in all" if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $fieldstosearchall['s.nom'] = "ThirdParty"; + $fieldstosearchall['s.name_alias'] = "AliasNames"; } // Definition of fields for list @@ -213,6 +216,7 @@ foreach ($object->fields as $key => $val) { $arrayfields['country.code_iso'] = array('label'=>"Country", 'position'=>66, 'checked'=>0); if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { $arrayfields['s.nom'] = array('label'=>"ThirdParty", 'position'=>113, 'checked'=> 1); + $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'position'=>114, 'checked'=> 1); } $arrayfields['unsubscribed'] = array( @@ -277,6 +281,7 @@ if (empty($reshook)) { $search_lastname = ""; $search_firstname = ""; $search_societe = ""; + $search_societe_alias = ""; $search_town = ""; $search_address = ""; $search_zip = ""; @@ -345,13 +350,21 @@ $formother = new FormOther($db); $formcompany = new FormCompany($db); $contactstatic = new Contact($db); -$morejs=array(); +$morejs = array(); $morecss = array(); +// Page Header +$title = $langs->trans("Contacts")." - ".$langs->trans("List"); +$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); + if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) { $contactstatic->loadCacheOfProspStatus(); } +$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + // Select every potentiels, and note each potentiels which fit in search parameters $tab_level = array(); $sql = "SELECT code, label, sortorder"; @@ -372,13 +385,14 @@ if ($resql) { dol_print_error($db); } -$sql = "SELECT s.rowid as socid, s.nom as name,"; +$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias as alias,"; $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.address, p.zip, p.town, p.poste, p.email,"; $sql .= " p.socialnetworks, p.photo,"; $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,"; $sql .= " p.import_key,"; -$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,"; +$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectlevel,"; $sql .= " co.label as country, co.code as country_code"; + // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { @@ -388,13 +402,15 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { if (isModEnabled('mailing')) { $sql .= ", (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = p.email) as unsubscribed"; } -// Add fields from hooks + +// Add fields from hooks - ListSelect $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sqlfields = $sql; // $sql fields to remove for count total +// SQL Table Aliase $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; if (isset($extrafields->attributes[$object->table_element]['label']) && 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 (p.rowid = ef.fk_object)"; @@ -405,6 +421,11 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stco if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; } + +// Add fields from hooks - ListFrom +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= ' WHERE p.entity IN ('.getEntity('contact').')'; if (empty($user->rights->societe->client->voir) && !$socid) { //restriction $sql .= " AND (sc.fk_user = ".((int) $user->id)." OR p.fk_soc IS NULL)"; @@ -413,7 +434,7 @@ if (!empty($userid)) { // propre au commercial $sql .= " AND p.fk_user_creat=".((int) $userid); } if ($search_level) { - $sql .= natural_search("p.fk_prospectcontactlevel", join(',', $search_level), 3); + $sql .= natural_search("p.fk_prospectlevel", join(',', $search_level), 3); } if ($search_stcomm != '' && $search_stcomm != -2) { $sql .= natural_search("p.fk_stcommcontact", $search_stcomm, 2); @@ -431,9 +452,13 @@ if ($search_priv != '0' && $search_priv != '1') { } } + +// Search Categories + + // Search Contact Categories $searchCategoryContactList = $search_categ ? array($search_categ) : array(); $searchCategoryContactOperator = 0; -// Search for tag/category ($searchCategoryContactList is an array of ID) + // Search for tag/category ($searchCategoryContactList is an array of ID) if (!empty($searchCategoryContactList)) { $searchCategoryContactSqlList = array(); $listofcategoryid = ''; @@ -461,9 +486,11 @@ if (!empty($searchCategoryContactList)) { } } } + + // Search Customer Categories $searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array(); $searchCategoryCustomerOperator = 0; -// Search for tag/category ($searchCategoryCustomerList is an array of ID) + // Search for tag/category ($searchCategoryCustomerList is an array of ID) if (!empty($searchCategoryCustomerList)) { $searchCategoryCustomerSqlList = array(); $listofcategoryid = ''; @@ -491,9 +518,11 @@ if (!empty($searchCategoryCustomerList)) { } } } + + // Search Supplier Categories $searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array(); $searchCategorySupplierOperator = 0; -// Search for tag/category ($searchCategorySupplierList is an array of ID) + // Search for tag/category ($searchCategorySupplierList is an array of ID) if (!empty($searchCategorySupplierList)) { $searchCategorySupplierSqlList = array(); $listofcategoryid = ''; @@ -544,8 +573,15 @@ if ($search_lastname) { if ($search_firstname) { $sql .= natural_search('p.firstname', $search_firstname); } -if ($search_societe) { - $sql .= natural_search(empty($conf->global->SOCIETE_DISABLE_CONTACTS) ? 's.nom' : 'p.fk_soc', $search_societe); +if (empty($arrayfields['s.name_alias']['checked']) && $search_societe) { + $sql .= natural_search(array("s.nom", "s.name_alias"), $search_societe); +} else { + if ($search_societe) { + $sql .= natural_search('s.nom', $search_societe); + } + if ($search_societe_alias) { + $sql .= natural_search('s.name_alias', $search_societe_alias); + } } if ($search_country) { $sql .= " AND p.fk_pays IN (".$db->sanitize($search_country).')'; @@ -581,6 +617,7 @@ if (isModEnabled('socialnetworks')) { } } //print $sql; + if (strlen($search_email)) { $sql .= natural_search('p.email', $search_email); } @@ -608,20 +645,22 @@ if ($search_status != '' && $search_status >= 0) { if ($search_import_key) { $sql .= natural_search("p.import_key", $search_import_key); } -if ($type == "o") { // filtre sur type +if ($type == "o") { // filter on type $sql .= " AND p.fk_soc IS NULL"; -} elseif ($type == "f") { // filtre sur type +} elseif ($type == "f") { // filter on type $sql .= " AND s.fournisseur = 1"; -} elseif ($type == "c") { // filtre sur type +} elseif ($type == "c") { // filter on type $sql .= " AND s.client IN (1, 3)"; -} elseif ($type == "p") { // filtre sur type +} elseif ($type == "p") { // filter on type $sql .= " AND s.client IN (2, 3)"; } if (!empty($socid)) { $sql .= " AND s.rowid = ".((int) $socid); } + // 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, $object, $action); // Note that $action and $object may have been modified by hook @@ -676,10 +715,12 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( exit; } -$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas'; -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); + $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -712,6 +753,9 @@ if ($search_firstname != '') { if ($search_societe != '') { $param .= '&search_societe='.urlencode($search_societe); } +if ($search_societe_alias != '') { + $param .= '&search_societe_alias='.urlencode($search_societe_alias); +} if ($search_address != '') { $param .= '&search_address='.urlencode($search_address); } @@ -774,7 +818,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; // List of mass actions available $arrayofmassactions = array( -// 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + 'presend' => img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), // 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); @@ -789,7 +833,10 @@ if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) { } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); print ''; if ($optioncss != '') { @@ -802,6 +849,8 @@ print ''; //print ''; print ''; print ''; +print ''; + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -918,20 +967,25 @@ if (!empty($arrayfields['p.town']['checked'])) { print ''; print ''; } + +/* // State -/*if (!empty($arrayfields['state.nom']['checked'])) + if (!empty($arrayfields['state.nom']['checked'])) { print ''; } + // Region if (!empty($arrayfields['region.nom']['checked'])) { print ''; - }*/ + } +*/ + // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; } +// Alias of ThirdParty +if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; +} if (!empty($arrayfields['p.priv']['checked'])) { print ''; } // Prospect level -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { +if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { print ''; @@ -1025,8 +1085,8 @@ if (!empty($arrayfields['p.tms']['checked'])) { } // Status if (!empty($arrayfields['p.statut']['checked'])) { - print ''; } if (!empty($arrayfields['p.import_key']['checked'])) { @@ -1043,7 +1103,7 @@ if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { } print ''; -// Ligne des titres +// Title line print ''; if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1105,11 +1165,14 @@ if (!empty($arrayfields['p.fk_soc']['checked'])) { if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $begin, $param, '', $sortfield, $sortorder); } +if (!empty($arrayfields['s.name_alias']['checked'])) { + print_liste_field_titre($arrayfields['s.name_alias']['label'], $_SERVER["PHP_SELF"], "s.name_alias", $begin, $param, '', $sortfield, $sortorder); +} if (!empty($arrayfields['p.priv']['checked'])) { print_liste_field_titre($arrayfields['p.priv']['label'], $_SERVER["PHP_SELF"], "p.priv", $begin, $param, '', $sortfield, $sortorder, 'center '); } -if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { - print_liste_field_titre($arrayfields['p.fk_prospectcontactlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectcontactlevel", "", $param, '', $sortfield, $sortorder, 'center '); +if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { + print_liste_field_titre($arrayfields['p.fk_prospectlevel']['label'], $_SERVER["PHP_SELF"], "p.fk_prospectlevel", "", $param, '', $sortfield, $sortorder, 'center '); } if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { print_liste_field_titre($arrayfields['p.fk_stcommcontact']['label'], $_SERVER["PHP_SELF"], "p.fk_stcommcontact", "", $param, '', $sortfield, $sortorder, 'center '); @@ -1168,267 +1231,317 @@ while ($i < min($num, $limit)) { $contactstatic->photo = $obj->photo; $contactstatic->import_key = $obj->import_key; - $contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel; + $contactstatic->fk_prospectlevel = $obj->fk_prospectlevel; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + } + } else { + print ''; - // Action column - if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; } - print ''; - } - // ID - if (!empty($arrayfields['p.rowid']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; + + // ID + if (!empty($arrayfields['p.rowid']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Name - if (!empty($arrayfields['p.lastname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // (Last) Name + if (!empty($arrayfields['p.lastname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Firstname - if (!empty($arrayfields['p.firstname']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Firstname + if (!empty($arrayfields['p.firstname']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Job position - if (!empty($arrayfields['p.poste']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Job position + if (!empty($arrayfields['p.poste']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Address - if (!empty($arrayfields['p.address']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Address + if (!empty($arrayfields['p.address']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Zip - if (!empty($arrayfields['p.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Zip + if (!empty($arrayfields['p.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Town - if (!empty($arrayfields['p.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Town + if (!empty($arrayfields['p.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // State - /*if (!empty($arrayfields['state.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - } - // Region - if (!empty($arrayfields['region.nom']['checked'])) - { - print "\n"; - if (! $i) $totalarray['nbfield']++; - }*/ - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + /* + // State + if (!empty($arrayfields['state.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; } - } - // Phone - if (!empty($arrayfields['p.phone']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Region + if (!empty($arrayfields['region.nom']['checked'])) + { + print "\n"; + if (! $i) $totalarray['nbfield']++; + }*/ + + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone perso - if (!empty($arrayfields['p.phone_perso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Phone pro + if (!empty($arrayfields['p.phone']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Phone mobile - if (!empty($arrayfields['p.phone_mobile']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Phone perso + if (!empty($arrayfields['p.phone_perso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // Fax - if (!empty($arrayfields['p.fax']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Phone mobile + if (!empty($arrayfields['p.phone_mobile']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // EMail - if (!empty($arrayfields['p.email']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Fax + if (!empty($arrayfields['p.fax']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - // No EMail - if (!empty($arrayfields['unsubscribed']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // No EMail Subscription + if (!empty($arrayfields['unsubscribed']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (isModEnabled('socialnetworks')) { - foreach ($socialnetworks as $key => $value) { - if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + + // Social Networks + if (isModEnabled('socialnetworks')) { + foreach ($socialnetworks as $key => $value) { + if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } } } - } - // Company - if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Private/Public - if (!empty($arrayfields['p.priv']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + // Company / Third Party + if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked'])) { - // Prospect level - print '"; - if (!$i) { - $totalarray['nbfield']++; + // Alias name + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Private/Public + if (!empty($arrayfields['p.priv']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Prospect Level + if (!empty($arrayfields['p.fk_prospectlevel']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { // Prospect status - print ''; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['p.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['p.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['p.statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Import key - if (!empty($arrayfields['p.import_key']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Action column - if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { - print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Date modification + if (!empty($arrayfields['p.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Status + if (!empty($arrayfields['p.statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Import key + if (!empty($arrayfields['p.import_key']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/contact/vcard.php b/htdocs/contact/vcard.php index fe11c90c0b9..d366d1c2b17 100644 --- a/htdocs/contact/vcard.php +++ b/htdocs/contact/vcard.php @@ -92,18 +92,23 @@ if ($company->id) { } elseif (empty(trim($contact->email))) { // when contact e-mail is empty, use only company e-mail $v->setEmail($company->email); - } elseif (strtolower(end(explode("@", $contact->email))) == strtolower(end(explode("@", $company->email)))) { - // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) - $v->setEmail($contact->email); - - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($company->email, 'INTERNET'); } else { - // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) - $v->setEmail($company->email); + $tmpcontact = explode("@", trim($contact->email)); + $tmpcompany = explode("@", trim($company->email)); - // support by Microsoft Outlook (2019 and possible earlier) - $v->setEmail($contact->email, 'INTERNET'); + if (strtolower(end($tmpcontact)) == strtolower(end($tmpcompany))) { + // when e-mail domain of contact and company are the same, use contact e-mail at first (and company e-mail at second) + $v->setEmail($contact->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($company->email, 'INTERNET'); + } else { + // when e-mail of contact and company complete different use company e-mail at first (and contact e-mail at second) + $v->setEmail($company->email); + + // support by Microsoft Outlook (2019 and possible earlier) + $v->setEmail($contact->email, 'INTERNET'); + } } // Si contact lie a un tiers non de type "particulier" diff --git a/htdocs/contrat/agenda.php b/htdocs/contrat/agenda.php index 3a3c5440b30..e631c6a4a60 100644 --- a/htdocs/contrat/agenda.php +++ b/htdocs/contrat/agenda.php @@ -41,7 +41,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -54,7 +54,11 @@ $ref = GETPOST('ref', 'alpha'); if ($user->socid) { $socid = $user->socid; } -$result = restrictedArea($user, 'contrat', $id, ''); + +// Security check +$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : '')); +$fieldtype = (!empty($id) ? 'rowid' : 'ref'); +$result = restrictedArea($user, 'contrat', $fieldvalue, '', '', '', $fieldtype); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -73,6 +77,13 @@ if (!$sortorder) { $sortorder = 'DESC,DESC'; } + +$object = new Contrat($db); + +if ($id > 0 || !empty($ref)) { + $result = $object->fetch($id, $ref); +} + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('agendacontract', 'globalcard')); @@ -83,7 +94,7 @@ $permissiontoadd = $user->rights->contrat->creer; // Used by the include * Actions */ -$parameters = array('id'=>$id); +$parameters = array('id' => $id, 'ref' => $ref); $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'); @@ -104,8 +115,6 @@ if (empty($reshook)) { } - - /* * View */ @@ -116,7 +125,7 @@ if (isModEnabled('project')) { $formproject = new FormProjets($db); } -if ($id > 0) { +if ($object->id > 0) { // Load object modContract $module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { @@ -130,8 +139,6 @@ if ($id > 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; - $object = new Contrat($db); - $result = $object->fetch($id); $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); @@ -181,7 +188,7 @@ if ($id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -195,13 +202,13 @@ if ($id > 0) { } $morehtmlref .= ''; - dol_banner_tab($object, 'id', $linkback, 1, 'ref', 'none', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref); print '
'; print '
'; - $object->info($id); + $object->info($object->id); dol_print_object_info($object, 1); print '
'; @@ -221,7 +228,7 @@ if ($id > 0) { { //$out.='trans("AddAnAction"),'filenew'); //$out.=""; @@ -234,7 +241,7 @@ if ($id > 0) { $newcardbutton = ''; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { $backtopage = $_SERVER['PHP_SELF'].'?id='.$object->id; $out = '&origin='.$object->element.'&originid='.$object->id.'&backtopage='.urlencode($backtopage); $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); @@ -244,7 +251,7 @@ if ($id > 0) { if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { print '
'; - $param = '&id='.$id; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.$contextpage; } diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 7aad6ca9c54..54779bb692d 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -143,7 +143,16 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) { - $result = $object->active_line($user, GETPOST('ligne', 'int'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment')); + $date_start = ''; + $date_end = ''; + if (GETPOST('startmonth') && GETPOST('startday') && GETPOST('startyear')) { + $date_start = dol_mktime(GETPOST('starthour'), GETPOST('startmin'), 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear')); + } + if (GETPOST('endmonth') && GETPOST('endday') && GETPOST('endyear')) { + $date_end = dol_mktime(GETPOST('endhour'), GETPOST('endmin'), 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + + $result = $object->active_line($user, GETPOST('ligne', 'int'), $date_start, $date_end, GETPOST('comment')); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -152,12 +161,16 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_closeline' && $confirm == 'yes' && $user->rights->contrat->activer) { - if (!GETPOST('dateend')) { + $date_end = ''; + if (GETPOST('endmonth') && GETPOST('endday') && GETPOST('endyear')) { + $date_end = dol_mktime(GETPOST('endhour'), GETPOST('endmin'), 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); + } + if (!$date_end) { $error++; setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEnd")), null, 'errors'); } if (!$error) { - $result = $object->close_line($user, GETPOST('ligne', 'int'), GETPOST('dateend'), urldecode(GETPOST('comment'))); + $result = $object->close_line($user, GETPOST('ligne', 'int'), $date_end, urldecode(GETPOST('comment'))); if ($result > 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; @@ -374,6 +387,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { @@ -427,6 +441,7 @@ if (empty($reshook)) { } else { $idprod = GETPOST('idprod', 'int'); } + $tva_tx = GETPOST('tva_tx', 'alpha'); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); @@ -474,11 +489,11 @@ if (empty($reshook)) { $prod->fetch($idprod); // Update if prices fields are defined - $tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); + /*$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id); $tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id); if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ $price_min = $prod->price_min; $price_min_ttc = $prod->price_min_ttc; @@ -500,14 +515,14 @@ if (empty($reshook)) { if (count($prodcustprice->lines) > 0) { $price_min = price($prodcustprice->lines[0]->price_min); $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc); - $tva_tx = $prodcustprice->lines[0]->tva_tx; + /*$tva_tx = $prodcustprice->lines[0]->tva_tx; if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; } $tva_npr = $prodcustprice->lines[0]->recuperableonly; if (empty($tva_tx)) { $tva_npr = 0; - } + }*/ } } } @@ -699,7 +714,7 @@ if (empty($reshook)) { $date_end_real_update = $objectline->date_end_real; } - $vat_rate = GETPOST('eltva_tx'); + $vat_rate = GETPOST('eltva_tx', 'alpha'); // Define info_bits $info_bits = 0; if (preg_match('/\*/', $vat_rate)) { @@ -1377,7 +1392,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -1513,7 +1528,7 @@ if ($action == 'create') { // print ''; //} print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -1594,7 +1609,7 @@ if ($action == 'create') { // Quantity print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } // Discount @@ -1701,7 +1716,7 @@ if ($action == 'create') { if (empty($senderissupplier)) { print $form->select_produits((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } else { - print $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); + $form->select_produits_fournisseurs((!empty($object->lines[$cursorline - 1]->fk_product) ? $object->lines[$cursorline - 1]->fk_product : 0), 'idprod'); } } print '
'; @@ -1739,7 +1754,7 @@ if ($action == 'create') { print ''; // Unit - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; @@ -1765,7 +1780,7 @@ if ($action == 'create') { if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) { $colspan++; } - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $colspan++; } @@ -1836,34 +1851,6 @@ if ($action == 'create') { print '
' . $langs->trans("Year") . " " . $y . '' . $langs->trans("Year") . '' . $langs->trans("VATToPay") . '' . $langs->trans("VATToCollect") . '' . $langs->trans("Balance") . '
' . $langs->trans("ErrorNoAccountancyModuleLoaded") . '
' . $langs->trans("FeatureNotYetAvailable") . '
' . dol_print_date(dol_mktime(0, 0, 0, $m, 1, $y), "%b %Y") . ''; + print ''; $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'.(($offset * $limit) + $i).'
'; + print '
'; } - } + // Output Kanban - // Ref - if (!empty($arrayfields['t.rowid']['checked'])) { - print '
'; - print $tva_static->getNomUrl(1); - $filename = dol_sanitizeFileName($tva_static->ref); - $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id; - print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp'); - print '
'.dol_trunc($obj->label, 40).''.(($offset * $limit) + $i).''.dol_print_date($db->jdate($obj->datev), 'day').''; + print $tva_static->getNomUrl(1); + $filename = dol_sanitizeFileName($tva_static->ref); + $filedir = $conf->tax->dir_output.'/vat/'.dol_sanitizeFileName($tva_static->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$tva_static->id; + print $formfile->getDocumentsLink($tva_static->element, $filename, $filedir, '', 'valignmiddle paddingleft2imp'); + print ''.dol_print_date($db->jdate($obj->datep), 'day').''; - if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); - print ''.dol_trunc($obj->label, 40).''; - if ($obj->fk_account > 0) { - $bankstatic->id = $obj->fk_account; - $bankstatic->ref = $obj->bref; - $bankstatic->number = $obj->bnumber; - $bankstatic->iban = $obj->iban; - $bankstatic->bic = $obj->bic; - $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); - $bankstatic->account_number = $obj->account_number; - $bankstatic->clos = $obj->clos; - - //$accountingjournal->fetch($obj->fk_accountancy_journal); - //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); - - $bankstatic->label = $obj->blabel; - print $bankstatic->getNomUrl(1); + // Date end period + if (!empty($arrayfields['t.datev']['checked'])) { + print ''.dol_print_date($db->jdate($obj->datev), 'day').'' . price($obj->amount) . ''.dol_print_date($db->jdate($obj->datep), 'day').'' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . ''; + if (!empty($obj->payment_code)) print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ''; + if ($obj->fk_account > 0) { + $bankstatic->id = $obj->fk_account; + $bankstatic->ref = $obj->bref; + $bankstatic->number = $obj->bnumber; + $bankstatic->iban = $obj->iban; + $bankstatic->bic = $obj->bic; + $bankstatic->currency_code = $langs->trans("Currency".$obj->currency_code); + $bankstatic->account_number = $obj->account_number; + $bankstatic->clos = $obj->clos; + + //$accountingjournal->fetch($obj->fk_accountancy_journal); + //$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + + $bankstatic->label = $obj->blabel; + print $bankstatic->getNomUrl(1); + } + print '' . price($obj->amount) . '' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . '
'; - if (!empty($value['icon'])) { - print ''; - } - print ''; - print '
'; - if (!empty($value['icon'])) { - print ''; - } - print ''; - print '
'; print ''; print ''; print ''; print ''; @@ -984,6 +1038,12 @@ if (!empty($arrayfields['p.fk_soc']['checked']) || !empty($arrayfields['s.nom'][ print ''; print ''; + print ''; + print ''; $selectarray = array('0'=>$langs->trans("ContactPublic"), '1'=>$langs->trans("ContactPrivate")); @@ -991,7 +1051,7 @@ if (!empty($arrayfields['p.priv']['checked'])) { print ''; print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2); print ''; - print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75 onrightofpage'); + print ''; + print $form->selectarray('search_status', array('-1'=>'', '0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $search_status, 0, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; + print '
'; + } + $contactstatic->photo = $obj->photo; + if ($obj->socid > 0) { + $contactstatic->fetch_thirdparty($obj->socid); + } + print $contactstatic->getKanbanView(''); + if ($i == min($num, $limit) - 1) { + print '
'; + print '
'; - 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; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; + print ''; - print dol_escape_htmltag($obj->rowid); - print "'; + print dol_escape_htmltag($obj->rowid); + print "'; - print $contactstatic->getNomUrl(1); - print ''; + print $contactstatic->getNomUrl(1); + print ''.dol_escape_htmltag($obj->firstname).''.dol_escape_htmltag($obj->firstname).''.dol_escape_htmltag($obj->poste).''.dol_escape_htmltag($obj->poste).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->town).''.dol_escape_htmltag($obj->town).'".$obj->state_name."".$obj->region_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print dol_escape_htmltag($tmparray['label']); - print '".$obj->state_name."'.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').'".$obj->region_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print dol_escape_htmltag($tmparray['label']); + print ''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_pro, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_phone($obj->phone_perso, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'phone').''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''.dol_print_phone($obj->phone_mobile, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'mobile').''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''.dol_print_phone($obj->fax, $obj->country_code, $obj->rowid, $obj->socid, 'AC_TEL', ' ', 'fax').''; - if (empty($obj->email)) { - //print ''.$langs->trans("NoEmail").''; - } else { - print yn(($obj->unsubscribed > 0) ? 1 : 0); + + // EMail + if (!empty($arrayfields['p.email']['checked'])) { + print ''.dol_print_email($obj->email, $obj->rowid, $obj->socid, 'AC_EMAIL', 18, 0, 1).''; + if (empty($obj->email)) { + //print ''.$langs->trans("NoEmail").''; + } else { + print yn(($obj->unsubscribed > 0) ? 1 : 0); + } + print ''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).''; - if ($obj->socid) { - $objsoc = new Societe($db); - $objsoc->fetch($obj->socid); - print $objsoc->getNomUrl(1); - } else { - print ' '; - } - print ''.$contactstatic->LibPubPriv($obj->priv).''; + if ($obj->socid) { + $objsoc = new Societe($db); + $objsoc->fetch($obj->socid); + print $objsoc->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + } else { + print ' '; + } + print ''; - print $contactstatic->getLibProspLevel(); - print "'; + print dol_escape_htmltag($obj->alias); + print ''.$contactstatic->LibPubPriv($obj->priv).''; + print $contactstatic->getLibProspLevel(); + print "
'; - print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); - print '
-
'; - foreach ($contactstatic->cacheprospectstatus as $key => $val) { - $titlealt = 'default'; - if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { - $titlealt = $val['label']; + if (!empty($arrayfields['p.fk_stcommcontact']['checked'])) { + print '
'; + print '
'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
-
'; + foreach ($contactstatic->cacheprospectstatus as $key => $val) { + $titlealt = 'default'; + if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) { + $titlealt = $val['label']; + } + if ($obj->stcomm_id != $val['id']) { + print ''.img_action($titlealt, $val['code'], $val['picto']).''; + } } - if ($obj->stcomm_id != $val['id']) { - print ''.img_action($titlealt, $val['code'], $val['picto']).''; + print '
'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$contactstatic->getLibStatut(5).''; - print dol_escape_htmltag($obj->import_key); - print "'; - 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; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['p.datec']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print '
'; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$contactstatic->getLibStatut(5).''; + print dol_escape_htmltag($obj->import_key); + print "'; + 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 ''; + } + print '
'.$langs->trans("PriceUHTCurrency").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$objp->qty.''.$langs->trans($object->lines[$cursorline - 1]->getLabelOfUnit()).''; print $form->selectUnits($objp->fk_unit, "unit"); print '
'; } - /* - * Confirmation de la validation activation - */ - if ($action == 'active' && !$cancel && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { - $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - $comment = GETPOST('comment', 'alpha'); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne', 'int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("ActivateService"), $langs->trans("ConfirmActivateService", dol_print_date($dateactstart, "%A %d %B %Y")), "confirm_active", '', 0, 1); - print '
'; - } - - /* - * Confirmation de la validation fermeture - */ - if ($action == 'closeline' && !$cancel && $user->rights->contrat->activer && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { - $dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear')); - $comment = GETPOST('comment', 'alpha'); - - if (empty($dateactend)) { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DateEndReal")), null, 'errors'); - } else { - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&ligne=".GETPOST('ligne', 'int')."&date=".$dateactstart."&dateend=".$dateactend."&comment=".urlencode($comment), $langs->trans("CloseService"), $langs->trans("ConfirmCloseService", dol_print_date($dateactend, "%A %d %B %Y")), "confirm_closeline", '', 0, 1); - } - print '
'; - } - - // Area with status and activation info of line if ($object->statut > 0) { print ''; @@ -1929,8 +1916,12 @@ if ($action == 'create') { // Form to activate line if ($user->rights->contrat->activer && $action == 'activateline' && $object->lines[$cursorline - 1]->id == GETPOST('ligne', 'int')) { - print ''; + print ''; print ''; + print ''; + print ''; + print ''; + print ''; print '
'; @@ -1955,7 +1946,7 @@ if ($action == 'create') { print ''; print ''; print ''; print ''; if ($num) { - $companystatic = new Societe($db); - $i = 0; //$tot_ttc = 0; while ($i < $num) { @@ -276,22 +274,29 @@ if (isModEnabled('contrat') && $user->rights->contrat->lire) { $staticcontrat->ref = $obj->ref; $staticcontrat->id = $obj->rowid; - $companystatic->id = $obj->socid; - $companystatic->name = $obj->name; - $companystatic->client = 1; + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; print ''; print ''; print ''; //$tot_ttc+=$obj->total_ttc; $i++; } } else { - print ''; + print ''; } print "
'.$langs->trans("DateServiceActivate").''; - print $form->selectDate($dateactstart, '', $usehm, $usehm, '', "active", 1, 0); + print $form->selectDate($dateactstart, 'start', $usehm, $usehm, '', "active", 1, 0); print ''.$langs->trans("DateEndPlanned").''; print $form->selectDate($dateactend, "end", $usehm, $usehm, '', "active", 1, 0); @@ -1983,10 +1974,10 @@ if ($action == 'create') { * Disable a contract line */ print ''."\n"; - print ''; - + print ''; print ''; - print ''; + print ''; + print ''; print ''; @@ -2025,7 +2016,7 @@ if ($action == 'create') { print ''; print ''; - print ''; + print ''; print ''; print ''; - print ''; + print ''; print "\n"; } if ($status == 4 && !$bool) { @@ -224,7 +224,7 @@ foreach ($listofstatus as $status) { if (empty($conf->use_javascript_ajax)) { print ''; print ''; - print ''; + print ''; if ($status == 4 && !$bool) { $bool = true; } else { @@ -241,7 +241,7 @@ print "
'.$langs->trans("Comment").''.$langs->trans("Comment").''; print '   '; print ''; @@ -2046,11 +2037,12 @@ if ($action == 'create') { $dateSelector = 1; print "\n"; - print ' + print ' + '; print '
'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 4352364452b..ad2cbcea84b 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -225,24 +225,24 @@ class Contrat extends CommonObject */ public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>15), + 'ref' =>array('type'=>'varchar(50)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'showoncombobox'=>1, 'position'=>15, 'searchall'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>20), - 'ref_supplier' =>array('type'=>'varchar(50)', 'label'=>'Ref supplier', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'ref_customer' =>array('type'=>'varchar(50)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>25, 'searchall'=>1), + 'ref_supplier' =>array('type'=>'varchar(50)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>26, 'searchall'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>30, 'index'=>1), '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), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>70), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>70), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'visible'=>-1, 'position'=>75), 'fk_commercial_signature' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative Signature', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'fk_commercial_suivi' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'SaleRepresentative follower', 'enabled'=>1, 'visible'=>-1, 'position'=>85), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>90), - 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105), - 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110), + 'note_public' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>105, 'searchall'=>1), + 'note_private' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>110, 'searchall'=>1), 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>115), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>120), 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125), - '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, 'notnull'=>1, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Validated', 2=>'Closed')) @@ -320,15 +320,15 @@ class Contrat extends CommonObject * * @param User $user Objet User who activate contract * @param int $line_id Id of line to activate - * @param int $date Opening date + * @param int $date_start Opening date * @param int|string $date_end Expected end date * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - public function active_line($user, $line_id, $date, $date_end = '', $comment = '') + public function active_line($user, $line_id, $date_start, $date_end = '', $comment = '') { // phpcs:enable - $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); + $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date_start, $date_end, $comment); if ($result < 0) { $this->error = $this->lines[$this->lines_id_index_mapper[$line_id]]->error; $this->errors = $this->lines[$this->lines_id_index_mapper[$line_id]]->errors; @@ -1368,8 +1368,8 @@ class Contrat extends CommonObject $sql .= " fk_commercial_suivi=".(isset($this->fk_commercial_suivi) ? $this->fk_commercial_suivi : "null").","; $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; - //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); + //$sql.= " extraparams=".(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -2249,15 +2249,15 @@ class Contrat extends CommonObject $warning_delay = $conf->contrat->services->inactifs->warning_delay; $label = $langs->trans("BoardNotActivatedServices"); $labelShort = $langs->trans("BoardNotActivatedServicesShort"); - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc'; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=0&sortfield=cd.date_fin_validite&sortorder=asc'; } elseif ($mode == 'expired') { $warning_delay = $conf->contrat->services->expires->warning_delay; - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc'; $label = $langs->trans("BoardExpiredServices"); $labelShort = $langs->trans("BoardExpiredServicesShort"); } else { $warning_delay = $conf->contrat->services->expires->warning_delay; - $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc'; + $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&search_status=4&sortfield=cd.date_fin_validite&sortorder=asc'; //$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year']; //if ($warning_delay >= 0) $url.='&filter=expired'; $label = $langs->trans("BoardRunningServices"); @@ -2474,18 +2474,18 @@ class Contrat extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'contrat' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -2602,6 +2602,8 @@ class Contrat extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $clonedObj, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -2789,6 +2791,39 @@ class Contrat extends CommonObject return ($error ? 1: 0); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'societe')) { + $return .= '
'.$this->societe.''; + } + if (property_exists($this, 'date_contrat')) { + $return .= '
'.$langs->trans("DateContract").' : '.dol_print_date($this->date_contrat).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -2944,7 +2979,7 @@ class ContratLigne extends CommonObjectLine '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'=>30, 'index'=>1), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'qty' =>array('type'=>'integer', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35, 'isameasure'=>1), + 'qty' =>array('type'=>'integer', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>35, 'isameasure'=>1), 'total_ht' =>array('type'=>'integer', 'label'=>'AmountHT', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>36, 'isameasure'=>1), 'total_tva' =>array('type'=>'integer', 'label'=>'AmountVAT', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>37, 'isameasure'=>1), 'total_ttc' =>array('type'=>'integer', 'label'=>'AmountTTC', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>38, 'isameasure'=>1), @@ -3434,11 +3469,11 @@ class ContratLigne extends CommonObjectLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; - $sql .= " total_ht=".price2num($this->total_ht, 'MT').""; - $sql .= ",total_tva=".price2num($this->total_tva, 'MT').""; - $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT').""; - $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT').""; - $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT').""; + $sql .= " total_ht=".price2num($this->total_ht, 'MT'); + $sql .= ",total_tva=".price2num($this->total_tva, 'MT'); + $sql .= ",total_localtax1=".price2num($this->total_localtax1, 'MT'); + $sql .= ",total_localtax2=".price2num($this->total_localtax2, 'MT'); + $sql .= ",total_ttc=".price2num($this->total_ttc, 'MT'); $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::update_total", LOG_DEBUG); @@ -3552,7 +3587,7 @@ class ContratLigne extends CommonObjectLine * Activate a contract line * * @param User $user Objet User who activate contract - * @param int $date Date activation + * @param int $date Date real activation * @param int|string $date_end Date planned end. Use '-1' to keep it unchanged. * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK @@ -3567,13 +3602,13 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); $this->statut = ContratLigne::STATUS_OPEN; - $this->date_start = $date; + $this->date_start_real = $date; $this->date_end = $date_end; $this->fk_user_ouverture = $user->id; $this->date_end_real = null; $this->commentaire = $comment; - $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".$this->statut.","; + $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".((int) $this->statut).","; $sql .= " date_ouverture = ".(dol_strlen($this->date_start_real) != 0 ? "'".$this->db->idate($this->date_start_real)."'" : "null").","; if ($date_end >= 0) { $sql .= " date_fin_validite = ".(dol_strlen($this->date_end) != 0 ? "'".$this->db->idate($this->date_end)."'" : "null").","; @@ -3612,7 +3647,7 @@ class ContratLigne extends CommonObjectLine * Close a contract line * * @param User $user Objet User who close contract - * @param int $date_end_real Date end + * @param int $date_end_real Date end * @param string $comment A comment typed by user * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index e5557c28a5b..6ca7b9b86ef 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -165,7 +165,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 652738f10b5..3fb6ce25a6d 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -152,7 +152,7 @@ if ($object->id) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index d537934a299..c40453ec7af 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -194,7 +194,7 @@ foreach ($listofstatus as $status) { if (empty($conf->use_javascript_ajax)) { print '
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'
'.$staticcontratligne->LibStatut($status, 0, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).''.($nb[$status.$bool] ? $nb[$status.$bool] : 0).' '.$staticcontratligne->LibStatut($status, 3, ($bool ? 1 : 0)).'

"; if (isModEnabled('contrat') && $user->rights->contrat->lire) { $sql = "SELECT c.rowid, c.ref,"; - $sql .= " s.nom as name, s.rowid as socid"; + $sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."contrat as c, ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -266,8 +266,6 @@ if (isModEnabled('contrat') && $user->rights->contrat->lire) { print '
'.$langs->trans("DraftContracts").($num ? ''.$num.'' : '').'
'; print $staticcontrat->getNomUrl(1, ''); print ''; - print $companystatic->getNomUrl(1, '', 16); + print $staticcompany->getNomUrl(1, '', 16); print '
'.$langs->trans("NoContracts").'
'.$langs->trans("NoContracts").'

"; $db->free($resql); @@ -312,7 +317,8 @@ $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd. $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now)."')", 1, 0).') as nb_expired,'; $sql .= " sum(".$db->ifsql("cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay)."')", 1, 0).') as nb_late,'; $sql .= " sum(".$db->ifsql("cd.statut=5", 1, 0).') as nb_closed,'; -$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut, s.nom as name, s.rowid as socid"; +$sql .= " c.rowid as cid, c.ref, c.datec, c.tms, c.statut,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,"; @@ -328,7 +334,8 @@ if (empty($user->rights->societe->client->voir) && !$socid) { if ($socid) { $sql .= " AND s.rowid = ".((int) $socid); } -$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut, s.nom, s.rowid"; +$sql .= " GROUP BY c.rowid, c.ref, c.datec, c.tms, c.statut,"; +$sql .= " s.nom, s.name_alias, s.logo, s.rowid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur"; $sql .= " ORDER BY c.tms DESC"; $sql .= $db->plimit($max); @@ -356,6 +363,14 @@ if ($result) { $staticcompany->id = $obj->socid; $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; print '
'; @@ -389,9 +404,9 @@ if ($result) { print '
'; // Last modified services -$sql = "SELECT c.ref, c.fk_soc, "; +$sql = "SELECT c.ref, c.fk_soc as socid,"; $sql .= " cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat, cd.date_fin_validite,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -427,9 +442,23 @@ if ($resql) { print '
'; + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); $staticcontrat->id = $obj->fk_contrat; + + $staticcompany->id = $obj->socid; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + print $staticcontrat->getNomUrl(1, 16); + //if (1 == 1) print img_warning($langs->trans("Late")); print ''; @@ -449,8 +478,6 @@ if ($resql) { } print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; @@ -471,7 +498,7 @@ print '
'; // Not activated services $sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -507,19 +534,32 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); + $staticcompany->id = $obj->fk_soc; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); + $staticcontrat->id = $obj->fk_contrat; + + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; + $productstatic->entity = $obj->pentity; + print '
'; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); - $staticcontrat->id = $obj->fk_contrat; print $staticcontrat->getNomUrl(1, 16); print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; - $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); } else { print ''.img_object($langs->trans("ShowService"), "service"); @@ -531,8 +571,6 @@ if ($resql) { } print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; @@ -553,7 +591,7 @@ print '
'; // Expired services $sql = "SELECT c.ref, c.fk_soc, cd.rowid as cid, cd.statut, cd.label, cd.fk_product, cd.description as note, cd.fk_contrat,"; -$sql .= " s.nom as name,"; +$sql .= " s.nom as name, s.name_alias, s.logo, s.rowid as socid, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity"; $sql .= " FROM (".MAIN_DB_PREFIX."contrat as c"; $sql .= ", ".MAIN_DB_PREFIX."societe as s"; @@ -584,25 +622,38 @@ if ($resql) { print '
'; print ''; - print ''; + print ''; print "\n"; while ($i < $num) { $obj = $db->fetch_object($resql); + $staticcompany->id = $obj->fk_soc; + $staticcompany->name = $obj->name; + $staticcompany->name_alias = $obj->name_alias; + $staticcompany->photo = 1; + $staticcompany->code_client = $obj->code_client; + $staticcompany->code_fournisseur = $obj->code_fournisseur; + $staticcompany->code_compta = $obj->code_compta; + $staticcompany->code_compta_fournisseur = $obj->code_compta_fournisseur; + $staticcompany->client = $obj->client; + $staticcompany->fournisseur = $obj->fournisseur; + + $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); + $staticcontrat->id = $obj->fk_contrat; + + $productstatic->id = $obj->fk_product; + $productstatic->type = $obj->ptype; + $productstatic->ref = $obj->pref; + $productstatic->entity = $obj->pentity; + print ''; print ''; print ''; print ''; print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - // Ref - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; - - print ''; - } - - // Ref thirdparty - if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''; - } - if (!empty($arrayfields['c.ref_supplier']['checked'])) { - print ''; - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; } - print ''; - } - // Email - if (!empty($arrayfields['s.email']['checked'])) { - print ''; - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['sale_representative']['checked'])) { - // Sales representatives - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - print ''; - } - // Date - if (!empty($arrayfields['c.date_contrat']['checked'])) { - print ''; - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['c.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['c.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date lower end date - if (!empty($arrayfields['lower_planned_end_date']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['status']['checked'])) { - print ''; - print ''; - print ''; - print ''; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); + print ''; + + print ''; + } + + // Ref thirdparty + if (!empty($arrayfields['c.ref_customer']['checked'])) { + print ''; + } + if (!empty($arrayfields['c.ref_supplier']['checked'])) { + print ''; + } + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + } + // Email + if (!empty($arrayfields['s.email']['checked'])) { + print ''; + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['sale_representative']['checked'])) { + // Sales representatives + print ''; + } + // Date + if (!empty($arrayfields['c.date_contrat']['checked'])) { + print ''; + } + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['c.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['c.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date lower end date + if (!empty($arrayfields['lower_planned_end_date']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['status']['checked'])) { + print ''; + print ''; + print ''; + print ''; + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/contrat/note.php b/htdocs/contrat/note.php index f17cc11f748..576d3ce5fe2 100644 --- a/htdocs/contrat/note.php +++ b/htdocs/contrat/note.php @@ -121,7 +121,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php index cfc888e229a..47818081448 100644 --- a/htdocs/contrat/services_list.php +++ b/htdocs/contrat/services_list.php @@ -36,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; $langs->loadLangs(array('products', 'contracts', 'companies')); $optioncss = GETPOST('optioncss', 'aZ09'); +$mode = GETPOST("mode"); $massaction = GETPOST('massaction', 'alpha'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; @@ -55,9 +56,13 @@ if (!$sortorder) { $sortorder = "ASC"; } -$mode = GETPOST("mode"); -$filter = GETPOST("filter"); +$filter = GETPOST("filter", 'alpha'); $search_name = GETPOST("search_name", 'alpha'); +$search_subprice = GETPOST("search_subprice", 'alpha'); +$search_qty = GETPOST("search_qty", 'alpha'); +$search_total_ht = GETPOST("search_total_ht", 'alpha'); +$search_total_tva = GETPOST("search_total_tva", 'alpha'); +$search_total_ttc = GETPOST("search_total_ttc", 'alpha'); $search_contract = GETPOST("search_contract", 'alpha'); $search_service = GETPOST("search_service", 'alpha'); $search_status = GETPOST("search_status", 'alpha'); @@ -105,7 +110,6 @@ $result = restrictedArea($user, 'contrat', $contratid); if ($search_status != '') { $tmp = explode('&', $search_status); - $mode = $tmp[0]; if (empty($tmp[1])) { $filter = ''; } else { @@ -116,14 +120,6 @@ if ($search_status != '') { $filter = 'expired'; } } -} else { - $search_status = $mode; - if ($filter == 'expired') { - $search_status .= '&filter=expired'; - } - if ($filter == 'notexpired') { - $search_status .= '&filter=notexpired'; - } } $staticcontrat = new Contrat($db); @@ -136,13 +132,13 @@ $arrayfields = array( 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>90), 'cd.tva_tx'=>array('label'=>"VATRate", 'checked'=>-1, 'position'=>100), 'cd.subprice'=>array('label'=>"PriceUHT", 'checked'=>-1, 'position'=>105), - 'cd.qty'=>array('label'=>"Qty", 'checked'=>-1, 'position'=>108), - 'cd.total_ht'=>array('label'=>"TotalHT", 'checked'=>-1, 'position'=>109), + 'cd.qty'=>array('label'=>"Qty", 'checked'=>1, 'position'=>108), + 'cd.total_ht'=>array('label'=>"TotalHT", 'checked'=>-1, 'position'=>109, 'isameasure'=>1), 'cd.total_tva'=>array('label'=>"TotalVAT", 'checked'=>-1, 'position'=>110), - 'cd.date_ouverture_prevue'=>array('label'=>"DateStartPlannedShort", 'checked'=>(($mode == "" || $mode == -1) || $mode == "0"), 'position'=>150), - 'cd.date_ouverture'=>array('label'=>"DateStartRealShort", 'checked'=>(($mode == "" || $mode == -1) || $mode > 0), 'position'=>160), - 'cd.date_fin_validite'=>array('label'=>"DateEndPlannedShort", 'checked'=>(($mode == "" || $mode == -1) || $mode < 5), 'position'=>170), - 'cd.date_cloture'=>array('label'=>"DateEndRealShort", 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5), 'position'=>180), + 'cd.date_ouverture_prevue'=>array('label'=>"DateStartPlannedShort", 'checked'=>1, 'position'=>150), + 'cd.date_ouverture'=>array('label'=>"DateStartRealShort", 'checked'=>1, 'position'=>160), + 'cd.date_fin_validite'=>array('label'=>"DateEndPlannedShort", 'checked'=>1, 'position'=>170), + 'cd.date_cloture'=>array('label'=>"DateEndRealShort", 'checked'=>1, 'position'=>180), //'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'cd.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500), 'status'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000) @@ -180,6 +176,11 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers $search_product_category = 0; $search_name = ""; + $search_subprice = ""; + $search_qty = ""; + $search_total_ht = ""; + $search_total_tva = ""; + $search_total_ttc = ""; $search_contract = ""; $search_service = ""; $search_status = -1; @@ -199,7 +200,6 @@ if (empty($reshook)) { $opclotureday = ""; $opclotureyear = ""; $filter_opcloture = ""; - $mode = ''; $filter = ''; $toselect = array(); $search_array_options = array(); @@ -217,7 +217,7 @@ $form = new Form($db); $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,"; $sql .= " s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,"; -$sql .= " cd.rowid, cd.description, cd.statut,"; +$sql .= " cd.rowid, cd.description, cd.statut, cd.product_type as type,"; $sql .= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.tobuy, p.tosell, p.barcode, p.entity as pentity,"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " sc.fk_soc, sc.fk_user,"; @@ -256,7 +256,7 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; if ($search_product_category > 0) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product'; } -$sql .= " WHERE c.entity = ".$conf->entity; +$sql .= " WHERE c.entity IN (".getEntity($object->element).")"; $sql .= " AND c.rowid = cd.fk_contrat"; if ($search_product_category > 0) { $sql .= " AND cp.fk_categorie = ".((int) $search_product_category); @@ -265,13 +265,13 @@ $sql .= " AND c.fk_soc = s.rowid"; if (empty($user->rights->societe->client->voir) && !$socid) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } -if ($mode == "0") { +if ($search_status == "0") { $sql .= " AND cd.statut = 0"; } -if ($mode == "4") { +if ($search_status == "4") { $sql .= " AND cd.statut = 4"; } -if ($mode == "5") { +if ($search_status == "5") { $sql .= " AND cd.statut = 5"; } if ($filter == "expired") { @@ -280,14 +280,29 @@ if ($filter == "expired") { if ($filter == "notexpired") { $sql .= " AND cd.date_fin_validite >= '".$db->idate($now)."'"; } +if ($search_subprice) { + $sql .= natural_search("cd.subprice", $search_subprice, 1); +} +if ($search_qty) { + $sql .= natural_search("cd.qty", $search_qty, 1); +} +if ($search_total_ht) { + $sql .= natural_search("cd.total_ht", $search_total_ht, 1); +} +if ($search_total_tva) { + $sql .= natural_search("cd.total_tva", $search_total_tva, 1); +} +if ($search_total_ttc) { + $sql .= natural_search("cd.total_ttc", $search_total_ttc, 1); +} if ($search_name) { - $sql .= " AND s.nom LIKE '%".$db->escape($search_name)."%'"; + $sql .= natural_search("s.nom", $search_name); } if ($search_contract) { - $sql .= " AND c.ref LIKE '%".$db->escape($search_contract)."%' "; + $sql .= natural_search("c.ref", $search_contract); } if ($search_service) { - $sql .= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')"; + $sql .= natural_search(array("p.ref", "p.description", "cd.description"), $search_service); } if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid); @@ -392,17 +407,35 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.$limit; } +if ($mode) { + $param .= '&mode='.urlencode($mode); +} if ($search_contract) { $param .= '&search_contract='.urlencode($search_contract); } if ($search_name) { $param .= '&search_name='.urlencode($search_name); } +if ($search_subprice) { + $param .= '&search_subprice='.urlencode($search_subprice); +} +if ($search_qty) { + $param .= '&search_qty='.urlencode($search_qty); +} +if ($search_total_ht) { + $param .= '&search_total_ht='.urlencode($search_total_ht); +} +if ($search_total_tva) { + $param .= '&search_total_tva='.urlencode($search_total_tva); +} +if ($search_total_ttc) { + $param .= '&search_total_ttc='.urlencode($search_total_ttc); +} if ($search_service) { $param .= '&search_service='.urlencode($search_service); } -if ($mode) { - $param .= '&mode='.urlencode($mode); +if ($search_status) { + $param .= '&search_status='.urlencode($search_status); } if ($filter) { $param .= '&filter='.urlencode($filter); @@ -460,16 +493,16 @@ print ''; print ''; $title = $langs->trans("ListOfServices"); -if ($mode == "0") { +if ($search_status == "0") { $title = $langs->trans("ListOfInactiveServices"); // Must use == "0" } -if ($mode == "4" && $filter != "expired") { +if ($search_status == "4" && $filter != "expired") { $title = $langs->trans("ListOfRunningServices"); } -if ($mode == "4" && $filter == "expired") { +if ($search_status == "4" && $filter == "expired") { $title = $langs->trans("ListOfExpiredServices"); } -if ($mode == "5") { +if ($search_status == "5") { $title = $langs->trans("ListOfClosedServices"); } @@ -517,67 +550,13 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi print '
'; print '
'.$langs->trans("ListOfExpiredServices").' '.$num.'
'.$langs->trans("ListOfExpiredServices").' '.$num.'
'; - $staticcontrat->ref = ($obj->ref ? $obj->ref : $obj->fk_contrat); - $staticcontrat->id = $obj->fk_contrat; print $staticcontrat->getNomUrl(1, 16); print ''; if ($obj->fk_product > 0) { - $productstatic->id = $obj->fk_product; - $productstatic->type = $obj->ptype; - $productstatic->ref = $obj->pref; - $productstatic->entity = $obj->pentity; print $productstatic->getNomUrl(1, '', 20); } else { print ''.img_object($langs->trans("ShowService"), "service"); @@ -614,8 +665,6 @@ if ($resql) { } print ''; - $staticcompany->id = $obj->fk_soc; - $staticcompany->name = $obj->name; print $staticcompany->getNomUrl(1, '', 20); print ''; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 07cf120f4cc..38c37c1389e 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -51,6 +51,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'contractlist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); $search_email = GETPOST('search_email', 'alpha'); @@ -62,7 +63,7 @@ $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_contract = GETPOST('search_contract', 'alpha'); $search_ref_customer = GETPOST('search_ref_customer', 'alpha'); $search_ref_supplier = GETPOST('search_ref_supplier', 'alpha'); -$sall = (GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = (GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); $search_status = GETPOST('search_status', 'alpha'); $socid = GETPOST('socid', 'int'); $search_user = GETPOST('search_user', 'int'); @@ -132,16 +133,23 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" -$fieldstosearchall = array( - 'c.ref'=>'Ref', - 'c.ref_customer'=>'RefCustomer', - 'c.ref_supplier'=>'RefSupplier', - 's.nom'=>"ThirdParty", - 'c.note_public'=>'NotePublic', -); +$fieldstosearchall = array(); +foreach ($object->fields as $key => $val) { + if (!empty($val['searchall'])) { + $fieldstosearchall['c.'.$key] = $val['label']; + } +} +$fieldstosearchall["s.nom"] = "ThirdParty"; if (empty($user->socid)) { $fieldstosearchall["c.note_private"] = "NotePrivate"; } +$parameters = array('fieldstosearchall'=>$fieldstosearchall); +$reshook = $hookmanager->executeHooks('completeFieldsToSearchAll', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook > 0) { + $fieldstosearchall = $hookmanager->resArray['fieldstosearchall']; +} elseif ($reshook == 0) { + $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray['fieldstosearchall']); +} $arrayfields = array( 'c.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1, 'position'=>10), @@ -166,9 +174,12 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); +$permissiontoread = $user->rights->contrat->lire; +$permissiontodelete = $user->rights->contrat->supprimer; + /* - * Action + * Actions */ if (GETPOST('cancel', 'alpha')) { @@ -212,7 +223,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_date_endyear = ''; $search_date_start = ''; $search_date_end = ''; - $sall = ""; + $search_all = ""; $search_status = ""; $toselect = array(); $search_type_thirdparty = ''; @@ -223,8 +234,6 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (empty($reshook)) { $objectclass = 'Contrat'; $objectlabel = 'Contracts'; - $permissiontoread = $user->rights->contrat->lire; - $permissiontodelete = $user->rights->contrat->supprimer; $uploaddir = $conf->contrat->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -264,6 +273,9 @@ if (!empty($extrafields->attributes[$object->table_element]['label'])) { $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent)"; @@ -324,8 +336,8 @@ if ($search_country && $search_country != '-1') { if ($search_sale > 0) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale); } -if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); @@ -455,13 +467,18 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } } } else { - $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); - $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat/', '', $sqlforcount); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat /', '', $sqlforcount); $sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } } if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 @@ -484,7 +501,7 @@ if (!$resql) { $num = $db->num_rows($resql); // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) { +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/contrat/card.php?id='.$id); @@ -510,14 +527,17 @@ if ($socid > 0) { } $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -if ($sall != '') { - $param .= '&sall='.urlencode($sall); +if ($search_all != '') { + $param .= '&search_all='.urlencode($search_all); } if ($search_contract != '') { $param .= '&search_contract='.urlencode($search_contract); @@ -594,10 +614,10 @@ $arrayofmassactions = array( 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($user->rights->contrat->supprimer) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (in_array($massaction, array('presend', 'predelete'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -606,9 +626,12 @@ $url = DOL_URL_ROOT.'/contrat/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.((int) $socid); } -$newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); -print ''; +print ''; if ($optioncss != '') { print ''; } @@ -617,9 +640,12 @@ print ''; print ''; print ''; +print ''; print ''; +print ''; +print ''; -print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($langs->trans("Contracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'contract', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "SendContractRef"; $modelmail = "contract"; @@ -627,11 +653,14 @@ $objecttmp = new Contrat($db); $trackid = 'con'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; -if ($sall) { +if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -909,212 +938,227 @@ while ($i < min($num, $limit)) { $socstatic->country_code = $cacheCountryIDCode[$obj->country_id]['code']; $socstatic->country = $cacheCountryIDCode[$obj->country_id]['label']; } - - - print '
'; - 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 ''; - } - print ''; - print $contracttmp->getNomUrl(1); - if ($obj->nb_late) { - print img_warning($langs->trans("Late")); - } - if (!empty($obj->note_private) || !empty($obj->note_public)) { - print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; - print ''; + //mode kanban + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->contrat->multidir_output[$obj->entity].'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir); - print '
'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''; - if ($obj->socid > 0) { - // TODO Use a cache for this string - print $socstatic->getNomUrl(1, ''); + // Output Kanban + $contracttmp->societe = $socstatic->getNomUrl(); + $contracttmp->date_contrat = $obj->date_contrat; + print $contracttmp->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - print dol_escape_htmltag($socstatic->country); - print ''; - if (count($typenArray) == 0) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - if ($obj->socid > 0) { - $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); - if ($listsalesrepresentatives < 0) { - dol_print_error($db); - } - $nbofsalesrepresentative = count($listsalesrepresentatives); - if ($nbofsalesrepresentative > 6) { - // We print only number - print $nbofsalesrepresentative; - } elseif ($nbofsalesrepresentative > 0) { - $userstatic = new User($db); - $j = 0; - foreach ($listsalesrepresentatives as $val) { - $userstatic->id = $val['id']; - $userstatic->lastname = $val['lastname']; - $userstatic->firstname = $val['firstname']; - $userstatic->email = $val['email']; - $userstatic->statut = $val['statut']; - $userstatic->entity = $val['entity']; - $userstatic->photo = $val['photo']; - $userstatic->login = $val['login']; - $userstatic->phone = $val['phone']; - $userstatic->job = $val['job']; - $userstatic->gender = $val['gender']; - - //print '
': - print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); - $j++; - if ($j < $nbofsalesrepresentative) { - print ' '; - } - //print '
'; + } else { + print '
'; + 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 ''; } - //else print $langs->trans("NoSalesRepresentativeAffected"); - } else { - print ' '; + print ''.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); - print ''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').''; - 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; + // Ref + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + print $contracttmp->getNomUrl(1); + if ($obj->nb_late) { + print img_warning($langs->trans("Late")); + } + if (!empty($obj->note_private) || !empty($obj->note_public)) { + print ' '; + print ''.img_picto($langs->trans("ViewPrivateNote"), 'note').''; + print ''; } - print ''; - } - print '
'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''.dol_escape_htmltag($obj->ref_supplier).''; + if ($obj->socid > 0) { + // TODO Use a cache for this string + print $socstatic->getNomUrl(1, ''); + } + print ''.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + print dol_escape_htmltag($socstatic->country); + print ''; + if (count($typenArray) == 0) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + if ($obj->socid > 0) { + $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user); + if ($listsalesrepresentatives < 0) { + dol_print_error($db); + } + $nbofsalesrepresentative = count($listsalesrepresentatives); + if ($nbofsalesrepresentative > 6) { + // We print only number + print $nbofsalesrepresentative; + } elseif ($nbofsalesrepresentative > 0) { + $userstatic = new User($db); + $j = 0; + foreach ($listsalesrepresentatives as $val) { + $userstatic->id = $val['id']; + $userstatic->lastname = $val['lastname']; + $userstatic->firstname = $val['firstname']; + $userstatic->email = $val['email']; + $userstatic->statut = $val['statut']; + $userstatic->entity = $val['entity']; + $userstatic->photo = $val['photo']; + $userstatic->login = $val['login']; + $userstatic->phone = $val['phone']; + $userstatic->job = $val['job']; + $userstatic->gender = $val['gender']; + + //print '
': + print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1, '', 0, 0, 12) : $userstatic->getNomUrl(-2); + $j++; + if ($j < $nbofsalesrepresentative) { + print ' '; + } + //print '
'; + } + } + //else print $langs->trans("NoSalesRepresentativeAffected"); + } else { + print ' '; + } + print '
'.dol_print_date($db->jdate($obj->date_contrat), 'day', 'tzserver').''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->lower_planned_end_date), 'day', 'tzuser'); + print ''.($obj->nb_initial > 0 ? $obj->nb_initial : '').''.($obj->nb_running > 0 ? $obj->nb_running : '').''.($obj->nb_expired > 0 ? $obj->nb_expired : '').''.($obj->nb_closed > 0 ? $obj->nb_closed : '').''; + 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 ''; + } + print '
'."\n"; -print ''; -if (!empty($arrayfields['c.ref']['checked'])) { - print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['p.description']['checked'])) { - print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder); -} -if (!empty($arrayfields['cd.tva_tx']['checked'])) { - print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['cd.subprice']['checked'])) { - print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['cd.qty']['checked'])) { - print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['cd.total_ht']['checked'])) { - print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['cd.total_tva']['checked'])) { - print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -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['cd.date_ouverture_prevue']['checked'])) { - print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['cd.date_ouverture']['checked'])) { - print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { - print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center '); -} -if (!empty($arrayfields['cd.date_cloture']['checked'])) { - print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center '); -} -// 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); // Note that $action and $object may have been modified by hook -print $hookmanager->resPrint; -if (!empty($arrayfields['cd.datec']['checked'])) { - print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['cd.tms']['checked'])) { - print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); -} -if (!empty($arrayfields['status']['checked'])) { - print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); -} -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); -print "\n"; print ''; if (!empty($arrayfields['c.ref']['checked'])) { print ''; } // Service label @@ -592,19 +571,23 @@ if (!empty($arrayfields['cd.tva_tx']['checked'])) { print ''; } if (!empty($arrayfields['cd.subprice']['checked'])) { - print ''; } if (!empty($arrayfields['cd.qty']['checked'])) { - print ''; } if (!empty($arrayfields['cd.total_ht']['checked'])) { - print ''; } if (!empty($arrayfields['cd.total_tva']['checked'])) { - print ''; } // Third party @@ -614,7 +597,6 @@ if (!empty($arrayfields['s.nom']['checked'])) { print ''; } - if (!empty($arrayfields['cd.date_ouverture_prevue']['checked'])) { print ''; } // Action column @@ -688,11 +670,67 @@ print $searchpicto; print ''; print "\n"; +print ''; +if (!empty($arrayfields['c.ref']['checked'])) { + print_liste_field_titre($arrayfields['c.ref']['label'], $_SERVER["PHP_SELF"], "c.ref", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['p.description']['checked'])) { + print_liste_field_titre($arrayfields['p.description']['label'], $_SERVER["PHP_SELF"], "p.description", "", $param, "", $sortfield, $sortorder); +} +if (!empty($arrayfields['cd.tva_tx']['checked'])) { + print_liste_field_titre($arrayfields['cd.tva_tx']['label'], $_SERVER["PHP_SELF"], "cd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.subprice']['checked'])) { + print_liste_field_titre($arrayfields['cd.subprice']['label'], $_SERVER["PHP_SELF"], "cd.subprice", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.qty']['checked'])) { + print_liste_field_titre($arrayfields['cd.qty']['label'], $_SERVER["PHP_SELF"], "cd.qty", "", $param, '', $sortfield, $sortorder, 'right nowrap '); +} +if (!empty($arrayfields['cd.total_ht']['checked'])) { + print_liste_field_titre($arrayfields['cd.total_ht']['label'], $_SERVER["PHP_SELF"], "cd.total_ht", "", $param, '', $sortfield, $sortorder, 'right nowrap '); +} +if (!empty($arrayfields['cd.total_tva']['checked'])) { + print_liste_field_titre($arrayfields['cd.total_tva']['label'], $_SERVER["PHP_SELF"], "cd.total_tva", "", $param, '', $sortfield, $sortorder, 'right nowrap '); +} +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['cd.date_ouverture_prevue']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture_prevue", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_ouverture']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_ouverture']['label'], $_SERVER["PHP_SELF"], "cd.date_ouverture", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_fin_validite']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'], $_SERVER["PHP_SELF"], "cd.date_fin_validite", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (!empty($arrayfields['cd.date_cloture']['checked'])) { + print_liste_field_titre($arrayfields['cd.date_cloture']['label'], $_SERVER["PHP_SELF"], "cd.date_cloture", "", $param, '', $sortfield, $sortorder, 'center '); +} +// 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); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; +if (!empty($arrayfields['cd.datec']['checked'])) { + print_liste_field_titre($arrayfields['cd.datec']['label'], $_SERVER["PHP_SELF"], "cd.datec", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['cd.tms']['checked'])) { + print_liste_field_titre($arrayfields['cd.tms']['label'], $_SERVER["PHP_SELF"], "cd.tms", "", $param, '', $sortfield, $sortorder, 'center nowrap '); +} +if (!empty($arrayfields['status']['checked'])) { + print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "cd.statut,c.statut", "", $param, '', $sortfield, $sortorder, 'right '); +} +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); +print "\n"; + + $contractstatic = new Contrat($db); $productstatic = new Product($db); $i = 0; -$totalarray = array(); +$totalarray = array('nbfield'=>0, 'cd.qty'=>0, 'cd.total_ht'=>0, 'cd.total_tva'=>0); while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -774,6 +812,13 @@ while ($i < min($num, $limit)) { if (!$i) { $totalarray['nbfield']++; } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cd.qty'; + } + if (!$i) { + $totalarray['val']['cd.qty'] = $obj->qty; + } + $totalarray['val']['cd.qty'] += $obj->qty; } if (!empty($arrayfields['cd.total_ht']['checked'])) { print ''; +} + $db->free($resql); $parameters = array('sql' => $sql); diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 49f3b2fa302..18ab3ac5eda 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -285,7 +285,7 @@ if ($action == 'update' && !empty($permissiontoadd)) { $action = 'view'; $urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist; $urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation - if ($urltogo && !$noback) { + if ($urltogo && empty($noback)) { header("Location: " . $urltogo); exit; } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 74852da84f7..55d7ec6fdcf 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -93,11 +93,11 @@ if (!$error && $massaction == 'confirm_presend') { $objecttmp = new $objectclass($db); if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); - } - if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + } elseif ($objecttmp->element == 'contact') { + $thirdparty = new Contact($db); + } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Adherent($db); - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'holiday') { $thirdparty = new User($db); } @@ -110,14 +110,13 @@ if (!$error && $massaction == 'confirm_presend') { $thirdpartyid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); if ($objecttmp->element == 'societe') { $thirdpartyid = $objecttmp->id; - } - if ($objecttmp->element == 'expensereport') { + } elseif ($objecttmp->element == 'contact') { + $thirdpartyid = $objecttmp->id; + } elseif ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; - } - if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdpartyid = $objecttmp->fk_member; - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'holiday') { $thirdpartyid = $objecttmp->fk_user; } if (empty($thirdpartyid)) { @@ -268,6 +267,10 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; + } elseif ($objectobj->element == 'contact') { + $fcontact = new Contact($db); + $fcontact->fetch($objectobj->id); + $sendto = $fcontact->email; } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objectobj->fk_member); @@ -510,31 +513,28 @@ if (!$error && $massaction == 'confirm_presend') { $trackid = 'thi'.$thirdparty->id; if ($objecttmp->element == 'expensereport') { $trackid = 'use'.$thirdparty->id; - } - if ($objecttmp->element == 'holiday') { + } elseif ($objecttmp->element == 'contact') { + $trackid = 'ctc'.$thirdparty->id; + } elseif ($objecttmp->element == 'holiday') { $trackid = 'use'.$thirdparty->id; } } else { $trackid = strtolower(get_class($objecttmp)); - if (get_class($objecttmp) == 'Contrat') { + if (get_class($objecttmp) == 'Contact') { + $trackid = 'ctc'; + } elseif (get_class($objecttmp) == 'Contrat') { $trackid = 'con'; - } - if (get_class($objecttmp) == 'Propal') { + } elseif (get_class($objecttmp) == 'Propal') { $trackid = 'pro'; - } - if (get_class($objecttmp) == 'Commande') { + } elseif (get_class($objecttmp) == 'Commande') { $trackid = 'ord'; - } - if (get_class($objecttmp) == 'Facture') { + } elseif (get_class($objecttmp) == 'Facture') { $trackid = 'inv'; - } - if (get_class($objecttmp) == 'Supplier_Proposal') { + } elseif (get_class($objecttmp) == 'Supplier_Proposal') { $trackid = 'spr'; - } - if (get_class($objecttmp) == 'CommandeFournisseur') { + } elseif (get_class($objecttmp) == 'CommandeFournisseur') { $trackid = 'sor'; - } - if (get_class($objecttmp) == 'FactureFournisseur') { + } elseif (get_class($objecttmp) == 'FactureFournisseur') { $trackid = 'sin'; } @@ -753,7 +753,7 @@ if (!$error && $massaction == "builddoc" && $permissiontoread && !GETPOST('butto $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'\.pdf$'; } foreach ($listofobjectref as $tmppdf) { - $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9-_]+\.pdf$'; // To include PDF generated from ODX files + $arrayofinclusion[] = '^'.preg_quote(dol_sanitizeFileName($tmppdf), '/').'_[a-zA-Z0-9\-\_\']+\.pdf$'; // To include PDF generated from ODX files } $listoffiles = dol_dir_list($uploaddir, 'all', 1, implode('|', $arrayofinclusion), '\.meta$|\.png', 'date', SORT_DESC, 0, true); @@ -1708,6 +1708,66 @@ if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday } } +//if (!$error && $massaction == 'clonetasks' && $user->rights->projet->creer) { +if (!$error && ($massaction == 'clonetasks' || ($action == 'clonetasks' && $confirm == 'yes'))) { + $num = 0; + + dol_include_once('/projet/class/task.class.php'); + + $origin_task = new Task($db); + $clone_task = new Task($db); + + foreach (GETPOST('selected') as $task) { + $origin_task->fetch($task, $ref = '', $loadparentdata = 0); + + $defaultref = ''; + $obj = empty($conf->global->PROJECT_TASK_ADDON) ? 'mod_task_simple' : $conf->global->PROJECT_TASK_ADDON; + if (!empty($conf->global->PROJECT_TASK_ADDON) && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . ".php")) { + require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . $conf->global->PROJECT_TASK_ADDON . '.php'; + $modTask = new $obj; + $defaultref = $modTask->getNextValue(0, $clone_task); + } + + if (!$error) { + $clone_task->fk_project = GETPOST('projectid', 'int'); + $clone_task->ref = $defaultref; + $clone_task->label = $origin_task->label; + $clone_task->description = $origin_task->description; + $clone_task->planned_workload = $origin_task->planned_workload; + $clone_task->fk_task_parent = $origin_task->fk_task_parent; + $clone_task->date_c = dol_now(); + $clone_task->date_start = $origin_task->date_start; + $clone_task->date_end = $origin_task->date_end; + $clone_task->progress = $origin_task->progress; + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $clone_task); + + $taskid = $clone_task->create($user); + + if ($taskid > 0) { + $result = $clone_task->add_contact(GETPOST("userid", 'int'), 'TASKEXECUTIVE', 'internal'); + $num++; + } else { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("projects"); + setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); + $duplicate_code_error = true; + } else { + setEventMessages($clone_task->error, $clone_task->errors, 'errors'); + } + $action = 'list'; + $error++; + } + } + } + + if (!$error) { + setEventMessage($langs->trans('NumberOfTasksCloned', $num)); + header("Refresh: 1;URL=".DOL_URL_ROOT.'/projet/tasks.php?id=' . GETPOST('projectid', 'int')); + } +} + $parameters['toselect'] = (empty($toselect) ? array() : $toselect); $parameters['uploaddir'] = $uploaddir; $parameters['massaction'] = $massaction; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index fbf526fd58e..deca9588444 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -127,6 +127,7 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $keyforuploaddir = GETPOST('keyforuploaddir', 'aZ09'); $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim(getDolGlobalString($keyforuploaddir)))); + foreach ($listofdir as $key => $tmpdir) { $tmpdir = trim($tmpdir); $tmpdir = preg_replace('/DOL_DATA_ROOT\/*/', '', $tmpdir); // Clean string if we found a hardcoded DOL_DATA_ROOT @@ -144,6 +145,8 @@ if ($action == 'setModuleOptions' && !empty($user->admin)) { break; // So we take the first directory found into setup $conf->global->$keyforuploaddir } } + + if ($upload_dir) { $result = dol_add_file_process($upload_dir, 1, 1, 'uploadfile', ''); if ($result <= 0) { diff --git a/htdocs/core/ajax/security.php b/htdocs/core/ajax/security.php index e5dc91c05d1..b01c952662e 100644 --- a/htdocs/core/ajax/security.php +++ b/htdocs/core/ajax/security.php @@ -36,9 +36,10 @@ if (!defined('NOREQUIREAJAX')) { if (!defined('NOREQUIRESOC')) { define('NOREQUIRESOC', '1'); } -if (!defined('NOREQUIRETRAN')) { +// We need langs because the getRandomPassword may use user language to define some rules of pass generation +/*if (!defined('NOREQUIRETRAN')) { define('NOREQUIRETRAN', '1'); -} +}*/ // Load Dolibarr environment require '../../main.inc.php'; @@ -55,9 +56,9 @@ top_httphead(); //print ''."\n"; -// Registering the location of boxes +// Return a new generated password if ($action) { - if ($action == 'getrandompassword' && ($user->admin || $user->rights->api->apikey->generate)) { + if ($action == 'getrandompassword') { require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; $generic = GETPOST('generic') ? true : false; echo getRandomPassword($generic); diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index fb0f93086d2..ac0df03184a 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -220,7 +220,9 @@ class box_actions extends ModeleBoxes if (!empty($conf->global->SHOW_DIALOG_HOMEPAGE)) { $actioncejour = false; $contents = $this->info_box_contents; - $nblines = count($contents); + if (is_countable($contents) && count($contents) > 0) { + $nblines = count($contents); + } if ($contents[0][0]['text'] != $langs->trans("NoActionsToDo")) { $out .= '
trans("ActionsToDo").'">'; $out .= '
'; print ''; print ''; - print ''; + print ''; print ''; + print ''; + print ''; print ''; + print ''; + print ''; print ''; + print ''; + print ''; print ''; + print ''; + print ''; print ''; $arrayofoperators = array('<'=>'<', '>'=>'>'); @@ -670,7 +652,7 @@ if (!empty($arrayfields['cd.tms']['checked'])) { } if (!empty($arrayfields['status']['checked'])) { // Status - print ''; + print ''; $arrayofstatus = array( '0'=>$langs->trans("ServiceStatusInitial"), '4'=>$langs->trans("ServiceStatusRunning"), @@ -678,7 +660,7 @@ if (!empty($arrayfields['status']['checked'])) { '4&filter=expired'=>$langs->trans("ServiceStatusLate"), '5'=>$langs->trans("ServiceStatusClosed") ); - print $form->selectarray('search_status', $arrayofstatus, (strstr($search_status, ',') ?-1 : $search_status), 1, 0, 0, '', 0, 0, 0, '', 'minwidth100imp maxwidth150'); + print $form->selectarray('search_status', $arrayofstatus, (strstr($search_status, ',') ?-1 : $search_status), 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; @@ -912,6 +957,17 @@ while ($i < min($num, $limit)) { // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; +// If no record found +if ($num == 0) { + $colspan = 1; + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } + print '
'.$langs->trans("NoRecordFound").'
'; diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 4829b32a72a..ea45580e163 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -155,7 +155,7 @@ class box_activity extends ModeleBoxes while ($j < count($data)) { $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal' ); @@ -169,7 +169,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Proposals")." ".$propalstatic->LibStatut($data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".$data[$j]->fk_statut, + 'url' => DOL_URL_ROOT."/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&search_status=".((int) $data[$j]->fk_statut), ); $totalnb += $data[$j]->nb; @@ -185,6 +185,13 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedProposals"), + ); + $line++; + } } } @@ -273,6 +280,13 @@ class box_activity extends ModeleBoxes $line++; $j++; } + if (count($data) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center"', + 'text'=>$langs->trans("NoRecordedOrders"), + ); + $line++; + } } } @@ -329,11 +343,11 @@ class box_activity extends ModeleBoxes if (!empty($data)) { $j = 0; while ($j < count($data)) { - $billurl = "search_status=2&paye=1"; + $billurl = "search_status=2&paye=1"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -346,7 +360,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="right"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", ); $this->info_box_contents[$line][3] = array( @@ -369,6 +383,7 @@ class box_activity extends ModeleBoxes 'td' => 'class="center"', 'text'=>$langs->trans("NoRecordedInvoices"), ); + $line++; } } @@ -412,11 +427,11 @@ class box_activity extends ModeleBoxes $j = 0; while ($j < count($data)) { - $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; + $billurl = "search_status=".$data[$j]->fk_statut."&paye=0"; $this->info_box_contents[$line][0] = array( 'td' => 'class="left" width="16"', 'tooltip' => $langs->trans('Bills').' '.$facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), - 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", + 'url' => DOL_URL_ROOT."/compta/facture/list.php?".$billurl."&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill', ); @@ -446,8 +461,9 @@ class box_activity extends ModeleBoxes if (count($data) == 0) { $this->info_box_contents[$line][0] = array( 'td' => 'class="center"', - 'text'=>$langs->trans("NoRecordedInvoices"), + 'text'=>$langs->trans("NoRecordedUnpaidInvoices"), ); + $line++; } } } diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index fc8dc4c6745..64a1f16e624 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2015-2019 Frederic France + * Copyright (C) 2015-2023 Frederic France * * 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,7 +115,7 @@ class box_birthdays_members extends ModeleBoxes $this->info_box_contents[$line][] = array( 'td' => 'class="center nowraponall"', - 'text' => dol_print_date($dateb, "day", 'gmt').' - '.$age.' '.$langs->trans('DurationYears') + 'text' => dol_print_date($dateb, "day", 'tzserver').' - '.$age.' '.$langs->trans('DurationYears') ); /*$this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 9a2e94b8a1d..6152b167863 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/boxes/box_dolibarr_state_board.php - * \ingroup + * \ingroup core * \brief Module Dolibarr state base */ diff --git a/htdocs/core/boxes/box_graph_invoices_peryear.php b/htdocs/core/boxes/box_graph_invoices_peryear.php index 5a9b84829f2..9ea2fe5a130 100644 --- a/htdocs/core/boxes/box_graph_invoices_peryear.php +++ b/htdocs/core/boxes/box_graph_invoices_peryear.php @@ -142,7 +142,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $px2->SetData($data2); unset($data2); $i = $startyear; - $legend = array(); + /*$legend = array(); while ($i <= $endyear) { if ($startmonth != 1) { $legend[] = sprintf("%d/%d", $i - 2001, $i - 2000); @@ -150,7 +150,7 @@ class box_graph_invoices_peryear extends ModeleBoxes $legend[] = $i; } $i++; - } + }*/ $px2->SetLegend([$langs->trans("AmountOfBillsHT")]); $px2->SetMaxValue($px2->GetCeilMaxValue()); $px2->SetWidth($WIDTH); diff --git a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php index b75d0752334..5a6dbbedd37 100644 --- a/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php +++ b/htdocs/core/boxes/box_graph_nb_ticket_last_x_days.php @@ -120,7 +120,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes while ($i < $num) { $objp = $this->db->fetch_object($resql); while ($minimumdatecformated < $objp->datec) { - $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); + $dataseries[] = array('label' => dol_print_date($minimumdatec, 'day'), 'data' => 0); $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); } @@ -130,7 +130,7 @@ class box_graph_nb_ticket_last_x_days extends ModeleBoxes $i++; } while (count($dataseries) < $days) { - $dataseries[] = array('label' => dol_print_date($minimumdatecformated, 'day'), 'data' => 0); + $dataseries[] = array('label' => dol_print_date($minimumdatec, 'day'), 'data' => 0); $minimumdatec = dol_time_plus_duree($minimumdatec, $intervaltoadd, 'd'); $minimumdatecformated = dol_print_date($minimumdatec, 'dayrfc'); $i++; diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php new file mode 100644 index 00000000000..196cec30738 --- /dev/null +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -0,0 +1,278 @@ + + * Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015-2020 Frederic France + * Copyright (C) 2021-2022 Waël Almoman + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_members_by_tags.php + * \ingroup adherent + * \brief Module to show box of members + */ + +include_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last modofied members + */ +class box_members_by_tags extends ModeleBoxes +{ + public $boxcode = "box_members_by_tags"; + public $boximg = "object_user"; + public $boxlabel = "BoxTitleMembersByTags"; + public $depends = array("adherent", "categorie"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + // disable module for such cases + $listofmodulesforexternal = explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (!in_array('adherent', $listofmodulesforexternal) && !empty($user->socid)) { + $this->enabled = 0; // disabled for external users + } + + $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + } + + /** + * Load data into info_box_contents array to show array later. + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->load("boxes"); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT . '/adherents/class/adherent.class.php'; + $staticmember = new Adherent($this->db); + + $year = date('Y'); + $numberyears = empty(getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH")) ? 2 : getDolGlobalInt("MAIN_NB_OF_YEAR_IN_WIDGET_GRAPH"); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMembersByTags").' ('.$year-$numberyears.' - '.$year.')'); + + if ($user->rights->adherent->lire) { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php'; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $stats = new AdherentStats($this->db, $user->socid, $user->id); + + // Show array + $sumMembers= $stats->countMembersByTagAndStatus($numberyears); + if ($sumMembers) { + $line = 0; + $this->info_box_contents[$line][] = array( + 'td' => 'class=""', + 'text' => '', + ); + // Members Status To Valid + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Waiting for subscription + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, + ); + // Up to date + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus, + ); + // Expired + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Excluded + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Resiliated + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Total row + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="10%" title="'.dol_escape_htmltag($langs->trans("Total")).'"', + 'text' => $langs->trans("Total") + ); + $line++; + foreach ($sumMembers as $key => $data) { + $adhtype = new AdherentType($this->db); + $adhtype->id = $key; + + if ($key=='total') { + break; + } + $adhtype->label = $data['label']; + $AdherentType[$key] = $adhtype; + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $adhtype->getNomUrl(1, dol_size(32)), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_draft']) && $data['members_draft'] > 0 ? $data['members_draft'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_pending']) && $data['members_pending'] > 0 ? $data['members_pending'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_uptodate']) && $data['members_uptodate'] > 0 ? $data['members_uptodate'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_expired']) && $data['members_expired'] > 0 ? $data['members_expired'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_excluded']) && $data['members_excluded'] > 0 ? $data['members_excluded'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, $now, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['members_resiliated']) && $data['members_resiliated'] > 0 ? $data['members_resiliated'] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1, + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($data['total_adhtype']) && $data['total_adhtype'] > 0 ? $data['total_adhtype'] : ''), + 'asis' => 1, + ); + $line++; + } + + if (count($sumMembers) == 0) { + $this->info_box_contents[$line][0] = array( + 'td' => 'class="center" colspan="6"', + 'text' => $langs->trans("NoRecordedMembersByType") + ); + } else { + $this->info_box_contents[$line][] = array( + 'tr' => 'class="liste_total"', + 'td' => 'class="liste_total"', + 'text' => $langs->trans("Total") + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_draft'].' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_pending'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_uptodate'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 0, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_expired'].' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_excluded'].' '.$staticmember->LibStatut(Adherent::STATUS_EXCLUDED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['members_resiliated'].' '.$staticmember->LibStatut(Adherent::STATUS_RESILIATED, 1, 0, 3), + 'asis' => 1 + ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $sumMembers['total']['all'], + 'asis' => 1 + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength' => 500, + 'text' => ($this->db->error() . ' sql=' . $sql) + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/boxes/box_members_by_type.php b/htdocs/core/boxes/box_members_by_type.php index 2e25da59564..b3f3504cee8 100644 --- a/htdocs/core/boxes/box_members_by_type.php +++ b/htdocs/core/boxes/box_members_by_type.php @@ -92,13 +92,15 @@ class box_members_by_type extends ModeleBoxes if ($user->rights->adherent->lire) { $MembersToValidate = array(); + $MembersPending = array(); $MembersValidated = array(); $MembersUpToDate = array(); $MembersExcluded = array(); $MembersResiliated = array(); $SumToValidate = 0; - $SumValidated = 0; + $SumPending = 0; + $SumExpired = 0; $SumUpToDate = 0; $SumResiliated = 0; $SumExcluded = 0; @@ -169,43 +171,74 @@ class box_members_by_type extends ModeleBoxes } $this->db->free($result); } + // Members pendding (Waiting for first subscription) + $sql = "SELECT count(*) as somme , d.fk_adherent_type"; + $sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t"; + $sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")"; + $sql .= " AND d.statut = 1 AND (d.datefin IS NULL AND t.subscription = 1)"; + $sql .= " AND t.rowid = d.fk_adherent_type"; + $sql .= " GROUP BY d.fk_adherent_type"; + + dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) { + $num2 = $this->db->num_rows($result); + $i = 0; + while ($i < $num2) { + $objp = $this->db->fetch_object($result); + $MembersPending[$objp->fk_adherent_type] = $objp->somme; + $i++; + } + $this->db->free($result); + } $line = 0; $this->info_box_contents[$line][] = array( 'td' => 'class=""', 'text' => '', ); + // Draft $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); - $labelstatus = $langs->trans("UpToDate"); + // Pending (Waiting for first subscription) + $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', + 'text' => $labelstatus + ); + // Up to date $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus, ); - $labelstatus = $langs->trans("OutOfDate"); + // Expired $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Excluded $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); + // Resiliated $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1); $this->info_box_contents[$line][] = array( 'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"', 'text' => $labelstatus ); $line++; + foreach ($AdherentType as $key => $adhtype) { $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0; - $SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0; + $SumPending += isset($MembersPending[$key]) ? $MembersPending[$key] : 0; + $SumExpired += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) - (isset($MembersPending[$key]) ? $MembersPending[$key] : 0): 0; $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0; $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0; $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; @@ -220,6 +253,11 @@ class box_members_by_type extends ModeleBoxes 'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1, ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => (isset($MembersPending[$key]) && $MembersPending[$key] > 0 ? $MembersPending[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'asis' => 1, + ); $this->info_box_contents[$line][] = array( 'td' => 'class="right"', 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), @@ -260,6 +298,11 @@ class box_members_by_type extends ModeleBoxes 'text' => $SumToValidate.' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3), 'asis' => 1 ); + $this->info_box_contents[$line][] = array( + 'td' => 'class="liste_total right"', + 'text' => $SumPending.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3), + 'asis' => 1 + ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', 'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3), @@ -267,7 +310,7 @@ class box_members_by_type extends ModeleBoxes ); $this->info_box_contents[$line][] = array( 'td' => 'class="liste_total right"', - 'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), + 'text' => $SumExpired.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3), 'asis' => 1 ); $this->info_box_contents[$line][] = array( diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 80d465f0f87..6c3db843523 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -175,7 +175,6 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => 'class="liste_total"', 'text' => $langs->trans("Total")." ".$textHead, - 'text' => " ", ); $this->info_box_contents[$i][] = array( 'td' => 'class="right liste_total" ', diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 1a29c8e1389..96928adfdff 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -464,6 +464,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box closedir($handle); } } + //echo "
";print_r($modules);echo "
"; asort($orders); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index a7a87e1ce6e..cf0bfa6ed3b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1123,7 +1123,7 @@ class CMailFile return 'Bad value for sendmode'; } - $parameters = array(); + $parameters = array('sent' => $res); $action = ''; $reshook = $hookmanager->executeHooks('sendMailAfter', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 67443a7bdb8..1ed16b2e1ce 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -157,13 +157,14 @@ class Canvas } /** - * Return the template to display canvas (if it exists) + * Return if a template exists to display as canvas (if it exists) * * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ public function displayCanvasExists($action) { + // template_dir should be '/'.$this->dirmodule.'/canvas/'.$this->canvas.'/tpl/', for example '/mymodule/canvas/product/tpl' if (empty($this->template_dir)) { return 0; } diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 7b46b0a08b0..cbf4574ec48 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -122,7 +122,7 @@ class Ccountry // extends CommonObject $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->code_iso) ? 'NULL' : "'".$this->db->escape($this->code_iso)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; - $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'"); $sql .= ")"; $this->db->begin(); @@ -239,7 +239,7 @@ class Ccountry // extends CommonObject $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " code_iso=".(isset($this->code_iso) ? "'".$this->db->escape($this->code_iso)."'" : "null").","; $sql .= " label=".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " active=".(isset($this->active) ? $this->active : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 960d2ac4744..4a743e5b070 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -351,16 +351,18 @@ class Comment extends CommonObject /** - * Load comments linked with current task + * Load comments linked with current task into ->comments * * @param string $element_type Element type * @param int $fk_element Id of element - * @return array Comment array + * @return int Result */ public function fetchAllFor($element_type, $fk_element) { global $db, $conf; + $this->comments = array(); + if (!empty($element_type) && !empty($fk_element)) { $sql = "SELECT"; $sql .= " c.rowid"; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 82012400f68..da529e33d0e 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -443,7 +443,7 @@ abstract class CommonDocGenerator } } - $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); + $date = (isset($object->element) && $object->element == 'contrat' && isset($object->date_contrat)) ? $object->date_contrat : (isset($object->date) ? $object->date : null); $resarray = array( $array_key.'_id'=>$object->id, @@ -452,7 +452,7 @@ abstract class CommonDocGenerator $array_key.'_ref_ext' => (property_exists($object, 'ref_ext') ? $object->ref_ext : ''), $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), - $array_key.'_source_invoice_ref'=>$invoice_source->ref, + $array_key.'_source_invoice_ref'=>((empty($invoice_source) || empty($invoice_source->ref)) ? '' : $invoice_source->ref), // Dates $array_key.'_hour'=>dol_print_date($date, 'hour'), $array_key.'_date'=>dol_print_date($date, 'day'), @@ -651,7 +651,7 @@ abstract class CommonDocGenerator ); // Units - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $resarray['line_unit'] = $outputlangs->trans($line->getLabelOfUnit('long')); $resarray['line_unit_short'] = $outputlangs->trans($line->getLabelOfUnit('short')); } @@ -687,7 +687,7 @@ abstract class CommonDocGenerator $resql = $this->db->fetch_object($resql); foreach ($extralabels as $key => $label) { - $resarray['line_product_supplier_'.$key] = $resql->{$key}; + $resarray['line_product_supplier_'.$key] = $resql->$key; } } } @@ -1016,12 +1016,10 @@ abstract class CommonDocGenerator * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return null + * @return void */ public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf; - $this->defineColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -1106,14 +1104,14 @@ abstract class CommonDocGenerator public function getColumnContentXStart($colKey) { $colDef = $this->cols[$colKey]; - return $colDef['xStartPos'] + $colDef['content']['padding'][3]; + return (isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0) + $colDef['content']['padding'][3]; } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $colKey the column key - * @return int rank on success and -1 on error + * @param string $colKey the column key + * @return int rank on success and -1 on error */ public function getColumnRank($colKey) { @@ -1126,11 +1124,11 @@ abstract class CommonDocGenerator /** * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { @@ -1171,11 +1169,11 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param TCPDF $pdf pdf object - * @param float $curY curent Y position - * @param string $colKey the column key - * @param string $columnText column text - * @return null + * @param TCPDF $pdf pdf object + * @param float $curY curent Y position + * @param string $colKey the column key + * @param string $columnText column text + * @return int <0 if KO, >= if OK */ public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { @@ -1193,7 +1191,7 @@ abstract class CommonDocGenerator } if (!$reshook) { if (empty($columnText)) { - return; + return 0; } $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; @@ -1206,22 +1204,24 @@ abstract class CommonDocGenerator // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } + + return 0; } /** * 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 + * @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 void */ public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { @@ -1265,7 +1265,7 @@ abstract class CommonDocGenerator global $hookmanager; if (empty($object->table_element)) { - return; + return ''; } $extrafieldsKeyPrefix = "options_"; @@ -1279,7 +1279,7 @@ abstract class CommonDocGenerator $extrafieldOptionsKey = $extrafieldsKeyPrefix.$extrafieldKey; - // Load extrafiels if not allready does + // Load extra fields if they haven't been loaded already. if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } @@ -1288,7 +1288,8 @@ abstract class CommonDocGenerator } $extrafields = $this->extrafieldsCache; - $extrafieldOutputContent = $extrafields->showOutputField($extrafieldKey, $object->array_options[$extrafieldOptionsKey], '', $object->table_element); + $extrafieldOutputContent = ''; + if (isset($object->array_options[$extrafieldOptionsKey])) $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') { @@ -1317,10 +1318,10 @@ abstract class CommonDocGenerator /** * display extrafields columns content * - * @param object $object line of common object - * @param Translate $outputlangs Output language - * @param array $params array of additionals parameters - * @return double max y value + * @param object $object line of common object + * @param Translate $outputlangs Output language + * @param array $params array of additionals parameters + * @return string Html string */ public function getExtrafieldsInHtml($object, $outputlangs, $params = array()) { @@ -1330,7 +1331,7 @@ abstract class CommonDocGenerator return; } - // Load extrafiels if not allready does + // Load extrafields if not allready done if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } @@ -1366,7 +1367,6 @@ abstract class CommonDocGenerator $params = $params + $defaultParams; - /** * @var $extrafields ExtraFields */ @@ -1593,21 +1593,19 @@ abstract class CommonDocGenerator * @param object $object common object det * @param Translate $outputlangs langs * @param int $hidedetails Do not show line details - * @return null + * @return int <0 if KO, >=0 if OK */ public function defineColumnExtrafield($object, $outputlangs, $hidedetails = 0) { - global $conf; - if (!empty($hidedetails)) { - return; + return 0; } if (empty($object->table_element)) { - return; + return 0; } - // Load extrafiels if not allready does + // Load extra fields if they haven't been loaded already. if (empty($this->extrafieldsCache)) { $this->extrafieldsCache = new ExtraFields($this->db); } @@ -1617,7 +1615,7 @@ abstract class CommonDocGenerator $extrafields = $this->extrafieldsCache; - if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) { + if (!empty($extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]) && array_key_exists('label', $extrafields->attributes[$object->table_element]) && is_array($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Dont display separator yet even is set to be displayed (not compatible yet) if ($extrafields->attributes[$object->table_element]['type'][$key] == 'separate') { @@ -1674,5 +1672,7 @@ abstract class CommonDocGenerator $this->insertNewColumnDef("options_".$key, $def); } } + + return 1; } } diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 3f53c3c4e94..dd0ec988062 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -332,6 +332,7 @@ abstract class CommonInvoice extends CommonObject $field = 'fk_facture'; $field2 = 'fk_paiement'; $field3 = ', p.ref_ext'; + $field4 = ', p.fk_bank'; // Bank line id $sharedentity = 'facture'; if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { $table = 'paiementfourn_facturefourn'; @@ -342,7 +343,7 @@ abstract class CommonInvoice extends CommonObject $sharedentity = 'facture_fourn'; } - $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3; + $sql = "SELECT p.ref, pf.amount, pf.multicurrency_amount, p.fk_paiement, p.datep, p.num_paiement as num, t.code".$field3 . $field4; $sql .= " FROM ".$this->db->prefix().$table." as pf, ".$this->db->prefix().$table2." as p, ".$this->db->prefix()."c_paiement as t"; $sql .= " WHERE pf.".$field." = ".((int) $this->id); $sql .= " AND pf.".$field2." = p.rowid"; @@ -363,6 +364,9 @@ abstract class CommonInvoice extends CommonObject if (!empty($field3)) { $tmp['ref_ext'] = $obj->ref_ext; } + if (!empty($field4)) { + $tmp['fk_bank_line'] = $obj->fk_bank; + } $retarray[] = $tmp; $i++; } @@ -865,7 +869,7 @@ abstract class CommonInvoice extends CommonObject /** - * Create a withdrawal request for a direct debit order or a credit transfer order. + * Create a withdrawal request, from a prelevement_demande, to Stripe for a direct debit order or a credit transfer order. * Use the remain to pay excluding all existing open direct debit requests. * * @param User $fuser User asking the direct debit transfer @@ -900,6 +904,8 @@ abstract class CommonInvoice extends CommonObject $sql = "SELECT rowid, date_demande, amount, fk_facture, fk_facture_fourn"; $sql .= " FROM ".$this->db->prefix()."prelevement_demande"; + $sql .= " AND fk_facture = ".((int) $this->fk_facture); // Add a protection to not pay another invoice than current one + $sql .= " AND traite = 0"; // Add a protection to not process twice $sql .= " WHERE rowid = ".((int) $did); dol_syslog(get_class($this)."::makeStripeSepaRequest 1", LOG_DEBUG); @@ -1035,9 +1041,9 @@ abstract class CommonInvoice extends CommonObject } - dol_syslog("makeStripeSepaRequest get stripe account", LOG_DEBUG); + dol_syslog("makeStripeSepaRequest get stripe connet account", LOG_DEBUG); $stripeacc = $stripe->getStripeAccount($service, $this->socid); // Get Stripe OAuth connect account if it exists (no network access here) - dol_syslog("makeStripeSepaRequest get stripe account return " . json_encode($stripeacc), LOG_DEBUG); + dol_syslog("makeStripeSepaRequest get stripe connect account return " . json_encode($stripeacc), LOG_DEBUG); if ($foundalternativestripeaccount) { if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage @@ -1072,101 +1078,68 @@ abstract class CommonInvoice extends CommonObject } if (!$error) { // Payment was not canceled - //erics card or sepa ? $sepaMode = false; + $stripecard = null; if ($companypaymentmode->type == 'ban') { $sepaMode = true; + // Check into societe_rib if a payment mode for Stripe and ban payment exists + // To make a Stripe SEPA payment request, we must have the payment mode source already saved into societe_rib and retreived with ->sepaStripe + // The payment mode source is created when we create the bank account on Stripe with paymentmodes.php?action=create $stripecard = $stripe->sepaStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0); - } else { - $stripecard = $stripe->cardStripe($customer, $companypaymentmode, $stripeacc, $servicestatus, 0); } - if ($stripecard) { // Can be card_... (old mode) or pm_... (new mode) + if ($stripecard) { // Can be src_... (for sepa) or pm_... (new card mode). Note that card_... (old card mode) should not happen here. $FULLTAG = 'INV=' . $this->id . '-CUS=' . $thirdparty->id; - $description = 'Stripe payment from doTakePaymentStripeForThirdparty: ' . $FULLTAG . ' ref=' . $this->ref; + $description = 'Stripe payment from makeStripeSepaRequest: ' . $FULLTAG . ' ref=' . $this->ref; $stripefailurecode = ''; $stripefailuremessage = ''; $stripefailuredeclinecode = ''; - if (preg_match('/^card_/', $stripecard->id)) { // Using old method - dol_syslog("* Create charge on card " . $stripecard->id . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); + // Using new SCA method + dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); - $ipaddress = getUserRemoteIP(); + // Create payment intent and charge payment (confirmnow = true) + $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $this, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); - $charge = null; // Force reset of $charge, so, if already set from a previous fetch, it will be empty even if there is an exception at next step - try { - $charge = \Stripe\Charge::create([ - 'amount' => price2num($amountstripe, 'MU'), - 'currency' => $currency, - 'capture' => true, // Charge immediatly - 'description' => $description, - 'metadata' => ["FULLTAG" => $FULLTAG, 'Recipient' => $mysoc->name, 'dol_version' => DOL_VERSION, 'dol_entity' => $conf->entity, 'ipaddress' => $ipaddress], - 'customer' => $customer->id, - //'customer' => 'bidon_to_force_error', // To use to force a stripe error - 'source' => $stripecard, - 'statement_descriptor' => dol_trunc('INV=' . $this->id, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) - ]); - } catch (\Stripe\Error\Card $e) { - // Since it's a decline, Stripe_CardError will be caught - $body = $e->getJsonBody(); - $err = $body['error']; + $charge = new stdClass(); - $stripefailurecode = $err['code']; - $stripefailuremessage = $err['message']; - $stripefailuredeclinecode = $err['decline_code']; - } catch (Exception $e) { - $stripefailurecode = 'UnknownChargeError'; - $stripefailuremessage = $e->getMessage(); - } - } else { // Using new SCA method - if ($sepaMode) { - dol_syslog("* Create payment on SEPA " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); - } else { - dol_syslog("* Create payment on card " . $stripecard->id . ", amounttopay=" . $amounttopay . ", amountstripe=" . $amountstripe . ", FULLTAG=" . $FULLTAG, LOG_DEBUG); - } + if ($paymentintent->status === 'succeeded' || $paymentintent->status === 'processing') { + $charge->status = 'ok'; + $charge->id = $paymentintent->id; + $charge->customer = $customer->id; + } elseif ($paymentintent->status === 'requires_action') { + //paymentintent->status may be => 'requires_action' (no error in such a case) + dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - // Create payment intent and charge payment (confirmnow = true) - $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); + $charge->status = 'failed'; + $charge->customer = $customer->id; + $charge->failure_code = $stripe->code; + $charge->failure_message = $stripe->error; + $charge->failure_declinecode = $stripe->declinecode; + $stripefailurecode = $stripe->code; + $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; + $stripefailuredeclinecode = $stripe->declinecode; + } else { + dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - $charge = new stdClass(); - //erics add processing sepa is like success ? - if ($paymentintent->status === 'succeeded' || $paymentintent->status === 'processing') { - $charge->status = 'ok'; - $charge->id = $paymentintent->id; - $charge->customer = $customer->id; - } elseif ($paymentintent->status === 'requires_action') { - //paymentintent->status may be => 'requires_action' (no error in such a case) - dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - - $charge->status = 'failed'; - $charge->customer = $customer->id; - $charge->failure_code = $stripe->code; - $charge->failure_message = $stripe->error; - $charge->failure_declinecode = $stripe->declinecode; - $stripefailurecode = $stripe->code; - $stripefailuremessage = 'Action required. Contact the support at ';// . $conf->global->SELLYOURSAAS_MAIN_EMAIL; - $stripefailuredeclinecode = $stripe->declinecode; - } else { - dol_syslog(var_export($paymentintent, true), LOG_DEBUG); - - $charge->status = 'failed'; - $charge->customer = $customer->id; - $charge->failure_code = $stripe->code; - $charge->failure_message = $stripe->error; - $charge->failure_declinecode = $stripe->declinecode; - $stripefailurecode = $stripe->code; - $stripefailuremessage = $stripe->error; - $stripefailuredeclinecode = $stripe->declinecode; - } - - //var_dump("stripefailurecode=".$stripefailurecode." stripefailuremessage=".$stripefailuremessage." stripefailuredeclinecode=".$stripefailuredeclinecode); - //exit; + $charge->status = 'failed'; + $charge->customer = $customer->id; + $charge->failure_code = $stripe->code; + $charge->failure_message = $stripe->error; + $charge->failure_declinecode = $stripe->declinecode; + $stripefailurecode = $stripe->code; + $stripefailuremessage = $stripe->error; + $stripefailuredeclinecode = $stripe->declinecode; } + //var_dump("stripefailurecode=".$stripefailurecode." stripefailuremessage=".$stripefailuremessage." stripefailuredeclinecode=".$stripefailuredeclinecode); + //exit; + + // Return $charge = array('id'=>'ch_XXXX', 'status'=>'succeeded|pending|failed', 'failure_code'=>, 'failure_message'=>...) if (empty($charge) || $charge->status == 'failed') { - dol_syslog('Failed to charge card or payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING); + dol_syslog('Failed to charge payment mode ' . $stripecard->id . ' stripefailurecode=' . $stripefailurecode . ' stripefailuremessage=' . $stripefailuremessage . ' stripefailuredeclinecode=' . $stripefailuredeclinecode, LOG_WARNING); // Save a stripe payment was in error $this->stripechargeerror++; @@ -1202,20 +1175,24 @@ abstract class CommonInvoice extends CommonObject $errmsg .= ($stripefailuredeclinecode ? ' - ' . $stripefailuredeclinecode : ''); } - $description = 'Stripe payment ERROR from doTakePaymentStripeForThirdparty: ' . $FULLTAG; + $description = 'Stripe payment ERROR from makeStripeSepaRequest: ' . $FULLTAG; $postactionmessages[] = $errmsg . ' (' . $stripearrayofkeys['publishable_key'] . ')'; $this->errors[] = $errmsg; } else { - dol_syslog('Successfuly charge card ' . $stripecard->id); + dol_syslog('Successfuly request direct debit ' . $stripecard->id); - $postactionmessages[] = 'Success to charge card (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')'; + $postactionmessages[] = 'Success to request direct debit (' . $charge->id . ' with ' . $stripearrayofkeys['publishable_key'] . ')'; // Save a stripe payment was done in realy life so later we will be able to force a commit on recorded payments // even if in batch mode (method doTakePaymentStripe), we will always make all action in one transaction with a forced commit. $this->stripechargedone++; // Default description used for label of event. Will be overwrite by another value later. - $description = 'Stripe payment OK (' . $charge->id . ') from doTakePaymentStripeForThirdparty: ' . $FULLTAG; + $description = 'Stripe payment request OK (' . $charge->id . ') from makeStripeSepaRequest: ' . $FULLTAG; + + + // @TODO LMR Save request to status pending instead of done. Done should be set with a webhook. + $db = $this->db; @@ -1256,6 +1233,7 @@ abstract class CommonInvoice extends CommonObject $ispostactionok = 1; // Creation of payment line + // TODO LMR This must be move into the stripe server listening hooks public/stripe/ipn.php include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php'; $paiement = new Paiement($this->db); $paiement->datepaye = $now; @@ -1300,13 +1278,8 @@ abstract class CommonInvoice extends CommonObject if (!$errorforinvoice && isModEnabled('banque')) { dol_syslog('* Add payment to bank'); + // The bank used is the one defined into Stripe setup $bankaccountid = 0; - if ($paymentmethod == 'paybox') { - $bankaccountid = $conf->global->PAYBOX_BANK_ACCOUNT_FOR_PAYMENTS; - } - if ($paymentmethod == 'paypal') { - $bankaccountid = $conf->global->PAYPAL_BANK_ACCOUNT_FOR_PAYMENTS; - } if ($paymentmethod == 'stripe') { $bankaccountid = $conf->global->STRIPE_BANK_ACCOUNT_FOR_PAYMENTS; } @@ -1323,7 +1296,7 @@ abstract class CommonInvoice extends CommonObject $error++; $errorforinvoice++; } else { - $postactionmessages[] = 'Bank transaction of payment created (by doTakePaymentStripeForThirdparty)'; + $postactionmessages[] = 'Bank transaction of payment created (by makeStripeSepaRequest)'; } } else { $postactionmessages[] = 'Setup of bank account to use in module ' . $paymentmethod . ' was not set. No way to record the payment.'; @@ -1334,13 +1307,13 @@ abstract class CommonInvoice extends CommonObject } if ($ispostactionok < 1) { - $description = 'Stripe payment OK (' . $charge->id . ' - ' . $amounttopay . ' ' . $conf->currency . ') but post action KO from doTakePaymentStripeForThirdparty: ' . $FULLTAG; + $description = 'Stripe payment OK (' . $charge->id . ' - ' . $amounttopay . ' ' . $conf->currency . ') but post action KO from makeStripeSepaRequest: ' . $FULLTAG; } else { - $description = 'Stripe payment+post action OK (' . $charge->id . ' - ' . $amounttopay . ' ' . $conf->currency . ') from doTakePaymentStripeForThirdparty: ' . $FULLTAG; + $description = 'Stripe payment+post action OK (' . $charge->id . ' - ' . $amounttopay . ' ' . $conf->currency . ') from makeStripeSepaRequest: ' . $FULLTAG; } } - $object = $invoice; + $object = $this; // Send emails $labeltouse = 'InvoicePaymentSuccess'; @@ -1366,8 +1339,8 @@ abstract class CommonInvoice extends CommonObject } else { $error++; $errorforinvoice++; - dol_syslog("No card or payment method found for this stripe customer " . $customer->id, LOG_WARNING); - $this->errors[] = 'Failed to get card | payment method for stripe customer = ' . $customer->id; + dol_syslog("No direct debit payment method found for this stripe customer " . $customer->id, LOG_WARNING); + $this->errors[] = 'Failed to get direct debit payment method for stripe customer = ' . $customer->id; $labeltouse = 'InvoicePaymentFailure'; $sendemailtocustomer = 1; @@ -1380,7 +1353,7 @@ abstract class CommonInvoice extends CommonObject $stripefailuremessage = 'Failed to find or use the payment mode - no credit card defined for the customer account'; $postactionmessages[] = $description . ' (' . $stripearrayofkeys['publishable_key'] . ')'; - $object = $invoice; + $object = $this; $actioncode = 'PAYMENT_STRIPE_KO'; $extraparams = ''; @@ -1394,7 +1367,7 @@ abstract class CommonInvoice extends CommonObject $stripefailurecode = ''; $stripefailuremessage = ''; - $object = $invoice; + $object = $this; $actioncode = ''; $extraparams = ''; @@ -1421,12 +1394,13 @@ abstract class CommonInvoice extends CommonObject $stripefailuremessage = 'Failed to find or use your payment mode (no payment mode for this customer id)'; $postactionmessages = []; - $object = $invoice; + $object = $this; $actioncode = 'PAYMENT_STRIPE_KO'; $extraparams = ''; } + /* // Send email + create action after if ($sendemailtocustomer && $labeltouse) { dol_syslog("* Send email with result of payment - " . $labeltouse); @@ -1537,6 +1511,7 @@ abstract class CommonInvoice extends CommonObject } } } + */ if ($description) { dol_syslog("* Record event for payment result - " . $description); @@ -1588,18 +1563,18 @@ abstract class CommonInvoice extends CommonObject $this->errors[] = "Remain to pay is null for the invoice " . $this->id . " " . $this->ref . ". Why is the invoice not classified 'Paid' ?"; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_demande("; - $sql .= "fk_facture, "; - $sql .= " amount, date_demande, fk_user_demande, ext_payment_id, ext_payment_site, sourcetype, entity)"; - $sql .= " VALUES (".$this->id; - $sql .= ",".((float) price2num($amount)); - $sql .= ",'".$this->db->idate($now)."'"; - $sql .= ",".((int) $fuser->id); - $sql .= ",'".$this->db->escape($stripe_id)."'"; - $sql .= ",'".$this->db->escape($stripe_uri)."'"; - $sql .= ",'".$this->db->escape($sourcetype)."'"; - $sql .= ",".$conf->entity; - $sql .= ")"; + // TODO Create a prelevement_bon and set its status to sent instead of this + $idtransferfile = 0; + + // Update the direct debit payment request of the processed invoice to save the id of the prelevement_bon + $sql = "UPDATE".MAIN_DB_PREFIX."prelevement_demande SET"; + $sql .= " traite = 1,"; // TODO Remove this + $sql .= " date_traite = '".$this->db->idate(dol_now())."'"; // TODO Remove this + if ($idtransferfile > 0) { + $sql .= " fk_prelevement_bons = ".((int) $idtransferfile); + } + $sql .= "WHERE rowid = ".((int) $did); + dol_syslog(get_class($this)."::makeStripeSepaRequest", LOG_DEBUG); $resql = $this->db->query($sql); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7df0c4efe9c..6870d25f6ea 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -16,6 +16,7 @@ * Copyright (C) 2018 Josep Lluís Amador * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2021 Grégory Blémand + * Copyright (C) 2023 Lenin Rivas * * 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 @@ -592,6 +593,15 @@ abstract class CommonObject protected $labelStatus; protected $labelStatusShort; + /** + * @var array nb used in load_stateboard + */ + public $nb = array(); + + /** + * @var string output + */ + public $output; /** * @var array List of child tables. To test if we can delete object. @@ -769,34 +779,6 @@ abstract class CommonObject } } - /** - * Return clicable link of object (with eventually picto) - * - * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) - * @return string HTML Code for Kanban thumb. - */ - public function getKanbanView($option = '') - { - $return = '
'; - $return .= '
'; - $return .= ''; - $return .= img_picto('', $this->picto); - $return .= ''; - $return .= '
'; - $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; - if (property_exists($this, 'label')) { - $return .= '
'.$this->label.''; - } - if (method_exists($this, 'getLibStatut')) { - $return .= '
'.$this->getLibStatut(5).'
'; - } - $return .= '
'; - $return .= '
'; - $return .= '
'; - - return $return; - } - /** * Return full address of contact * @@ -979,27 +961,6 @@ abstract class CommonObject } $outdone++; } - } else { // Old code to remove - if (!empty($this->skype)) { - $outsocialnetwork .= dol_print_socialnetworks($this->skype, $this->id, $object->id, 'skype'); - } - $outdone++; - if (!empty($this->jabberid)) { - $outsocialnetwork .= dol_print_socialnetworks($this->jabberid, $this->id, $object->id, 'jabber'); - } - $outdone++; - if (!empty($this->twitter)) { - $outsocialnetwork .= dol_print_socialnetworks($this->twitter, $this->id, $object->id, 'twitter'); - } - $outdone++; - if (!empty($this->facebook)) { - $outsocialnetwork .= dol_print_socialnetworks($this->facebook, $this->id, $object->id, 'facebook'); - } - $outdone++; - if (!empty($this->linkedin)) { - $outsocialnetwork .= dol_print_socialnetworks($this->linkedin, $this->id, $object->id, 'linkedin'); - } - $outdone++; } if ($outsocialnetwork) { @@ -1309,11 +1270,11 @@ abstract class CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Delete all links between an object $this and all its contacts + * Delete all links between an object $this and all its contacts in llx_element_contact * * @param string $source '' or 'internal' or 'external' * @param string $code Type of contact (code or id) - * @return int >0 if OK, <0 if KO + * @return int <0 if KO, 0=Nothing done, >0 if OK */ public function delete_linked_contact($source = '', $code = '') { @@ -1329,11 +1290,15 @@ abstract class CommonObject $listId = implode(",", $temp); } + // If $listId is empty, we have not criteria on fk_c_type_contact so we will delete record on element_id for + // any type or record instead of only the ones of the current object. So we do nothing in such a case. + if (empty($listId)) { + return 0; + } + $sql = "DELETE FROM ".$this->db->prefix()."element_contact"; $sql .= " WHERE element_id = ".((int) $this->id); - if (!empty($listId)) { - $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; - } + $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; dol_syslog(get_class($this)."::delete_linked_contact", LOG_DEBUG); if ($this->db->query($sql)) { @@ -1415,6 +1380,7 @@ abstract class CommonObject $transkey = "TypeContact_".$obj->element."_".$obj->source."_".$obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); $tab[$i] = array( + 'parentId' => $this->id, 'source' => $obj->source, 'socid' => $obj->socid, 'id' => $obj->id, @@ -2072,7 +2038,7 @@ abstract class CommonObject $sql .= " WHERE ".$id_field." = ".((int) $id); - dol_syslog(__METHOD__."", LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($trigkey) { @@ -3338,6 +3304,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -3361,6 +3329,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3406,6 +3376,8 @@ abstract class CommonObject return $row[0]; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -3796,7 +3768,7 @@ abstract class CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Add objects linked in llx_element_element. + * Add an object link into llx_element_element. * * @param string $origin Linked element type * @param int $origin_id Linked element id @@ -4118,6 +4090,21 @@ abstract class CommonObject } } + /** + * Clear the cache saying that all linked object were already loaded. So next fetchObjectLinked will reload all links. + * + * @return int <0 if KO, >0 if OK + * @see fetchObjectLinked() + */ + public function clearObjectLinkedCache() + { + if ($this->id > 0 && !empty($this->linkedObjectsFullLoaded[$this->id])) { + unset($this->linkedObjectsFullLoaded[$this->id]); + } + + return 1; + } + /** * Update object linked of a current object * @@ -4518,6 +4505,8 @@ abstract class CommonObject $row = $this->db->fetch_row($resql); return $row[0]; } + + return 0; } /** @@ -5100,7 +5089,7 @@ abstract class CommonObject print '
'; } print ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print ''; } print ''; @@ -5238,7 +5227,7 @@ abstract class CommonObject $this->tpl['total_ht'] = price($line->total_ht); $this->tpl['multicurrency_price'] = price($line->multicurrency_subprice); $this->tpl['qty'] = (($line->info_bits & 2) != 2) ? $line->qty : ' '; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $this->tpl['unit'] = $langs->transnoentities($line->getLabelOfUnit('long')); } $this->tpl['remise_percent'] = (($line->info_bits & 2) != 2) ? vatrate($line->remise_percent, true) : ' '; @@ -5717,15 +5706,16 @@ abstract class CommonObject * * @param string $fieldname Name of field * @param string $alternatevalue Alternate value to use + * @param string $type Type of data * @return string|string[] Default value (can be an array if the GETPOST return an array) **/ - public function getDefaultCreateValueFor($fieldname, $alternatevalue = null) + public function getDefaultCreateValueFor($fieldname, $alternatevalue = null, $type = 'alphanohtml') { global $conf, $_POST; // If param here has been posted, we use this value first. if (GETPOSTISSET($fieldname)) { - return GETPOST($fieldname, 'alphanohtml', 3); + return GETPOST($fieldname, $type, 3); } if (isset($alternatevalue)) { @@ -5751,6 +5741,9 @@ abstract class CommonObject } // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname + // store content into $conf->cache['overwrite_default'] + + return ''; } @@ -6442,9 +6435,9 @@ abstract class CommonObject return -1; } elseif ($value == '') { $new_array_languages[$key] = null; + } else { + $new_array_languages[$key] = $value; } - //dol_syslog("double value"." sur ".$attributeLabel."(".$value." is '".$attributeType."')", LOG_DEBUG); - $new_array_languages[$key] = $value; break; /*case 'select': // Not required, we chosed value='0' for undefined values if ($value=='-1') @@ -7807,7 +7800,7 @@ abstract class CommonObject * clear validation message result for a field * * @param string $fieldKey Key of attribute to clear - * @return null + * @return void */ public function clearFieldError($fieldKey) { @@ -7820,12 +7813,14 @@ abstract class CommonObject * * @param string $fieldKey Key of attribute * @param string $msg the field error message - * @return null + * @return void */ public function setFieldError($fieldKey, $msg = '') { global $langs; - if (empty($msg)) { $msg = $langs->trans("UnknowError"); } + if (empty($msg)) { + $msg = $langs->trans("UnknowError"); + } $this->error = $this->validateFieldsErrors[$fieldKey] = $msg; } @@ -7847,30 +7842,34 @@ abstract class CommonObject /** * Return validation test result for a field * - * @param array $val Array of properties of field to show + * @param array $fields Array of properties of field to show * @param string $fieldKey Key of attribute * @param string $fieldValue value of attribute * @return bool return false if fail true on success, see $this->error for error message */ - public function validateField($val, $fieldKey, $fieldValue) + public function validateField($fields, $fieldKey, $fieldValue) { global $langs; - if (!class_exists('Validate')) { require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; } + if (!class_exists('Validate')) { + require_once DOL_DOCUMENT_ROOT . '/core/class/validate.class.php'; + } $this->clearFieldError($fieldKey); - if (!isset($val[$fieldKey])) { + if (!isset($fields[$fieldKey])) { $this->setFieldError($fieldKey, $langs->trans('FieldNotFoundInObject')); return false; } + $val = $fields[$fieldKey]; + $param = array(); $param['options'] = array(); - $type = $val[$fieldKey]['type']; + $type = $val['type']; $required = false; - if (isset($val[$fieldKey]['notnull']) && $val[$fieldKey]['notnull'] === 1) { + if (isset($val['notnull']) && $val['notnull'] === 1) { // 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). $required = true; } @@ -7881,6 +7880,7 @@ abstract class CommonObject // // PREPARE Elements // + $reg = array(); // Convert var to be able to share same code than showOutputField of extrafields if (preg_match('/varchar\((\d+)\)/', $type, $reg)) { @@ -7894,7 +7894,7 @@ abstract class CommonObject $type = 'select'; } - if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { + if (!empty($val['type']) && preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) { $type = 'link'; } @@ -8431,19 +8431,19 @@ abstract class CommonObject * This function is meant to be called from replaceThirdparty with the appropriate tables * Column name fk_soc MUST be used to identify thirdparties * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler * @param int $origin_id Old thirdparty id (the thirdparty to delete) * @param int $dest_id New thirdparty id (the thirdparty that will received element of the other) * @param string[] $tables Tables that need to be changed * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old thirdparty may already exists on new one) * @return bool True if success, False if error */ - public static function commonReplaceThirdparty(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) + public static function commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { - $sql = 'UPDATE '.$db->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); + $sql = 'UPDATE '.$dbs->prefix().$table.' SET fk_soc = '.((int) $dest_id).' WHERE fk_soc = '.((int) $origin_id); - if (!$db->query($sql)) { + if (!$dbs->query($sql)) { if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept thirdparty and B-C on old one, we must get A-B-C after merge. Not A-B. } @@ -8460,19 +8460,19 @@ abstract class CommonObject * This function is meant to be called from replaceProduct with the appropriate tables * Column name fk_product MUST be used to identify products * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler * @param int $origin_id Old product id (the product to delete) * @param int $dest_id New product id (the product that will received element of the other) * @param string[] $tables Tables that need to be changed * @param int $ignoreerrors Ignore errors. Return true even if errors. We need this when replacement can fails like for categories (categorie of old product may already exists on new one) * @return bool True if success, False if error */ - public static function commonReplaceProduct(DoliDB $db, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) + public static function commonReplaceProduct(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors = 0) { foreach ($tables as $table) { $sql = 'UPDATE '.MAIN_DB_PREFIX.$table.' SET fk_product = '.((int) $dest_id).' WHERE fk_product = '.((int) $origin_id); - if (!$db->query($sql)) { + if (!$dbs->query($sql)) { if ($ignoreerrors) { return true; // TODO Not enough. If there is A-B on kept product and B-C on old one, we must get A-B-C after merge. Not A-B. } @@ -8553,21 +8553,21 @@ abstract class CommonObject /** * Show photos of an object (nbmax maximum), into several columns * - * @param string $modulepart 'product', 'ticket', ... - * @param string $sdir Directory to scan (full absolute path) - * @param int $size 0=original size, 1='small' use thumbnail if possible - * @param int $nbmax Nombre maximum de photos (0=pas de max) - * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'. - * @param int $showfilename 1=Show filename - * @param int $showaction 1=Show icon with action links (resize, delete) - * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. - * @param int $maxWidth Max width of original image when size='small' - * @param int $nolink Do not add a href link to view enlarged imaged into a new tab - * @param int $notitle Do not add title tag on image - * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) - * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto + * @param string $modulepart 'product', 'ticket', ... + * @param string $sdir Directory to scan (full absolute path) + * @param int $size 0=original size, 1='small' use thumbnail if possible + * @param int $nbmax Nombre maximum de photos (0=pas de max) + * @param int $nbbyrow Number of image per line or -1 to use div separator or 0 to use no separator. Used only if size=1 or 'small'. + * @param int $showfilename 1=Show filename + * @param int $showaction 1=Show icon with action links (resize, delete) + * @param int $maxHeight Max height of original image when size='small' (so we can use original even if small requested). If 0, always use 'small' thumb image. + * @param int $maxWidth Max width of original image when size='small' + * @param int $nolink Do not add a href link to view enlarged imaged into a new tab + * @param int|string $overwritetitle Do not add title tag on image + * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) + * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) + public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $overwritetitle = 0, $usesharelink = 0) { // phpcs:enable global $conf, $user, $langs; @@ -8635,7 +8635,10 @@ abstract class CommonObject // Find name of thumb file $photo_vignette = basename(getImageFileNameForSize($dir.$file, '_small')); if (!dol_is_file($dirthumb.$photo_vignette)) { - $photo_vignette = ''; + // The thumb does not exists, so we will use the original file + $dirthumb = $dir; + $pdirthumb = $pdir; + $photo_vignette = basename($file); } // Get filesize of original file @@ -8670,8 +8673,12 @@ abstract class CommonObject // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt = $langs->transnoentitiesnoconv('File').': '.$relativefile; $alt .= ' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; - if ($notitle) { - $alt = ''; + if ($overwritetitle) { + if (is_numeric($overwritetitle)) { + $alt = ''; + } else { + $alt = $overwritetitle; + } } $addphotorefcss = 1; @@ -9316,7 +9323,7 @@ abstract class CommonObject $sql .= ' WHERE 1 = 1'; // usage with empty id and empty ref is very rare } if (empty($id) && isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' AND t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' AND t.entity IN ('.getEntity($this->element).')'; } if ($morewhere) { $sql .= $morewhere; @@ -9600,6 +9607,12 @@ abstract class CommonObject } } + // Delete linked object + $res = $this->deleteObjectLinked(); + if ($res < 0) { + $error++; + } + if (!$error && !empty($this->isextrafieldmanaged)) { $result = $this->deleteExtraFields(); if ($result < 0) { @@ -9723,23 +9736,24 @@ abstract class CommonObject $tmpforobjectclass = get_class($this); $tmpforobjectlineclass = ucfirst($tmpforobjectclass).'Line'; + $this->db->begin(); + // Call trigger $result = $this->call_trigger('LINE'.strtoupper($tmpforobjectclass).'_DELETE', $user); if ($result < 0) { - return -1; + $error++; } // End call triggers - $this->db->begin(); + if (empty($error)) { + $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; + $sql .= " WHERE rowid = ".((int) $idline); - $sql = "DELETE FROM ".$this->db->prefix().$this->table_element_line; - $sql .= " WHERE rowid = ".((int) $idline); - - dol_syslog(get_class($this)."::deleteLineCommon", LOG_DEBUG); - $resql = $this->db->query($sql); - if (!$resql) { - $this->error = "Error ".$this->db->lasterror(); - $error++; + $resql = $this->db->query($sql); + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + $error++; + } } if (empty($error)) { @@ -9935,7 +9949,7 @@ abstract class CommonObject * @param int[]|int $categories Category ID or array of Categories IDs * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 966d7963d7c..65ae367c3b2 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -32,6 +32,41 @@ abstract class CommonOrder extends CommonObject { use CommonIncoterm; + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs, $conf; + + $return = '
'; + $return .= '
'; + $return .= '
'; + $return .= img_picto('', 'order'); + $return .= '
'; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + + if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) { + $return .= '
'.$this->thirdparty->getNomUrl(1).'
'; + } + if (property_exists($this, 'total_ht')) { + $return .= '
'.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency).' '.$langs->trans('HT').'
'; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } + /** * @var string code */ diff --git a/htdocs/core/class/commonsocialnetworks.class.php b/htdocs/core/class/commonsocialnetworks.class.php new file mode 100644 index 00000000000..4ec32194f3d --- /dev/null +++ b/htdocs/core/class/commonsocialnetworks.class.php @@ -0,0 +1,108 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/class/commonincoterm.class.php + * \ingroup core + * \brief File of the superclass of object classes that support incoterm (customer and supplier) + */ + + +/** + * Superclass for social networks + */ +trait CommonSocialNetworks +{ + /** + * @var array array of socialnetworks + */ + public $socialnetworks; + + + /** + * Show social network part if the module is enabled with hiding functionality + * + * @param array $socialnetworks Array of social networks + * @param int $colspan Colspan + * @return void + */ + public function showSocialNetwork($socialnetworks, $colspan = 4) + { + global $object, $form, $langs; + + $nbofnetworks = count($socialnetworks); + $nbactive = 0; + foreach ($socialnetworks as $key => $value) { + if (!empty($object->socialnetworks[$key])) { + $nbactive++; + } + } + + if ($nbofnetworks > 1) { + print ''; + print ''; + print '
'.$nbactive.''; + print ''; + print '
'; + } + foreach ($socialnetworks as $key => $value) { + if ($value['active'] || $nbofnetworks == 1) { + print ''; + print ''; + print ''; + print ''; + } elseif (!empty($object->socialnetworks[$key])) { + print ''; + } + } + print '
'; + + if ($nbofnetworks > 1) { + print ''; + } + } +} diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 279ccded71c..bec9c85d5dc 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -133,6 +133,7 @@ class Conf 'barcode' => array(), 'models' => array(), 'societe' => array(), + 'member' => array(), 'hooks' => array(), 'dir' => array(), 'syslog' => array() @@ -145,22 +146,22 @@ class Conf $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); - $this->product = new stdClass(); - $this->service = new stdClass(); - $this->contrat = new stdClass(); - $this->actions = new stdClass(); - $this->agenda = new stdClass(); + $this->product = new stdClass(); + $this->service = new stdClass(); + $this->contrat = new stdClass(); + $this->actions = new stdClass(); + $this->agenda = new stdClass(); $this->commande = new stdClass(); $this->propal = new stdClass(); - $this->facture = new stdClass(); - $this->contrat = new stdClass(); + $this->facture = new stdClass(); + $this->contrat = new stdClass(); $this->user = new stdClass(); - $this->adherent = new stdClass(); + $this->adherent = new stdClass(); $this->bank = new stdClass(); - $this->notification = new stdClass(); + $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); - $this->productbatch = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); } /** @@ -215,26 +216,26 @@ class Conf $this->expedition_bon = new stdClass(); $this->delivery_note = new stdClass(); $this->fournisseur = new stdClass(); - $this->product = new stdClass(); - $this->service = new stdClass(); - $this->contrat = new stdClass(); - $this->actions = new stdClass(); - $this->agenda = new stdClass(); + $this->product = new stdClass(); + $this->service = new stdClass(); + $this->contrat = new stdClass(); + $this->actions = new stdClass(); + $this->agenda = new stdClass(); $this->commande = new stdClass(); $this->propal = new stdClass(); - $this->facture = new stdClass(); - $this->contrat = new stdClass(); + $this->facture = new stdClass(); + $this->contrat = new stdClass(); $this->user = new stdClass(); - $this->adherent = new stdClass(); + $this->adherent = new stdClass(); $this->bank = new stdClass(); - $this->notification = new stdClass(); + $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); - $this->productbatch = new stdClass(); + $this->expensereport = new stdClass(); + $this->productbatch = new stdClass(); // Common arrays $this->cache = array(); - $this->modules = array();; + $this->modules = array(); $this->modules_parts = array( 'css' => array(), 'js' => array(), @@ -249,6 +250,7 @@ class Conf 'barcode' => array(), 'models' => array(), 'societe' => array(), + 'member' => array(), 'hooks' => array(), 'dir' => array(), 'syslog' => array(), @@ -497,9 +499,9 @@ class Conf // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition - $this->expedition_bon->enabled = (!empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? $this->global->MAIN_SUBMODULE_EXPEDITION : 0); + $this->expedition_bon->enabled = (empty($this->global->MAIN_SUBMODULE_EXPEDITION) ? 0 : $this->global->MAIN_SUBMODULE_EXPEDITION); // Sub module delivery note Sous module bons de livraison - $this->delivery_note->enabled = (!empty($this->global->MAIN_SUBMODULE_DELIVERY) ? $this->global->MAIN_SUBMODULE_DELIVERY : 0); + $this->delivery_note->enabled = (empty($this->global->MAIN_SUBMODULE_DELIVERY) ? 0 : $this->global->MAIN_SUBMODULE_DELIVERY); // Module fournisseur if (!empty($this->fournisseur)) { @@ -783,6 +785,11 @@ class Conf $this->global->USE_STRICT_CSV_RULES = 2; } + // By default, option is on. Once set by user, this code is useless + if (!isset($this->global->ACCOUNTING_REEXPORT)) { + $this->global->ACCOUNTING_REEXPORT = 1; + } + // Use a SCA ready workflow with Stripe module (STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION by default if nothing defined) if (!isset($this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION) && empty($this->global->STRIPE_USE_NEW_CHECKOUT)) { $this->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION = 1; diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index d67b0c25f66..e098de93bd4 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -117,7 +117,7 @@ class Cstate // extends CommonObject $sql .= " ".(!isset($this->rowid) ? 'NULL' : "'".$this->db->escape($this->rowid)."'").","; $sql .= " ".(!isset($this->code_departement) ? 'NULL' : "'".$this->db->escape($this->code_departement)."'").","; $sql .= " ".(!isset($this->nom) ? 'NULL' : "'".$this->db->escape($this->nom)."'").","; - $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").""; + $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'"); $sql .= ")"; $this->db->begin(); @@ -208,22 +208,23 @@ class Cstate // extends CommonObject if (isset($this->code_departement)) { $this->code_departement = trim($this->code_departement); } - if (isset($this->nom)) { - $this->nom = trim($this->nom); + if (isset($this->name)) { + $this->name = trim($this->name); } if (isset($this->active)) { $this->active = trim($this->active); } - // Check parameters - // Put here code to add control on parameters values + if (empty($this->name) && !empty($this->nom)) { + $this->name = $this->nom; + } // Update request $sql = "UPDATE ".$this->db->prefix()."c_departements SET"; $sql .= " code_departement=".(isset($this->code_departement) ? "'".$this->db->escape($this->code_departement)."'" : "null").","; - $sql .= " nom=".(isset($this->nom) ? "'".$this->db->escape($this->nom)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").""; + $sql .= " nom=".(isset($this->name) ? "'".$this->db->escape($this->name)."'" : "null").","; + $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 324bfcb36a0..3bfae75d7de 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -114,7 +114,7 @@ class Ctypent // extends CommonObject $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").","; $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").","; - $sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'").""; + $sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'"); $sql .= ")"; $this->db->begin(); @@ -227,8 +227,8 @@ class Ctypent // extends CommonObject $sql = "UPDATE ".$this->db->prefix()."c_typent SET"; $sql .= " code=".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").","; $sql .= " libelle=".(isset($this->libelle) ? "'".$this->db->escape($this->libelle)."'" : "null").","; - $sql .= " active=".(isset($this->active) ? $this->active : "null").","; - $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null").""; + $sql .= " active=".(isset($this->active) ? ((int) $this->active) : "null").","; + $sql .= " module=".(isset($this->module) ? "'".$this->db->escape($this->module)."'" : "null"); $sql .= " WHERE id=".$this->id; $this->db->begin(); diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index be83877098c..88f6960a9f9 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -468,8 +468,4 @@ class CtyperesourceLine public $label; public $active; - - /** - * @var mixed Sample line property 2 - */ } diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 052d5ae7e1c..9f5ea960c9a 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -419,7 +419,7 @@ class DiscountAbsolute * When discount is from a credit note used to reduce payment of an invoice, we link using rowidinvoice * * @param int $rowidline Invoice line id (To use discount into invoice lines) - * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) + * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduce payment of invoice) * @return int <0 if KO, >0 if OK */ public function link_to_invoice($rowidline, $rowidinvoice) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 67f9cbcbf89..f53498fafe8 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -157,11 +157,7 @@ class DolEditor define('REQUIRE_CKEDITOR', '1'); } - if (!empty($conf->global->FCKEDITOR_SKIN)) { - $skin = $conf->global->FCKEDITOR_SKIN; - } else { - $skin = 'moono-lisa'; // default with ckeditor 4.6 : moono-lisa - } + $skin = getDolGlobalString('FCKEDITOR_SKIN', 'moono-lisa'); // default with ckeditor 4.6 : moono-lisa $pluginstodisable = 'elementspath,save,flash,div,specialchar,anchor'; if (!empty($conf->dol_optimize_smallscreen)) { @@ -183,31 +179,31 @@ class DolEditor $htmlencode_force = preg_match('/_encoded$/', $this->toolbarname) ? 'true' : 'false'; - $out .= ''."\n"; + $out .= ''."\n"; $out .= ''; } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index bc06d1517dc..b2bb2a5f8fa 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -449,6 +449,15 @@ class FormFile $titletoshow = ($title == 'none' ? '' : $title); } + $submodulepart = $modulepart; + + // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' + $tmp = explode(':', $modulepart); + if (!empty($tmp[1])) { + $modulepart = $tmp[0]; + $submodulepart = $tmp[1]; + } + // Show table if ($genallowed) { $modellist = array(); @@ -648,15 +657,6 @@ class FormFile $modellist = ModelePDFUserGroup::liste_modeles($this->db); } } else { - $submodulepart = $modulepart; - - // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject' - $tmp = explode(':', $modulepart); - if (!empty($tmp[1])) { - $modulepart = $tmp[0]; - $submodulepart = $tmp[1]; - } - // For normalized standard modules $file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0); if (file_exists($file)) { @@ -837,7 +837,7 @@ class FormFile } // Show file name with link to download - $imgpreview = $this->showPreview($file, $modulepart, $relativepath, 0, $param);; + $imgpreview = $this->showPreview($file, $modulepart, $relativepath, 0, $param); $out .= ''; + + // Note + print ''; + + // Warning + print ''; + + print "\n"; + } + //} + //else + //{ + //$level--; + //} + } + + return $totalforeachline; +} + + /** * Output a task line into a pertime intput mode * @@ -1391,8 +1635,10 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr // Duration print ''; diff --git a/htdocs/core/lib/propal.lib.php b/htdocs/core/lib/propal.lib.php index 9d1401ea47a..3d380a3904a 100644 --- a/htdocs/core/lib/propal.lib.php +++ b/htdocs/core/lib/propal.lib.php @@ -42,7 +42,7 @@ function propal_prepare_head($object) $head[$h][2] = 'comm'; $h++; - if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && !empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire) + if ((empty($conf->commande->enabled) && ((isModEnabled("expedition") && isModEnabled('expedition_bon') && $user->rights->expedition->lire) || (isModEnabled("expedition") && !empty($conf->delivery_note->enabled) && $user->rights->expedition->delivery->lire)))) { $langs->load("sendings"); $text = ''; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index deff1af567c..c372f617237 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -344,7 +344,9 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', } else { $objectid = $object; // $objectid can be X or 'X,Y,Z' } - $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input + if ($objectid) { + $objectid = preg_replace('/[^0-9\.\,]/', '', $objectid); // For the case value is coming from a non sanitized user input + } //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; @@ -367,7 +369,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($features == 'subscription') { $features = 'adherent'; $feature2 = 'cotisation'; - }; + } if ($features == 'websitepage') { $features = 'website'; $tableandshare = 'website_page'; @@ -466,6 +468,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', $readok = 0; $nbko++; } + } elseif ($feature == 'payment_sc') { + if (empty($user->rights->tax->charges->lire)) { + $readok = 0; + $nbko++; + } } elseif (!empty($feature2)) { // This is for permissions on 2 levels $tmpreadok = 1; foreach ($feature2 as $subfeature) { @@ -648,6 +655,10 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if (!$user->rights->facture->paiement) { $deleteok = 0; } + } elseif ($feature == 'payment_sc') { + if (!$user->rights->tax->charges->creer) { + $deleteok = 0; + } } elseif ($feature == 'banque') { if (empty($user->rights->banque->modifier)) { $deleteok = 0; @@ -723,7 +734,11 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', if ($mode) { return $ok ? 1 : 0; } else { - return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); + if ($ok) { + return 1; + } else { + accessforbidden('', 1, 1, 0, $params); + } } } diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index b33ad1333ef..93da106aebd 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -52,12 +52,11 @@ function dol_getwebuser($mode) * @param string $entitytotest Instance of data we must check * @param array $authmode Array list of selected authentication mode array('http', 'dolibarr', 'xxx'...) * @param string $context Context checkLoginPassEntity was created for ('api', 'dav', 'ws', '') - * @return string Login or '' + * @return string Login or '' or '--bad-login-validity--' */ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode, $context = '') { global $conf, $langs; - //global $dolauthmode; // To return authentication finally used // Check parameters if ($entitytotest == '') { @@ -97,13 +96,14 @@ function checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $auth // Call function to check user/password $function = 'check_user_password_'.$mode; $login = call_user_func($function, $usertotest, $passwordtotest, $entitytotest, $context); - if ($login && $login != '--bad-login-validity--') { // Login is successfull + if ($login && $login != '--bad-login-validity--') { + // Login is successfull with this method $test = false; // To stop once at first login success $conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used - $dol_tz = GETPOST('tz'); + /*$dol_tz = GETPOST('tz'); $dol_dst = GETPOST('dst'); $dol_screenwidth = GETPOST('screenwidth'); - $dol_screenheight = GETPOST('screenheight'); + $dol_screenheight = GETPOST('screenheight');*/ } } else { dol_syslog("Authentication KO - failed to load file '".$authfile."'", LOG_ERR); @@ -561,10 +561,11 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len * * @param string $htmlname HTML name of element to insert key into * @param string $htmlnameofbutton HTML name of button + * @param int $generic 1=Return a generic pass, 0=Return a pass following setup rules * @return string HTML javascript code to set a password * @see getRandomPassword() */ -function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token') +function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token', $generic = 1) { global $conf; @@ -572,10 +573,10 @@ function dolJSToSetRandomPassword($htmlname, $htmlnameofbutton = 'generate_token print "\n".' -global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { print 'global->PRODUCT_USE_UNITS)) { + if (getDolGlobalInt('PRODUCT_USE_UNITS')) { $coldisplay++; print ''; +// Vendor price ref if ($object->element == 'supplier_proposal' || $object->element == 'order_supplier' || $object->element == 'invoice_supplier' || $object->element == 'invoice_supplier_rec') { // We must have same test in printObjectLines print ''; } + +$tooltiponprice = ''; +$tooltiponpriceend = ''; +if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); + $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); + if (is_object($object->thirdparty)) { + if ($senderissupplier) { + $seller = $object->thirdparty; + $buyer = $mysoc; + } else { + $seller = $mysoc; + $buyer = $object->thirdparty; + } + + if ($mysoc->useLocalTax(1)) { + if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + if ($mysoc->useLocalTax(2)) { + if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); + } else { + $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisVendor" : "NotUsedForThisCustomer").''; + } + } + } + $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); + + $tooltiponprice = ''; + $tooltiponpriceend = ''; +} + // VAT Rate print ' @@ -344,53 +382,24 @@ if ($usemargins && isModEnabled('margin') && empty($user->socid)) { special_code == 3) { ?> '; $coldisplay++; - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - $tooltiponprice = $langs->transcountry("TotalHT", $mysoc->country_code).'='.price($line->total_ht); - $tooltiponprice .= '
'.$langs->transcountry("TotalVAT", ($senderissupplier ? $object->thirdparty->country_code : $mysoc->country_code)).'='.price($line->total_tva); - if (is_object($object->thirdparty)) { - if ($senderissupplier) { - $seller = $object->thirdparty; - $buyer = $mysoc; - } else { - $seller = $mysoc; - $buyer = $object->thirdparty; - } - - if ($mysoc->useLocalTax(1)) { - if (($seller->country_code == $buyer->country_code) || $line->total_localtax1 || $seller->useLocalTax(1)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.price($line->total_localtax1); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT1", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - if ($mysoc->useLocalTax(2)) { - if (($seller->country_code == $buyer->thirdparty->country_code) || $line->total_localtax2 || $seller->useLocalTax(2)) { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.price($line->total_localtax2); - } else { - $tooltiponprice .= '
'.$langs->transcountry("TotalLT2", $seller->country_code).'='.$langs->trans($senderissupplier ? "NotUsedForThisSupplier" : "NotUsedForThisCustomer").''; - } - } - } - $tooltiponprice .= '
'.$langs->transcountry("TotalTTC", $mysoc->country_code).'='.price($line->total_ttc); - - print ''; - } + print $tooltiponprice; print price($sign * $line->total_ht); - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { - print ''; - } + print $tooltiponpriceend; print ''; if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { print ''; $coldisplay++; } } + +// Price inc tax if ($outputalsopricetotalwithtax) { print ''; $coldisplay++; @@ -405,6 +414,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } } + // Asset info if (isModEnabled('asset') && $object->element == 'invoice_supplier') { print ''; } + // Edit picto print ''; + // Delete picto print ''; + // Move up-down picto if ($num > 1 && $conf->browser->layout != 'phone' && ($this->situation_counter == 1 || !$this->situation_cycle_ref) && empty($disablemove)) { print ''; print ''; print ''; } print ''; - print ''; print ''; - $donationstatic->id = $objp->rowid; - $donationstatic->ref = $objp->rowid; - $donationstatic->lastname = $objp->lastname; - $donationstatic->firstname = $objp->firstname; - print ""; - if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { - $company = new Societe($db); - $result = $company->fetch($objp->socid); if (!empty($objp->socid) && $company->id > 0) { - print ""; + $donationstatic->societe = $company->getNomUrl(1); + } else { + $donationstatic->societe = $objp->societe; + } + + print $donationstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; + $donationstatic->lastname = $objp->lastname; + $donationstatic->firstname = $objp->firstname; + print ""; + if (!empty($conf->global->DONATION_USE_THIRDPARTIES)) { + if (!empty($objp->socid) && $company->id > 0) { + print ""; + } else { + print ""; + } } else { print ""; } - } else { - print ""; - } - print ""; - print ''; - if (isModEnabled('project')) { - print ""; + print ''; + if (isModEnabled('project')) { + print "\n"; } - print "\n"; + print ''; + print ''; + print ''; + print ""; } - print ''; - print ''; - print ''; - print ""; $i++; } print "
'.$langs->trans('PriceUHTCurrency').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('ReductionShort').'

'; + if (!empty($value['icon'])) { + print ''; + } + print ''; + print '
'; if ($imgpreview) { diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index a0e74c5cdd5..dc82e3bf4cf 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -39,6 +39,9 @@ class FormProjets */ public $error = ''; + public $errors = array(); + + public $nboftasks; @@ -267,7 +270,7 @@ class FormProjets 'value' => $obj->ref, 'ref' => $obj->ref, 'labelx' => $labeltoshow, - 'label' => ((bool) $disabled) ? ''.$labeltoshow.'' : $labeltoshow, + 'label' => ($disabled ? ''.$labeltoshow.'' : $labeltoshow), 'disabled' => (bool) $disabled ); } @@ -622,6 +625,8 @@ class FormProjets if ($resql) { $num = $this->db->num_rows($resql); $i = 0; + $sellist = ''; + if ($num > 0) { $sellist = ''; print ajax_combobox($htmlname, array(), 0, 0, 'resolve', ($showempty < 0 ? (string) $showempty : '-1'), $morecss); diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index c57ee0c5106..40dec1870a4 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -21,7 +21,6 @@ */ class FormSetup { - /** * @var DoliDB Database handler. */ @@ -339,8 +338,8 @@ class FormSetup /** * Method used to test module builder convertion to this form usage * - * @param array $params an array of arrays of params from old modulBuilder params - * @return null + * @param array $params an array of arrays of params from old modulBuilder params + * @return void */ public function addItemsFromParamsArray($params) { @@ -662,7 +661,7 @@ class FormSetupItem { global $conf; if (isset($conf->global->{$this->confKey})) { - $this->fieldValue = $conf->global->{$this->confKey}; + $this->fieldValue = getDolGlobalString($this->confKey); return true; } else { $this->fieldValue = null; @@ -683,7 +682,8 @@ class FormSetupItem /** * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php - * @return int -1 if KO, 1 if OK + * + * @return int -1 if KO, 1 if OK */ public function saveConfValue() { @@ -714,10 +714,13 @@ class FormSetupItem return 1; } } + + return 0; } /** * Set an override function for saving data + * * @param callable $callBack a callable function * @return void */ @@ -1005,6 +1008,7 @@ class FormSetupItem * set the type from string : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist * to be sure we can manage evolution easily + * * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' * @deprecated yes this setTypeFromTypeString came deprecated because it exists only for manage setup convertion * @return bool @@ -1012,11 +1016,13 @@ class FormSetupItem public function setTypeFromTypeString($type) { $this->type = $type; + return true; } /** * Add error + * * @param array|string $errors the error text * @return null */ @@ -1034,7 +1040,9 @@ class FormSetupItem } /** - * @return bool|string Generate the output html for this item + * generateOutputField + * + * @return bool|string Generate the output html for this item */ public function generateOutputField() { @@ -1073,16 +1081,18 @@ class FormSetupItem } } } elseif (preg_match('/emailtemplate:/', $this->type)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($this->db); + if ($this->fieldValue > 0) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); - $tmp = explode(':', $this->type); + $tmp = explode(':', $this->type); - $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); - if (is_numeric($template) && $template < 0) { - $this->setErrors($formmail->errors); + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); + if (is_numeric($template) && $template < 0) { + $this->setErrors($formmail->errors); + } + $out.= $this->langs->trans($template->label); } - $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; $c = new Categorie($this->db); @@ -1108,6 +1118,7 @@ class FormSetupItem } } elseif ($this->type == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; + $product = new Product($this->db); $resprod = $product->fetch($this->fieldValue); if ($resprod > 0) { diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index f08640c6e55..28092a72da6 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -250,7 +250,7 @@ function limitChars(textarea, limit, infodiv) if ($this->withtoreadonly) { print (!is_array($this->withto) && !is_numeric($this->withto)) ? $this->withto : ""; } else { - print "withto) && $this->withto != '1' ? (isset($_REQUEST["sendto"]) ?GETPOST("sendto") : $this->withto) : "+")."\">"; + print 'withto) : "+").'">'; if (!empty($this->withtosocid) && $this->withtosocid > 0) { $liste = array(); foreach ($soc->thirdparty_and_contact_phone_array() as $key => $value) { diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 3dc618c36ab..5692a285dda 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2016 Christophe Battarel - * Copyright (C) 2019 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2021 Juanjo Menent * Copyright (C) 2021 Alexandre Spangaro * @@ -49,10 +49,15 @@ class FormTicket public $db; /** - * @var string The track_id of the ticket. Used also for the $keytoavoidconflict to name session vars to upload files. + * @var string A hash value of the ticket. Duplicate of ref but for public purposes. */ public $track_id; + /** + * @var string Email $trackid. Used also for the $keytoavoidconflict to name session vars to upload files. + */ + public $trackid; + /** * @var int ID */ @@ -89,8 +94,12 @@ class FormTicket public $withusercreate; // to show name of creating user in form public $withcreatereadonly; - public $withref; // to show ref field + /** + * @var int withextrafields + */ + public $withextrafields; + public $withref; // to show ref field public $withcancel; public $type_code; @@ -146,9 +155,10 @@ class FormTicket * @param string $mode Mode ('create' or 'edit') * @param int $public 1=If we show the form for the public interface * @param Contact|null $with_contact [=NULL] Contact to link to this ticket if exists + * @param string $action [=''] Action in card * @return void */ - public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null) + public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0, Contact $with_contact = null, $action = '') { global $conf, $langs, $user, $hookmanager; @@ -346,7 +356,7 @@ class FormTicket print $langs->trans('SubjectAnswerToTicket').' '.$this->topic_title; } else { if (isset($this->withreadid) && $this->withreadid > 0) { - $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title.''; + $subject = $langs->trans('SubjectAnswerToTicket').' '.$this->withreadid.' : '.$this->topic_title; } else { $subject = GETPOST('subject', 'alpha'); } @@ -361,7 +371,7 @@ class FormTicket print ' '; } diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index f3f28abe149..606a6640995 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -118,7 +118,7 @@ class InfoBox $sql .= " WHERE d.entity IN (0, ".$conf->entity.")"; } - dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : '')."", LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user) ? $user->id : ''), LOG_DEBUG); $resql = $dbs->query($sql); if ($resql) { $num = $dbs->num_rows($resql); diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 011d8a380ef..8b3c9177d3e 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -982,7 +982,7 @@ class Ldap * * @param string $filterrecord Record * @param string $attribute Attributes - * @return void + * @return array|boolean */ public function getAttributeValues($filterrecord, $attribute) { @@ -1025,7 +1025,7 @@ class Ldap * @param array $attributeArray Array of fields required. Note this array must also contains field $useridentifier (Ex: sn,userPassword) * @param int $activefilter '1' or 'user'=use field this->filter as filter instead of parameter $search, 'group'=use field this->filtergroup as filter, 'member'=use field this->filtermember as filter * @param array $attributeAsArray Array of fields wanted as an array not a string - * @return array Array of [id_record][ldap_field]=value + * @return array|int Array of [id_record][ldap_field]=value */ public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { @@ -1239,10 +1239,10 @@ class Ldap /** * Load all attribute of a LDAP user * - * @param User $user User to search for. Not used if a filter is provided. - * @param string $filter Filter for search. Must start with &. - * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) - * @return int >0 if OK, <0 if KO + * @param User|string $user Not used. + * @param string $filter Filter for search. Must start with &. + * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) + * @return int >0 if OK, <0 if KO */ public function fetch($user, $filter) { @@ -1291,7 +1291,6 @@ class Ldap $this->firstname = $this->convToOutputCharset($result[0][$this->attr_firstname][0], $this->ldapcharset); $this->login = $this->convToOutputCharset($result[0][$this->attr_login][0], $this->ldapcharset); $this->phone = $this->convToOutputCharset($result[0][$this->attr_phone][0], $this->ldapcharset); - $this->skype = $this->convToOutputCharset($result[0][$this->attr_skype][0], $this->ldapcharset); $this->fax = $this->convToOutputCharset($result[0][$this->attr_fax][0], $this->ldapcharset); $this->mail = $this->convToOutputCharset($result[0][$this->attr_mail][0], $this->ldapcharset); $this->mobile = $this->convToOutputCharset($result[0][$this->attr_mobile][0], $this->ldapcharset); @@ -1342,7 +1341,7 @@ class Ldap * UserAccountControl Flgs to more human understandable form... * * @param string $uacf UACF - * @return void + * @return array */ public function parseUACF($uacf) { @@ -1382,7 +1381,7 @@ class Ldap } //Return human friendly flags - return($retval); + return $retval; } /** @@ -1414,7 +1413,7 @@ class Ldap $retval = "UNKNOWN_TYPE_".$samtype; } - return($retval); + return $retval; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index bd2d6d020cd..0452cab45aa 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -703,8 +703,8 @@ class Lessc // has default value $value = $a[2]; } else { - $this->throwError("Failed to assign arg ".$a[1]); $value = null; // :( + $this->throwError("Failed to assign arg ".$a[1]); // This end function by throwing an exception } $value = $this->reduce($value); @@ -1011,6 +1011,7 @@ class Lessc if ($list[0] == "list" && isset($list[2][$idx - 1])) { return $list[2][$idx - 1]; } + return ''; } protected function lib_isnumber($value) @@ -1118,8 +1119,7 @@ class Lessc if (isset($items[0])) { return $this->lib_e($items[0]); } - $this->throwError("unrecognised input"); - return null; + $this->throwError("unrecognised input"); // This end function by throwing an exception case "string": $arg[1] = ""; return $arg; @@ -1306,6 +1306,7 @@ class Lessc if (!is_null($color = $this->coerceColor($value))) { return isset($color[4]) ? $color[4] : 1; } + return ''; } // set the alpha of the color @@ -1836,6 +1837,7 @@ class Lessc } return null; } + return null; } // make something string like into a string @@ -1931,6 +1933,8 @@ class Lessc array_unshift($strRight[2], $left); return $strRight; } + + return ''; } @@ -1954,6 +1958,8 @@ class Lessc if ($op == '+' || $op == '*') { return $this->op_color_number($op, $rgt, $lft); } + + return array(); } protected function op_color_number($op, $lft, $rgt) @@ -2756,7 +2762,7 @@ class lessc_parser // media if ($this->literal('@media')) { - if (($this->mediaQueryList($mediaQueries) || true) + if ($this->mediaQueryList($mediaQueries) && $this->literal('{') ) { $media = $this->pushSpecialBlock("media"); @@ -2770,7 +2776,7 @@ class lessc_parser if ($this->literal("@", false) && $this->keyword($dirName)) { if ($this->isDirective($dirName, $this->blockDirectives)) { - if (($this->openString("{", $dirValue, null, array(";")) || true) && + if ($this->openString("{", $dirValue, null, array(";")) && $this->literal("{") ) { $dir = $this->pushSpecialBlock("directive"); @@ -2808,7 +2814,7 @@ class lessc_parser // opening parametric mixin if ($this->tag($tag, true) && $this->argumentDef($args, $isVararg) && - ($this->guards($guards) || true) && + $this->guards($guards) && $this->literal('{') ) { $block = $this->pushBlock($this->fixTags(array($tag))); @@ -2871,8 +2877,8 @@ class lessc_parser // mixin if ($this->mixinTags($tags) && - ($this->argumentDef($argv, $isVararg) || true) && - ($this->keyword($suffix) || true) && $this->end() + $this->argumentDef($argv, $isVararg) && + $this->keyword($suffix) && $this->end() ) { $tags = $this->fixTags($tags); $this->append(array('mixin', $tags, $argv, $suffix), $s); @@ -3134,7 +3140,7 @@ class lessc_parser } // an import statement - protected function import(&$out) + protected function import(&$out, $value = '') { if (!$this->literal('@import')) { return false; @@ -3148,6 +3154,8 @@ class lessc_parser $out = array("import", $value); return true; } + + return false; } protected function mediaQueryList(&$out) @@ -3166,7 +3174,7 @@ class lessc_parser $expressions = null; $parts = array(); - if (($this->literal("only") && ($only = true) || $this->literal("not") && ($not = true) || true) && $this->keyword($mediaType)) { + if ((($this->literal("only") && ($only = true)) || ($this->literal("not") && ($not = true))) && $this->keyword($mediaType)) { $prop = array("mediaType"); if (isset($only)) { $prop[] = "only"; @@ -3205,7 +3213,7 @@ class lessc_parser $value = null; if ($this->literal("(") && $this->keyword($feature) && - ($this->literal(":") && $this->expression($value) || true) && + ($this->literal(":") && $this->expression($value)) && $this->literal(")") ) { $out = array("mediaExp", $feature); diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index caeece975f2..9544e11e075 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -647,7 +647,7 @@ class Menubase $sql .= " ORDER BY m.position, m.rowid"; //print $sql; - //dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG); + //dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu), LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $numa = $this->db->num_rows($resql); diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 2a3a2b805da..fc562913c08 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -225,7 +225,7 @@ class Notify $sql .= " AND s.rowid = ".((int) $socid); } - dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); + dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -263,7 +263,7 @@ class Notify $sql .= " AND c.rowid = ".((int) $userid); } - dol_syslog(__METHOD__." ".$notifcode.", ".$socid."", LOG_DEBUG); + dol_syslog(__METHOD__." ".$notifcode.", ".$socid, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -658,6 +658,11 @@ class Notify $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } @@ -901,6 +906,11 @@ class Notify $parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list); $reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if (empty($reshook)) { + if (!empty($hookmanager->resArray['files'])) { + $filename_list = $hookmanager->resArray['files']['file']; + $mimetype_list = $hookmanager->resArray['files']['mimefile']; + $mimefilename_list = $hookmanager->resArray['files']['filename']; + } if (!empty($hookmanager->resArray['subject'])) { $subject .= $hookmanager->resArray['subject']; } diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 79cf9137a99..7198f532358 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -178,7 +178,7 @@ class SimpleOpenID /** * SetOpenIDServer * - * @return void + * @return array */ public function GetError() { @@ -225,7 +225,7 @@ class SimpleOpenID * splitResponse * * @param string $response Server - * @return void + * @return array */ public function splitResponse($response) { diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 66e9241d9f5..da3257b09c9 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -175,7 +175,7 @@ class RssParser /** * getItems * - * @return string + * @return array */ public function getItems() { @@ -801,8 +801,8 @@ class RssParser /** * Function to convert an XML object into an array * - * @param SimpleXMLElement $xml Xml - * @return void + * @param SimpleXMLElement $xml Xml + * @return array|string */ function xml2php($xml) { diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index 990bdaf107e..60cdc5d5226 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -55,7 +55,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -156,7 +156,7 @@ abstract class Stats global $conf, $user, $langs; if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -237,7 +237,7 @@ abstract class Stats /** * @param int $year year number - * @return int value + * @return array array of values */ protected abstract function getAverageByMonth($year); @@ -251,7 +251,7 @@ abstract class Stats public function getAverageByMonthWithPrevYear($endyear, $startyear) { if ($startyear > $endyear) { - return -1; + return array(); } $datay = array(); @@ -359,7 +359,7 @@ abstract class Stats // phpcs:enable $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -388,7 +388,7 @@ abstract class Stats // phpcs:enable $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -442,7 +442,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -499,7 +499,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -557,7 +557,7 @@ abstract class Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -613,7 +613,7 @@ abstract class Stats $result = array(); - dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__FUNCTION__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 568ef7b4ace..2315428b37a 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -834,7 +834,6 @@ class Translate 'ja'=>'ja_JP', 'lo'=>'lo_LA', 'nb'=>'nb_NO', - 'fa'=>'fa_IR', 'sq'=>'sq_AL', 'sr'=>'sr_RS', 'sv'=>'sv_SE', @@ -933,8 +932,10 @@ class Translate $fonc = 'numberwords'; if (file_exists($newdir.'/functions_'.$fonc.'.lib.php')) { include_once $newdir.'/functions_'.$fonc.'.lib.php'; - $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); - break; + if (function_exists('numberwords_getLabelFromNumber')) { + $newnumber = numberwords_getLabelFromNumber($this, $number, $isamount); + break; + } } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index f8096ed84e9..0241431c8b7 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -34,6 +34,9 @@ class Utils */ public $db; + public $error; + public $errors; + public $output; // Used by Cron method to return message public $result; // Used by Cron method to return data @@ -646,12 +649,14 @@ class Utils if (!$errormsg && $keeplastnfiles > 0) { $tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC); $i = 0; - foreach ($tmpfiles as $key => $val) { - $i++; - if ($i <= $keeplastnfiles) { - continue; + if (is_array($tmpfiles)) { + foreach ($tmpfiles as $key => $val) { + $i++; + if ($i <= $keeplastnfiles) { + continue; + } + dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); } - dol_delete_file($val['fullname'], 0, 0, 0, null, false, 0); } } @@ -1290,6 +1295,7 @@ class Utils $message = dol_escape_htmltag($langs->trans('MakeSendLocalDatabaseDumpShort')); } + $tmpfiles = array(); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; if ($filename) { if (dol_is_file($conf->admin->dir_output.'/backup/'.$filename)) { @@ -1298,7 +1304,7 @@ class Utils } else { $tmpfiles = dol_most_recent_file($conf->admin->dir_output.'/backup', $filter); } - if ($tmpfiles) { + if ($tmpfiles && is_array($tmpfiles)) { foreach ($tmpfiles as $key => $val) { if ($key == 'fullname') { $filepath = array($val); diff --git a/htdocs/core/class/validate.class.php b/htdocs/core/class/validate.class.php index 9d8832c36ce..31cf6300aff 100644 --- a/htdocs/core/class/validate.class.php +++ b/htdocs/core/class/validate.class.php @@ -191,7 +191,7 @@ class Validate */ public function isMinLength($string, $length) { - if (!strlen($string) < $length) { + if (strlen($string) < $length) { $this->error = $this->outputLang->trans('RequireMinLength', $length); return false; } diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index dbe505a894b..7b5a320f678 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -31,7 +31,7 @@ */ function encode($string) { - return str_replace(";", "\;", (dol_quoted_printable_encode(utf8_decode($string)))); + return str_replace(";", "\;", (dol_quoted_printable_encode($string))); } @@ -100,14 +100,14 @@ class vCard /** * @var string encoding */ - public $encoding = "ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding = "ENCODING=QUOTED-PRINTABLE"; /** * mise en forme du numero de telephone * * @param int $number numero de telephone - * @param string $type Type + * @param string $type Type ('cell') * @return void */ public function setPhoneNumber($number, $type = "") @@ -117,22 +117,25 @@ class vCard if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; - $this->properties[$key] = encode($number); + $key .= ";VALUE=uri"; + //$key .= ";".$this->encoding; + $this->properties[$key] = 'tel:'.$number; } /** * mise en forme de la photo * warning NON TESTE ! * - * @param string $type Type + * @param string $type Type 'image/jpeg' or 'JPEG' * @param string $photo Photo * @return void */ public function setPhoto($type, $photo) { // $type = "GIF" | "JPEG" - $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); + //$this->properties["PHOTO;MEDIATYPE=$type;ENCODING=BASE64"] = base64_encode($photo); + $this->properties["PHOTO;MEDIATYPE=$type"] = $photo; // must be url of photo + //$this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); // must be content of image } /** @@ -143,7 +146,7 @@ class vCard */ public function setFormattedName($name) { - $this->properties["FN;CHARSET=".$this->encoding] = encode($name); + $this->properties["FN;".$this->encoding] = encode($name); } /** @@ -152,13 +155,14 @@ class vCard * @param string $family Family name * @param string $first First name * @param string $additional Additional (e.g. second name, nick name) - * @param string $prefix Prefix (e.g. "Mr.", "Ms.", "Prof.") + * @param string $prefix Title prefix (e.g. "Mr.", "Ms.", "Prof.") * @param string $suffix Suffix (e.g. "sen." for senior, "jun." for junior) * @return void */ public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") { - $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); + //$this->properties["N;".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); + $this->properties["N"] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); $this->filename = "$first%20$family.vcf"; if (empty($this->properties["FN"])) { $this->setFormattedName(trim("$prefix $first $additional $family $suffix")); @@ -173,12 +177,13 @@ class vCard */ public function setBirthday($date) { - // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 - $this->properties["BDAY"] = dol_print_date($date, 'dayrfc'); + // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 for vcard v3 + // $date format is YYYYMMDD or ISO8601 for vcard v4 + $this->properties["BDAY"] = dol_print_date($date, 'dayxcard'); } /** - * mise en forme de l'adresse + * Address * * @param string $postoffice Postoffice * @param string $extended Extended @@ -188,25 +193,29 @@ class vCard * @param string $zip Zip * @param string $country Country * @param string $type Type + * @param string $label Label * @return void */ - public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "", $label = "") { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; if ($type != "") { $key .= ";".$type; } - $key .= ";CHARSET=".$this->encoding; - $this->properties[$key] = ";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); + if ($label != "") { + $key .= ';LABEL="'.encode($label).'"'; + } + $key .= ";".$this->encoding; + $this->properties[$key] = encode($postoffice).";".encode($extended).";".encode($street).";".encode($city).";".encode($region).";".encode($zip).";".encode($country); - //if ($this->properties["LABEL;".$type.";CHARSET=".$this->encoding] == '') { + //if ($this->properties["LABEL;".$type.";".$this->encoding] == '') { //$this->setLabel($postoffice, $extended, $street, $city, $region, $zip, $country, $type); //} } /** - * mise en forme du label + * Address (old standard) * * @param string $postoffice Postoffice * @param string $extended Extended @@ -217,8 +226,9 @@ class vCard * @param string $country Country * @param string $type Type * @return void + * @deprecated */ - public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME") { $label = ""; if ($postoffice != "") { @@ -243,7 +253,7 @@ class vCard $country .= "$country\r\n"; } - $this->properties["LABEL;$type;CHARSET=".$this->encoding] = encode($label); + $this->properties["LABEL;$type;".$this->encoding] = encode($label); } /** @@ -253,7 +263,7 @@ class vCard * @param string $type (optional) The type of the e-mail (typical "PREF;INTERNET" or "INTERNET") * @return void */ - public function setEmail($address, $type = "TYPE=INTERNET;PREF") + public function setEmail($address, $type = "") { $key = "EMAIL"; if ($type != "") { @@ -270,7 +280,7 @@ class vCard */ public function setNote($note) { - $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note); + $this->properties["NOTE;".$this->encoding] = encode($note); } /** @@ -281,7 +291,7 @@ class vCard */ public function setTitle($title) { - $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title); + $this->properties["TITLE;".$this->encoding] = encode($title); } @@ -293,7 +303,7 @@ class vCard */ public function setOrg($org) { - $this->properties["ORG;CHARSET=".$this->encoding] = encode($org); + $this->properties["ORG;".$this->encoding] = encode($org); } @@ -305,7 +315,7 @@ class vCard */ public function setProdId($prodid) { - $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid); + $this->properties["PRODID"] = encode($prodid); } @@ -317,7 +327,7 @@ class vCard */ public function setUID($uid) { - $this->properties["UID;CHARSET=".$this->encoding] = encode($uid); + $this->properties["UID"] = encode($uid); } @@ -346,13 +356,14 @@ class vCard public function getVCard() { $text = "BEGIN:VCARD\r\n"; - $text .= "VERSION:3.0\r\n"; + $text .= "VERSION:4.0\r\n"; // With V4, all encoding are UTF-8 //$text.= "VERSION:2.1\r\n"; foreach ($this->properties as $key => $value) { - $text .= "$key:$value\r\n"; + $newkey = preg_replace('/-.*$/', '', $key); // remove suffix -twitter, -facebook, ... + $text .= $newkey.":".$value."\r\n"; } - $text .= "REV:".date("Y-m-d")."T".date("H:i:s")."Z\r\n"; - $text .= "MAILER: Dolibarr\r\n"; + $text .= "REV:".date("Ymd")."T".date("His")."Z\r\n"; + //$text .= "MAILER: Dolibarr\r\n"; $text .= "END:VCARD\r\n"; return $text; } @@ -367,6 +378,165 @@ class vCard return $this->filename; } + /** + * Return a VCARD string + * See RFC https://datatracker.ietf.org/doc/html/rfc6350 + * + * @param Object $object Object (User or Contact) + * @param Societe|null $company Company. May be null + * @param Translate $langs Lang object + * @param string $urlphoto Full public URL of photo + * @return string String + */ + public function buildVCardString($object, $company, $langs, $urlphoto = '') + { + global $dolibarr_main_instance_unique_id; + + $this->setProdId('Dolibarr '.DOL_VERSION); + + $this->setUid('DOLIBARR-USERID-'.dol_trunc(md5('vcard'.$dolibarr_main_instance_unique_id), 8, 'right', 'UTF-8', 1).'-'.$object->id); + $this->setName($object->lastname, $object->firstname, "", $object->civility_code, ""); + $this->setFormattedName($object->getFullName($langs, 1)); + + if ($urlphoto) { + $mimetype = dol_mimetype($urlphoto); + if ($mimetype) { + $this->setPhoto($mimetype, $urlphoto); + } + } + + if ($object->office_phone) { + $this->setPhoneNumber($object->office_phone, "TYPE=WORK,VOICE"); + } + /* disabled + if ($object->personal_mobile) { + $this->setPhoneNumber($object->personal_mobile, "TYPE=CELL,VOICE"); + }*/ + if ($object->user_mobile) { + $this->setPhoneNumber($object->user_mobile, "TYPE=CELL,VOICE"); + } + if ($object->office_fax) { + $this->setPhoneNumber($object->office_fax, "TYPE=WORK,FAX"); + } + + if (!empty($object->socialnetworks)) { + foreach ($object->socialnetworks as $key => $val) { + $urlsn = ''; + if ($key == 'linkedin') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/company/'.urlencode($val); + } else { + $urlsn = $val; + } + } elseif ($key == 'youtube') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/user/'.urlencode($val); + } else { + $urlsn = $val; + } + } else { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/'.urlencode($val); + } else { + $urlsn = $val; + } + } + if ($urlsn) { + $this->properties["SOCIALPROFILE;TYPE=WORK-".$key] = $key.':'.$urlsn; + } + } + } + + $country = $object->country_code ? $object->country : ''; + + if ($object->address || $object->town || $object->state || $object->zip || $object->country) { + $this->setAddress("", "", $object->address, $object->town, $object->state, $object->zip, $country, ""); + //$this->setLabel("", "", $object->address, $object->town, $object->state, $object->zip, $country, "TYPE=HOME"); + } + + if ($object->email) { + $this->setEmail($object->email, "TYPE=WORK"); + } + /* disabled + if ($object->personal_email) { + $this->setEmail($object->personal_email, "TYPE=HOME"); + } */ + if ($object->note_public) { + $this->setNote($object->note_public); + } + if ($object->job) { + $this->setTitle($object->job); + } + + // For user, $object->url is not defined + // For contact, $object->url is not defined + if (!empty($object->url)) { + $this->setURL($object->url, ""); + } + + if (is_object($company)) { + // Si user linked to a thirdparty and not a physical people + if ($company->typent_code != 'TE_PRIVATE') { + $this->setOrg($company->name); + } + + $this->setURL($company->url, ""); + + if ($company->phone && $company->phone != $object->office_phone) { + $this->setPhoneNumber($company->phone, "TYPE=WORK,VOICE"); + } + if ($company->fax && $company->fax != $object->office_fax) { + $this->setPhoneNumber($company->fax, "TYPE=WORK,FAX"); + } + if ($company->address || $company->town || $company->state || $company->zip || $company->country) { + $this->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK"); + } + + if ($company->email && $company->email != $object->email) { + $this->setEmail($company->email, "TYPE=WORK"); + } + + /* + if (!empty($company->socialnetworks)) { + foreach ($company->socialnetworks as $key => $val) { + $urlsn = ''; + if ($key == 'linkedin') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/company/'.urlencode($val); + } else { + $urlsn = $val; + } + } elseif ($key == 'youtube') { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/user/'.urlencode($val); + } else { + $urlsn = $val; + } + } else { + if (!preg_match('/^http/', $val)) { + $urlsn = 'https://www.'.$key.'.com/'.urlencode($val); + } else { + $urlsn = $val; + } + } + if ($urlsn) { + $this->properties["socialProfile;type=".$key] = $urlsn; + } + } + } + */ + } + + // Birthday + if ($object->birth) { + $this->setBirthday($object->birth); + } + + // Return VCard string + return $this->getVCard(); + } + + /* Example from Microsoft Outlook 2019 BEGIN:VCARD diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index e2659e224a4..30b3ea76975 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/db/Database.interface.php'; */ abstract class DoliDB implements Database { - /** @var bool|resource|SQLite3|PgSql\connection Database handler */ + /** @var bool|resource|mysqli|SQLite3|PgSql\connection Database handler */ public $db; /** @var string Database type */ public $type; @@ -37,8 +37,10 @@ abstract class DoliDB implements Database public $forcecharset = 'utf8'; /** @var string Collate used to force collate when creating database */ public $forcecollate = 'utf8_unicode_ci'; + /** @var resource Resultset of last query */ private $_results; + /** @var bool true if connected, else false */ public $connected; /** @var bool true if database selected, else false */ @@ -73,7 +75,8 @@ abstract class DoliDB implements Database /** - * Return the DB prefix + * Return the DB prefix found into prefix_db (if it was set manually by doing $dbhandler->prefix_db=...). + * Otherwise return MAIN_DB_PREFIX (common use). * * @return string The DB prefix */ diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 7d184dc06cf..593fa770536 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -36,10 +36,12 @@ class DoliDBMysqli extends DoliDB public $db; //! Database type public $type = 'mysqli'; + //! Database label const LABEL = 'MySQL or MariaDB'; //! Version min database const VERSIONMIN = '5.0.3'; + /** @var bool|mysqli_result Resultset of last query */ private $_results; @@ -703,7 +705,7 @@ class DoliDBMysqli extends DoliDB } $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); - $sql = "SHOW TABLES FROM ".$tmpdatabase." ".$like.";"; + $sql = "SHOW TABLES FROM `".$tmpdatabase."` ".$like.";"; //print $sql; $result = $this->query($sql); if ($result) { diff --git a/htdocs/core/doxygen.php b/htdocs/core/doxygen.php index ac66362a89f..1e66b348ef8 100644 --- a/htdocs/core/doxygen.php +++ b/htdocs/core/doxygen.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2022 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,10 +20,10 @@ /** * \file htdocs/core/doxygen.php * \ingroup core - * \mainpage Dolibarr project + * \mainpage Dolibarr documentation of source code * * This is source documentation for Dolibarr ERP/CRM.
- * This documentation can be built or updated running the script dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
+ * This documentation can be built or updated running the script build/doxygen/dolibarr-doxygen-build.pl or from Eclipse with Doxygen plugin.
*
* Dolibarr official web site: www.dolibarr.org
*
diff --git a/htdocs/core/filemanagerdol/browser/default/frmfolders.php b/htdocs/core/filemanagerdol/browser/default/frmfolders.php index d8d1fae179a..a1b03693324 100644 --- a/htdocs/core/filemanagerdol/browser/default/frmfolders.php +++ b/htdocs/core/filemanagerdol/browser/default/frmfolders.php @@ -53,7 +53,7 @@ top_httphead(); --> diff --git a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php index 608c2ba4cd6..75c4d1e3e08 100644 --- a/htdocs/core/filemanagerdol/connectors/php/connector.lib.php +++ b/htdocs/core/filemanagerdol/connectors/php/connector.lib.php @@ -343,7 +343,8 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; //var_dump($sFileName); var_dump(image_format_supported($sFileName));exit; - $isImageValid = (image_format_supported($sFileName) >= 0 ? true : false); + $imgsupported = image_format_supported($sFileName); + $isImageValid = ($imgsupported >= 0 ? true : false); if (!$isImageValid) { $sErrorNumber = '202'; } @@ -387,7 +388,7 @@ function FileUpload($resourceType, $currentFolder, $sCommand, $CKEcallback = '') if (file_exists($sFilePath)) { //previous checks failed, try once again - if (isset($isImageValid) && $isImageValid === -1 && IsImageValid($sFilePath, $sExtension) === false) { + if (isset($isImageValid) && $imgsupported === -1 && IsImageValid($sFilePath, $sExtension) === false) { dol_syslog("connector.lib.php IsImageValid is ko"); @unlink($sFilePath); $sErrorNumber = '202'; diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index 3310554e530..c037b86a7b9 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -110,6 +110,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) { console.log("toggle dropdown dt a"); //$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\'); + $(".ulselectedfields").removeClass("open"); $(this).parent().parent().find(\'dd ul\').toggleClass("open"); if ($(this).parent().parent().find(\'dd ul\').hasClass("open")) { diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 71bcc082961..92895793082 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1084,11 +1084,12 @@ function purgeSessions($mysessionid) /** * Enable a module * - * @param string $value Name of module to activate - * @param int $withdeps Activate/Disable also all dependencies - * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); + * @param string $value Name of module to activate + * @param int $withdeps Activate/Disable also all dependencies + * @param int $noconfverification Remove verification of $conf variable for module + * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added); */ -function activateModule($value, $withdeps = 1) +function activateModule($value, $withdeps = 1, $noconfverification = 0) { global $db, $langs, $conf, $mysoc; @@ -1144,8 +1145,10 @@ function activateModule($value, $withdeps = 1) } $const_name = $objMod->const_name; - if (!empty($conf->global->$const_name)) { - return $ret; + if ($noconfverification == 0) { + if (!empty($conf->global->$const_name)) { + return $ret; + } } $result = $objMod->init(); // Enable module diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 8e539fceac4..cacd22269ad 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -194,7 +194,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen $("#'.$htmlnamejquery.'").attr("data-tvatx", ui.item.tva_tx); $("#'.$htmlnamejquery.'").attr("data-default-vat-code", ui.item.default_vat_code); '; - if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { $script .= ' // For customer price when PRODUIT_CUSTOMER_PRICES_BY_QTY is on console.log("PRODUIT_CUSTOMER_PRICES_BY_QTY is on, propagate also prices by quantity into data-pbqxxx properties"); @@ -480,8 +480,11 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = ';*/ + + print '
'; + print ''; + print ''; + /*if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("UserIsNotContactOfProject")); + elseif ($disabledtask) + { + $titleassigntask = $langs->trans("AssignTaskToMe"); + if ($fuser->id != $user->id) $titleassigntask = $langs->trans("AssignTaskToUser", '...'); + + print $form->textwithpicto('',$langs->trans("TaskIsNotAssignedToUser", $titleassigntask)); + }*/ + print '
'; - $dayWorkLoad = !empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id] : 0; - if (!isset($totalforeachday[$preselectedday])) $totalforeachday[$preselectedday] = 0; + $dayWorkLoad = empty($projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]) ? 0 : $projectstatic->weekWorkLoadPerTask[$preselectedday][$lines[$i]->id]; + if (!isset($totalforeachday[$preselectedday])) { + $totalforeachday[$preselectedday] = 0; + } $totalforeachday[$preselectedday] += $dayWorkLoad; $alreadyspent = ''; @@ -2363,7 +2609,7 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks print ''; print $projectstatic->getNomUrl(1, '', 0, '', '-', 0, -1, 'nowraponall'); if (!in_array('projectlabel', $hiddenfields)) { - print '
'.dol_trunc($objp->title, 24).''; + print '
'.dol_escape_htmltag($objp->title).''; } print '
trans('Qty'); ?> '; print ''; print $langs->trans('Unit'); @@ -214,7 +216,7 @@ if ($nolinesbefore) { echo ' '; } } - echo $form->select_type_of_lines(GETPOSTISSET("type") ? GETPOST("type", 'alpha', 2) : -1, 'type', 1, 1, $forceall); + $form->select_type_of_lines(GETPOSTISSET("type") ? GETPOST("type", 'alpha', 2) : -1, 'type', 1, 1, $forceall); echo ''; } // Predefined product/service @@ -424,7 +426,7 @@ if ($nolinesbefore) { "> '; print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units"); @@ -511,7 +513,7 @@ if ((isModEnabled("service") || ($object->element == 'contrat')) && $dateSelecto print $form->selectDate($date_start, 'date_start', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); print ' '.$langs->trans('to').' '; print $form->selectDate($date_end, 'date_end', empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 0 : 1, 1, "addproduct", 1, 0); - }; + } if ($prefillDates) { echo ' '.$langs->trans('FillWithLastServiceDates').''; @@ -774,8 +776,37 @@ if (!empty($usemargins) && $user->rights->margins->creer) { // Now set the VAT var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; + + console.log("MAIN_SALETAX_AUTOSWITCH_I_CS_FOR_INDIA is on so we check if we need to autoswith the vat code"); + console.log("mysoc->country_code=country_code; ?> thirdparty->country_code=thirdparty->country_code; ?>"); + new_default_vat_code = default_vat_code; + country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code == $object->thirdparty->state_code) { + // We are in India and states are same, we revert the vat code "I-x" into "CS-x" + ?> + console.log("Countries are both IN and states are same, so we revert I into CS in default_vat_code="+default_vat_code); + new_default_vat_code = default_vat_code.replace(/^I\-/, 'C+S-'); + country_code == 'IN' && !empty($object->thirdparty) && $object->thirdparty->country_code == 'IN' && $mysoc->state_code != $object->thirdparty->state_code) { + // We are in India and states differs, we revert the vat code "CS-x" into "I-x" + ?> + console.log("Countries are both IN and states differs, so we revert CS into I in default_vat_code="+default_vat_code); + new_default_vat_code = default_vat_code.replace(/^C\+S\-/, 'I-'); + + if (new_default_vat_code != default_vat_code && jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val()) { + console.log("We found en entry into VAT with new default_vat_code, we will use it"); + stringforvatrateselection = jQuery('#tva_tx option:contains("'+new_default_vat_code+'")').val(); + } + } // Set vat rate if field is an input box $('#tva_tx').val(tva_tx); @@ -937,7 +968,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { ?> global->PRODUIT_CUSTOMER_PRICES_BY_QTY)) { + if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { ?> /* To process customer price per quantity (PRODUIT_CUSTOMER_PRICES_BY_QTY works only if combo product is not an ajax after x key pressed) */ var pbq = parseInt($('option:selected', this).attr('data-pbq')); // When select is done from HTML select @@ -996,7 +1027,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } @@ -1058,7 +1089,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } @@ -1113,7 +1144,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { }); - /* Function to set fields from choice */ + /* Function to set fields visibility after selecting a free product */ function setforfree() { console.log("objectline_create.tpl::setforfree. We show most fields"); jQuery("#idprodfournprice").val('0'); // Set cursor on not selected product @@ -1148,7 +1179,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { jQuery("#multicurrency_price_ttc").val('').hide(); jQuery("#title_up_ttc, #title_up_ttc_currency").hide(); - jQuery("#fourn_ref, #tva_tx, #title_vat").hide(); + /* jQuery("#tva_tx, #title_vat").hide(); */ /* jQuery("#title_fourn_ref").hide(); */ jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").hide(); jQuery("#buying_price").show(); diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 5520215d89a..dbc8b407fa5 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -120,7 +120,7 @@ $coldisplay++; print ''; } else { if ($senderissupplier) { - print $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); + $form->select_produits_fournisseurs(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); } else { print $form->select_produits(!empty($line->fk_product) ? $line->fk_product : 0, 'productid'); } diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index 7fe63613ea1..4640d710705 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -71,7 +71,7 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA if (in_array($object->element, array('propal', 'commande', 'facture', 'supplier_proposal', 'order_supplier', 'invoice_supplier')) && $object->status == $object::STATUS_DRAFT) { global $mysoc; - if (empty($disableedit)) { + if (empty($disableedit) && GETPOST('mode', 'aZ09') != 'vatforalllines') { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; } //print ''; @@ -111,7 +111,7 @@ print $langs->trans('ReductionShort'); if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { global $mysoc; - if (empty($disableedit)) { + if (empty($disableedit) && GETPOST('mode', 'aZ09') != 'remiseforalllines') { print 'id.'">'.img_edit($langs->trans("UpdateForAllLines"), 0, 'class="clickvatforalllines opacitymedium paddingleft cursorpointer"').''; } //print ''; diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 14197b6d052..be24a555a3c 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -255,11 +255,48 @@ if (isModEnabled('accounting') && $line->fk_accounting_account > 0) { } print ''; print ($line->ref_fourn ? $line->ref_fourn : $line->ref_supplier); print ''; $coldisplay++; @@ -276,8 +313,9 @@ if (price2num($line->total_localtax2)) { if (empty($positiverates)) { $positiverates = '0'; } +print $tooltiponprice; print vatrate($positiverates.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), '%', $line->info_bits); -//print vatrate($line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), '%', $line->info_bits); +print $tooltiponpriceend; ?> subprice); ?>marque_tx, 'MT')).'%'; ?> trans('Option'); ?> '.price($sign * $line->multicurrency_total_ht).''.price($sign * $line->total_ttc).''; $coldisplay++; @@ -434,6 +444,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin print ''; $coldisplay++; if (($line->info_bits & 2) == 2 || !empty($disableedit)) { @@ -443,6 +454,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; if (!$situationinvoicelinewithparent && empty($disableremove)) { // For situation invoice, deletion is not possible if there is a parent company. @@ -452,6 +464,7 @@ if ($this->statut == 0 && !empty($object_rights->creer) && $action != 'selectlin } print ''; $coldisplay++; diff --git a/htdocs/core/tpl/passwordforgotten.tpl.php b/htdocs/core/tpl/passwordforgotten.tpl.php index 3fdbcd14ef3..e9d7de9a1bf 100644 --- a/htdocs/core/tpl/passwordforgotten.tpl.php +++ b/htdocs/core/tpl/passwordforgotten.tpl.php @@ -76,7 +76,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -253,7 +253,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/tpl/passwordreset.tpl.php b/htdocs/core/tpl/passwordreset.tpl.php index 1f35b1a251a..e9d518dba64 100644 --- a/htdocs/core/tpl/passwordreset.tpl.php +++ b/htdocs/core/tpl/passwordreset.tpl.php @@ -77,7 +77,7 @@ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { $disablenofollow = 0; } -print top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); +top_htmlhead('', $titleofpage, 0, 0, $arrayofjs, array(), 1, $disablenofollow); $colorbackhmenu1 = '60,70,100'; // topmenu @@ -292,7 +292,7 @@ if ($mode == 'dolibarr' || !$disabled) { diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index abaadfc85a8..b6bd9bb73a8 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -90,6 +90,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } @@ -111,6 +114,9 @@ class InterfaceWorkflowManager extends DolibarrTriggers $this->error = $newobject->error; $this->errors[] = $newobject->error; } + + $object->clearObjectLinkedCache(); + return $ret; } } diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index e3f798dec62..ae53b01e19b 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -5,6 +5,7 @@ * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes + * Copyright (C) 2022 Ferran Marcet * * 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 @@ -861,6 +862,16 @@ class InterfaceActionsAuto extends DolibarrTriggers // Parameters $object->sendtoid defined by caller //$object->sendtoid=0; + } elseif ($action == 'PROJECT_CLOSE') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "projects")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + } + $object->actionmsg = $langs->transnoentities("ProjectClosedInDolibarr", $object->ref); + + $object->sendtoid = 0; } elseif ($action == 'TASK_CREATE') { // Project tasks // Load translation files required by the page @@ -920,7 +931,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->sendtoid = 0; } else { // TODO Merge all previous cases into this generic one - // $action = BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... + // $action = PASSWORD, BILL_DELETE, TICKET_CREATE, TICKET_MODIFY, TICKET_DELETE, CONTACT_SENTBYMAIL, RECRUITMENTCANDIDATURE_MODIFY, ... // Can also be a value defined by an external module like SENTBYSMS, COMPANY_SENTBYSMS, MEMBER_SENTBYSMS, ... // Note: We are here only if $conf->global->MAIN_AGENDA_ACTIONAUTO_action is on (tested at begining of this function). // Note that these key can be set in agenda setup, only if defined into llx_c_action_trigger diff --git a/htdocs/core/website.inc.php b/htdocs/core/website.inc.php index 2bdc9080b78..82fcabd557b 100644 --- a/htdocs/core/website.inc.php +++ b/htdocs/core/website.inc.php @@ -112,7 +112,7 @@ if (!defined('USEDOLIBARRSERVER') && !defined('USEDOLIBARREDITOR')) { // The constant WEBSITE_MAIN_SECURITY_FORCECSP should never be defined by page, but the variable used just after may be // A default security policy that keep usage of js external component like ckeditor, stripe, google, working - // $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-src 'self' *.stripe.com; connect-src 'self';"; + // $contentsecuritypolicy = "font-src *; img-src *; style-src * 'unsafe-inline' 'unsafe-eval'; default-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; script-src 'self' *.stripe.com 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self'; frame-src 'self' *.stripe.com; connect-src 'self';"; $contentsecuritypolicy = getDolGlobalString('WEBSITE_MAIN_SECURITY_FORCECSP'); if (!is_object($hookmanager)) { diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index d26c83f4772..b12a2b909cf 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -368,15 +368,15 @@ class Cronjob extends CommonObject $sql .= " ".(!isset($this->datelastresult) || dol_strlen($this->datelastresult) == 0 ? 'NULL' : "'".$this->db->idate($this->datelastresult)."'").","; $sql .= " ".(!isset($this->lastoutput) ? 'NULL' : "'".$this->db->escape($this->lastoutput)."'").","; $sql .= " ".(!isset($this->unitfrequency) ? 'NULL' : "'".$this->db->escape($this->unitfrequency)."'").","; - $sql .= " ".(!isset($this->frequency) ? '0' : $this->frequency).","; - $sql .= " ".(!isset($this->status) ? '0' : $this->status).","; - $sql .= " ".$user->id.","; - $sql .= " ".$user->id.","; + $sql .= " ".(!isset($this->frequency) ? '0' : ((int) $this->frequency)).","; + $sql .= " ".(!isset($this->status) ? '0' : ((int) $this->status)).","; + $sql .= " ".((int) $user->id).","; + $sql .= " ".((int) $user->id).","; $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'").","; - $sql .= " ".(!isset($this->nbrun) ? '0' : $this->db->escape($this->nbrun)).","; - $sql .= " ".(empty($this->maxrun) ? '0' : $this->db->escape($this->maxrun)).","; + $sql .= " ".(!isset($this->nbrun) ? '0' : ((int) $this->nbrun)).","; + $sql .= " ".(empty($this->maxrun) ? '0' : ((int) $this->maxrun)).","; $sql .= " ".(!isset($this->libname) ? 'NULL' : "'".$this->db->escape($this->libname)."'").","; - $sql .= " ".(!isset($this->test) ? 'NULL' : "'".$this->db->escape($this->test)."'").""; + $sql .= " ".(!isset($this->test) ? 'NULL' : "'".$this->db->escape($this->test)."'"); $sql .= ")"; $this->db->begin(); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 30f195b550b..aaccb39e68e 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -448,7 +448,7 @@ print '  '; -print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); +print $form->selectarray('search_status', array('0'=>$langs->trans("Disabled"), '1'=>$langs->trans("Scheduled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index ac360674c85..768ddd216d7 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -82,11 +82,11 @@ class ActionsDatapolicy /** * Overloading the doActions function : replacing the parent's function with the one below * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code + * @param array $parameters Hook metadatas (context, etc...) + * @param Societe|CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code */ public function doActions($parameters, &$object, &$action, $hookmanager) { @@ -103,7 +103,6 @@ class ActionsDatapolicy // on verifie si l'objet est utilisé if ($object->isObjectUsed(GETPOST('socid'))) { $object->name = $langs->trans('ANONYME'); - $object->name_bis = ''; $object->name_alias = ''; $object->address = ''; $object->town = ''; @@ -115,7 +114,7 @@ class ActionsDatapolicy $object->state = ''; $object->country = ''; $object->state_id = ''; - $object->skype = ''; + $object->socialnetworks = ''; $object->country_id = ''; $object->note_private = $object->note_private.'
'.$langs->trans('ANONYMISER_AT', dol_print_date(time())); @@ -128,76 +127,6 @@ class ActionsDatapolicy header('Location:'.$_SERVER["PHP_SELF"]."?socid=".$object->id); } } - } elseif ($parameters['currentcontext'] == 'thirdpartycard' && $action == 'datapolicy_portabilite') { - header('Content-Type: application/csv'); - header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); - header('Pragma: no-cache'); - $object->fetch(GETPOST('socid')); - echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; - echo $object->name.';'; - echo ';'; - echo ';'; - echo ';'; - echo ';'; - echo $object->address.';'; - echo $object->zip.';'; - echo $object->town.';'; - echo $object->state.';'; - echo $object->country.';'; - echo $object->email.';'; - echo $object->phone.';'; - echo ';'; - echo ';'; - echo $object->skype.';'; - echo ';'; - exit; - } elseif ($parameters['currentcontext'] == 'membercard' && $action == 'datapolicy_portabilite') { - header('Content-Type: application/csv'); - header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); - header('Pragma: no-cache'); - $soc = $object->fetch_thirdparty(); - - echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; - echo $object->lastname.';'; - echo $object->firstname.';'; - echo $object->getCivilityLabel().';'; - echo ($soc != -1 ? $object->thirdparty->name : '').';'; - echo ';'; - echo $object->address.';'; - echo $object->zip.';'; - echo $object->town.';'; - echo $object->state.';'; - echo $object->country.';'; - echo $object->email.';'; - echo $object->phone.';'; - echo $object->phone_perso.';'; - echo $object->phone_mobile.';'; - echo $object->skype.';'; - echo dol_print_date($object->birth).';'; - exit; - } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'datapolicy_portabilite') { - $object->fetch(GETPOST('id')); - header('Content-Type: application/csv'); - header('Content-Disposition: attachment; filename=datapolicy_portabilite.csv'); - header('Pragma: no-cache'); - $soc = $object->fetch_thirdparty(); - echo 'Name;Firstname;Civility;Thirdparty;Function;Address;ZipCode;City;Department;Country;Email;Pro Phone;Perso Phone;Mobile Phone;Instant Mail;Birthday;'.PHP_EOL; - echo $object->lastname.';'; - echo $object->firstname.';'; - echo $object->getCivilityLabel().';'; - echo ($soc != -1 ? $object->thirdparty->name : '').';'; - echo $object->poste.';'; - echo $object->address.';'; - echo $object->zip.';'; - echo $object->town.';'; - echo $object->state.';'; - echo $object->country.';'; - echo $object->email.';'; - echo $object->phone_pro.';'; - echo $object->phone_perso.';'; - echo $object->phone_mobile.';'; - echo dol_print_date($object->birth).';'; - exit; } elseif ($parameters['currentcontext'] == 'contactcard' && $action == 'send_datapolicy') { $object->fetch(GETPOST('id')); @@ -358,13 +287,7 @@ class ActionsDatapolicy } ); '; echo $dialog; - if ($parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) { - echo ''; - } elseif ($parameters['currentcontext'] == 'membercard') { - echo ''; - } elseif ($parameters['currentcontext'] == 'contactcard') { - echo ''; - } + // TODO Replace test of hardcoded values if (!empty($object->mail) && empty($object->array_options['options_datapolicy_send']) && $parameters['currentcontext'] == 'thirdpartycard' && in_array($object->forme_juridique_code, array(11, 12, 13, 15, 17, 18, 19, 35, 60, 200, 311, 312, 316, 401, 600, 700, 1005)) || $object->typent_id == 8) { echo ''; } elseif (!empty($object->mail) && empty($object->array_options['options_datapolicy_send']) && $parameters['currentcontext'] == 'membercard') { diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index a4c98eba8a7..a0375210271 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -143,12 +143,14 @@ class CdavLib $location = trim($location.', '.$obj->soc_country_label); } + /* $address = explode("\n", $obj->address, 2); foreach ($address as $kAddr => $vAddr) { $address[$kAddr] = trim(str_replace(array("\r", "\t"), ' ', str_replace("\n", ' | ', trim($vAddr)))); } $address[] = ''; $address[] = ''; + */ if ($obj->percent == -1 && trim($obj->datep) != '') { $type = 'VEVENT'; @@ -249,7 +251,7 @@ class CdavLib */ public function getFullCalendarObjects($calendarId, $bCalendarData) { - $calid = ($calendarId * 1); + $calid = (int) $calendarId; $calevents = array(); if (!$this->user->rights->agenda->myactions->read) { diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index 7abe3f2bacf..af23fde5fff 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -92,8 +92,7 @@ $tmpDir = $conf->dav->multidir_output[$entity]; // We need root dir, not a dir t // Authentication callback function $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) { - global $user; - global $conf; + global $user, $conf; global $dolibarr_main_authentication, $dolibarr_auto_user; if (empty($user->login)) { @@ -101,7 +100,7 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p return false; } if ($user->socid > 0) { - dol_syslog("Failed to authenticate to DAV, use is an external user", LOG_WARNING); + dol_syslog("Failed to authenticate to DAV, user is an external user", LOG_WARNING); return false; } if ($user->login != $username) { @@ -132,6 +131,27 @@ $authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $p return false; } + // Check if user status is enabled + if ($user->statut != $user::STATUS_ENABLED) { + // Status is disabled + dol_syslog("The user has been disabled."); + return false; + } + + // Check if session was unvalidated by a password change + if (($user->flagdelsessionsbefore && !empty($_SESSION["dol_logindate"]) && $user->flagdelsessionsbefore > $_SESSION["dol_logindate"])) { + // Session is no more valid + dol_syslog("The user has a date for session invalidation = ".$user->flagdelsessionsbefore." and a session date = ".$_SESSION["dol_logindate"].". We must invalidate its sessions."); + return false; + } + + // Check date validity + if ($user->isNotIntoValidityDateRange()) { + // User validity dates are no more valid + dol_syslog("The user login has a validity between [".$user->datestartvalidity." and ".$user->dateendvalidity."], curren date is ".dol_now()); + return false; + } + return true; }); diff --git a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php index 715d20abcf9..0920b140dbc 100644 --- a/htdocs/debugbar/class/DataCollector/DolConfigCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolConfigCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolConfigCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\ConfigCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php index 15d433fd050..38d2b971dde 100644 --- a/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolExceptionsCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolexceptionsCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\ExceptionsCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index d21cdd6233f..3d3b3b25a0e 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolLogsCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\MessagesCollector; use Psr\Log\LogLevel; @@ -20,6 +41,11 @@ class DolLogsCollector extends MessagesCollector */ protected $maxnboflines; + /** + * @var int number of lines + */ + protected $nboflines; + /** * Constructor * @@ -33,7 +59,7 @@ class DolLogsCollector extends MessagesCollector parent::__construct($name); $this->nboflines = 0; - $this->maxnboflines = empty($conf->global->DEBUGBAR_LOGS_LINES_NUMBER) ? 250 : $conf->global->DEBUGBAR_LOGS_LINES_NUMBER; // High number slows seriously output + $this->maxnboflines = getDolGlobalInt('DEBUGBAR_LOGS_LINES_NUMBER', 250); // High number slows seriously output $this->path = $path ?: $this->getLogsFile(); } diff --git a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php index b52ac8ff8c4..3372e89c2b6 100644 --- a/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolMemoryCollector.php @@ -1,17 +1,37 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolMemoryCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\MemoryCollector; /** * DolMemoryCollector class */ - class DolMemoryCollector extends MemoryCollector { /** * Return value of indicator * - * @return void + * @return array */ public function collect() { @@ -28,7 +48,7 @@ class DolMemoryCollector extends MemoryCollector /** * Return widget settings * - * @return void + * @return array */ public function getWidgets() { diff --git a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php index 1fcf60c8ba6..733009e77c6 100644 --- a/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolMessagesCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolMessagesCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\MessagesCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php index 3d6536bd258..bca2b2a7071 100644 --- a/htdocs/debugbar/class/DataCollector/DolPhpCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolPhpCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolPhpCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\DataCollector; use DebugBar\DataCollector\Renderable; diff --git a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php index ca5aa284dd2..8cc55e34df9 100644 --- a/htdocs/debugbar/class/DataCollector/DolQueryCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolQueryCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolQueryCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php index 938643802d5..4ddcac9af7c 100644 --- a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\RequestDataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php index ed5e979d539..d16622d329f 100644 --- a/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolTimeDataCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use \DebugBar\DataCollector\TimeDataCollector; diff --git a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php index 3193fe26176..11cedbe2b93 100644 --- a/htdocs/debugbar/class/DataCollector/DolibarrCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolibarrCollector.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/DolibarrCollector.php + * \brief Class for debugbar collection + * \ingroup debugbar + */ use DebugBar\DataCollector\AssetProvider; use DebugBar\DataCollector\DataCollector; diff --git a/htdocs/debugbar/class/DebugBar.php b/htdocs/debugbar/class/DebugBar.php index b2ec0f17bf0..6181ad7cd60 100644 --- a/htdocs/debugbar/class/DebugBar.php +++ b/htdocs/debugbar/class/DebugBar.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DebugBar.php + * \brief Class for debugbar + * \ingroup debugbar + */ dol_include_once('/debugbar/class/autoloader.php'); @@ -55,9 +76,10 @@ class DolibarrDebugBar extends DebugBar public function getRenderer() { $renderer = parent::getJavascriptRenderer(DOL_URL_ROOT.'/includes/maximebf/debugbar/src/DebugBar/Resources'); - //$renderer->disableVendor('jquery'); - $renderer->disableVendor('fontawesome'); - $renderer->disableVendor('highlightjs'); + $renderer->disableVendor('jquery'); // We already have jquery loaded globally by the main.inc.php + $renderer->disableVendor('fontawesome'); // We already have fontawesome loaded globally by the main.inc.php + $renderer->disableVendor('highlightjs'); // We don't need this + $renderer->setEnableJqueryNoConflict(false); // We don't need no conflict return $renderer; } } diff --git a/htdocs/debugbar/class/TraceableDB.php b/htdocs/debugbar/class/TraceableDB.php index a5f76f71aa7..8e28b0c59bd 100644 --- a/htdocs/debugbar/class/TraceableDB.php +++ b/htdocs/debugbar/class/TraceableDB.php @@ -1,4 +1,25 @@ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/debugbar/class/DataCollector/TraceableDB.php + * \brief Class for debugbar DB + * \ingroup debugbar + */ require_once DOL_DOCUMENT_ROOT.'/core/db/DoliDB.class.php'; @@ -649,7 +670,7 @@ class TraceableDB extends DoliDB */ public function free($resultset = null) { - return $this->db->free($resultset); + $this->db->free($resultset); } /** diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index b98b75015ab..fe2aff8e4c3 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; if (isModEnabled("product") || isModEnabled("service")) { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; } -if (!empty($conf->expedition_bon->enabled)) { +if (isModEnabled('expedition_bon')) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; } if (isModEnabled('stock')) { @@ -338,7 +338,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 73fc15e6911..3b560ce1026 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -1085,18 +1085,18 @@ class Delivery extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'delivery' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/document.php b/htdocs/document.php index 4f6652fafda..eccf49de0be 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -286,9 +286,10 @@ $hookmanager->initHooks(array('document')); $parameters = array('ecmfile' => $ecmfile, 'modulepart' => $modulepart, 'original_file' => $original_file, 'entity' => $entity, 'refname' => $refname, 'fullpath_original_file' => $fullpath_original_file, 'filename' => $filename, 'fullpath_original_file_osencoded' => $fullpath_original_file_osencoded); -$reshook = $hookmanager->executeHooks('downloadDocument', $parameters); // Note that $action and $object may have been +$object = new stdClass(); +$reshook = $hookmanager->executeHooks('downloadDocument', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { - $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join($separator, $hookmanager->errors) : ''); + $errors = $hookmanager->error.(is_array($hookmanager->errors) ? (!empty($hookmanager->error) ? ', ' : '').join(', ', $hookmanager->errors) : ''); dol_syslog("document.php - Errors when executing the hook 'downloadDocument' : ".$errors); print "ErrorDownloadDocumentHooks: ".$errors; exit; diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 459c892a1d9..a077c703fda 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -52,7 +52,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); - +$socid = GETPOST('socid', 'int'); $amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT'); $donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0); @@ -63,6 +63,13 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } +if (!empty($socid) && $socid > 0) { + $soc = new Societe($db); + if ($socid > 0) { + $soc->fetch($socid); + } +} + $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -729,7 +736,7 @@ if (!empty($id) && $action != 'edit') { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index b52e0974b9a..716e3728b57 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -206,7 +206,7 @@ class Don extends CommonObject */ public function initAsSpecimen() { - global $conf, $user, $langs; + global $conf; $now = dol_now(); @@ -224,10 +224,10 @@ class Don extends CommonObject $num_socs = $this->db->num_rows($resql); $i = 0; while ($i < $num_socs) { - $i++; - $row = $this->db->fetch_row($resql); $socids[$i] = $row[0]; + + $i++; } } @@ -237,7 +237,7 @@ class Don extends CommonObject $this->specimen = 1; $this->lastname = 'Doe'; $this->firstname = 'John'; - $this->socid = 1; + $this->socid = empty($socids[0]) ? 0 : $socids[0]; $this->date = $now; $this->date_valid = $now; $this->amount = 100.90; @@ -772,7 +772,7 @@ class Don extends CommonObject */ public function setPaid($id, $modepayment = 0) { - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2, paid = 1"; if ($modepayment) { $sql .= ", fk_payment = ".((int) $modepayment); } @@ -782,6 +782,7 @@ class Don extends CommonObject if ($resql) { if ($this->db->affected_rows($resql)) { $this->statut = 2; + $this->paid = 1; return 1; } else { return 0; @@ -1101,18 +1102,18 @@ class Don extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'don' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -1141,4 +1142,40 @@ class Don extends CommonObject return (float) $this->amount - $sum_amount; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'date')) { + $return .= ' | '.$langs->trans("Date").' : '.dol_print_date($this->date).''; + } + if (property_exists($this, 'societe') && !empty($this->societe)) { + $return .= '
'.$langs->trans("Company").' : '.$this->societe.''; + } + if (property_exists($this, 'amount')) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'LibStatut')) { + $return .= '
'.$this->LibStatut($this->labelStatus, 5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 07eb6d6588e..bd52f10dbc4 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -68,10 +68,11 @@ class DonationStats extends Stats */ public function __construct($db, $socid, $mode, $userid = 0) { - global $user, $conf; + global $conf; $this->db = $db; + $this->field = 'amount'; $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; $this->cachefilesuffix = $mode; @@ -98,8 +99,6 @@ class DonationStats extends Stats */ public function getNbByMonth($year, $format = 0) { - global $user; - $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; $sql .= " FROM ".$this->from; $sql .= " WHERE d.datedon BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; @@ -119,8 +118,6 @@ class DonationStats extends Stats */ public function getNbByYear() { - global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; @@ -130,6 +127,45 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } + /** + * Return the number of subscriptions by month for a given year + * + * @param int $year Year + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array of amount each month + */ + public function getAmountByMonth($year, $format = 0) + { + $sql = "SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.")"; + $sql .= " FROM ".$this->from; + //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAmountByMonth($year, $sql, $format); + } + + /** + * Return average amount each month + * + * @param int $year Year + * @return array Array of average each month + */ + public function getAverageByMonth($year) + { + $sql = "SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.")"; + $sql .= " FROM ".$this->from; + //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); + $sql .= " AND ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } + /** * Return nb, total and average * @@ -137,8 +173,6 @@ class DonationStats extends Stats */ public function getAllByYear() { - global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; $sql .= " FROM ".$this->from; $sql .= " WHERE ".$this->where; diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index b42f5fb4e4d..657a1d32d1a 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -347,7 +347,7 @@ class PaymentDonation extends CommonObject $sql .= " note=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null"); $sql .= " WHERE rowid=".(int) $this->id; $this->db->begin(); diff --git a/htdocs/don/document.php b/htdocs/don/document.php index a5aa3984202..786371bcdd3 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -146,7 +146,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/don/info.php b/htdocs/don/info.php index ad67cceb30c..75efd9f73f5 100644 --- a/htdocs/don/info.php +++ b/htdocs/don/info.php @@ -102,7 +102,7 @@ if (isModEnabled('project')) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/don/list.php b/htdocs/don/list.php index ac704571daa..eb487be4768 100644 --- a/htdocs/don/list.php +++ b/htdocs/don/list.php @@ -42,6 +42,7 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $type = GETPOST('type', 'aZ'); +$mode = GETPOST('mode', 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -59,6 +60,7 @@ $search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_ $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST('search_ref', 'alpha'); $search_company = GETPOST('search_company', 'alpha'); +$search_thirdparty = GETPOST('search_thirdparty', 'alpha'); $search_name = GETPOST('search_name', 'alpha'); $search_amount = GETPOST('search_amount', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); @@ -71,6 +73,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_all = ""; $search_ref = ""; $search_company = ""; + $search_thirdparty = ""; $search_name = ""; $search_amount = ""; $search_status = ''; @@ -153,6 +156,9 @@ if ($resql) { $i = 0; $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -179,6 +185,8 @@ if ($resql) { } $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); if ($user->rights->don->creer) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create'); } @@ -193,6 +201,9 @@ if ($resql) { print ''; print ''; print ''; + print ''; + + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -232,14 +243,14 @@ if ($resql) { print '
'; + print ''; $liststatus = array( Don::STATUS_DRAFT=>$langs->trans("DonationStatusPromiseNotValidated"), Don::STATUS_VALIDATED=>$langs->trans("DonationStatusPromiseValidated"), Don::STATUS_PAID=>$langs->trans("DonationStatusPaid"), Don::STATUS_CANCELED=>$langs->trans("Canceled") ); - print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'maxwidth100 onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, -4, 0, 0, '', 0, 0, 0, '', 'search_status maxwidth100 onrightofpage'); print ''; $searchpicto = $form->showFilterAndCheckAddButtons(0); @@ -267,44 +278,70 @@ if ($resql) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); + $donationstatic->setVarsFromFetchObj($objp); + $company = new Societe($db); + $result = $company->fetch($objp->socid); + + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + $donationstatic->amount = $objp->amount; + $donationstatic->date = $objp->datedon; + $donationstatic->labelStatus = $objp->status; + $donationstatic->id = $objp->rowid; + $donationstatic->ref = $objp->rowid; - print '
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."
".$donationstatic->getNomUrl(1)."".$company->getNomUrl(1)."".$objp->societe."".$objp->societe."".$objp->societe."".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon), 'day').'"; - if ($objp->pid) { - $projectstatic->id = $objp->pid; - $projectstatic->ref = $objp->ref; - $projectstatic->id = $objp->pid; - $projectstatic->public = $objp->public; - $projectstatic->title = $objp->title; - print $projectstatic->getNomUrl(1); - } else { - print ' '; + print "".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon), 'day').'"; + if ($objp->pid) { + $projectstatic->id = $objp->pid; + $projectstatic->ref = $objp->ref; + $projectstatic->id = $objp->pid; + $projectstatic->public = $objp->public; + $projectstatic->title = $objp->title; + print $projectstatic->getNomUrl(1); + } else { + print ' '; + } + print "'.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
'.price($objp->amount).''.$donationstatic->LibStatut($objp->status, 5).'
"; diff --git a/htdocs/don/note.php b/htdocs/don/note.php index dd3f4e176ce..14011000267 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -121,7 +121,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 19f40bc984e..416e848d271 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -181,7 +181,7 @@ if ($resql) { // Expected to pay print '
'.price($objp->d_amount).''.$don->getLibStatut(4, $objp->amount).''.$don->getLibStatut(4).''.price($objp->amount).'
'; print ''; print ''; -print ''; +print ''; /*print ''; print '';*/ print ''; @@ -334,7 +334,7 @@ print '
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").''.$langs->trans("NbOfDonations").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'; */ print '
'; -print ''.$langs->trans("StatsOnShipmentsOnlyValidated").''; +print ''.$langs->trans("StatsOnDonationsOnlyValidated").''; llxFooter(); diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index ab7b13aba90..cf1a570f04f 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -240,12 +240,9 @@ class EcmFiles extends CommonObject } // If ref not defined - $ref = ''; - if (!empty($this->ref)) { - $ref = $this->ref; - } else { + if (empty($this->ref)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; - $ref = dol_hash($this->filepath.'/'.$this->filename, 3); + $this->ref = dol_hash($this->filepath.'/'.$this->filename, 3); } $maxposition = 0; @@ -300,7 +297,7 @@ class EcmFiles extends CommonObject $sql .= 'src_object_type,'; $sql .= 'src_object_id'; $sql .= ') VALUES ('; - $sql .= " '".$this->db->escape($ref)."', "; + $sql .= " '".$this->db->escape($this->ref)."', "; $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; $sql .= ' '.(!isset($this->share) ? 'NULL' : "'".$this->db->escape($this->share)."'").','; $sql .= ' '.((int) $this->entity).','; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 9eb512bc96d..6edf59dcbed 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -322,7 +322,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index', '', -1, ''); diff --git a/htdocs/ecm/index_auto.php b/htdocs/ecm/index_auto.php index 342d7d74129..3944e869da0 100644 --- a/htdocs/ecm/index_auto.php +++ b/htdocs/ecm/index_auto.php @@ -309,7 +309,7 @@ llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $m // Add sections to manage $rowspan = 0; $sectionauto = array(); -if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { +if (empty($conf->global->ECM_AUTO_TREE_HIDEN)) { if (isModEnabled("product") || isModEnabled("service")) { $langs->load("products"); $rowspan++; $sectionauto[] = array('position'=>10, 'level'=>1, 'module'=>'product', 'test'=>(isModEnabled("product") || isModEnabled("service")), 'label'=>$langs->trans("ProductsAndServices"), 'desc'=>$langs->trans("ECMDocsByProducts")); @@ -387,7 +387,7 @@ if (!empty($conf->global->ECM_AUTO_TREE_ENABLED)) { } } -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_auto', '', -1, ''); diff --git a/htdocs/ecm/index_medias.php b/htdocs/ecm/index_medias.php index 2e1edcdc269..39118774430 100644 --- a/htdocs/ecm/index_medias.php +++ b/htdocs/ecm/index_medias.php @@ -295,7 +295,7 @@ $moreheadjs .= ''."\n"; llxHeader($moreheadcss.$moreheadjs, $langs->trans("ECMArea"), '', '', '', '', $morejs, '', 0, 0); -$head = ecm_prepare_dasboard_head(''); +$head = ecm_prepare_dasboard_head(null); print dol_get_fiche_head($head, 'index_medias', '', -1, ''); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index e37a1ce88f3..c43428fae8e 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -175,7 +175,7 @@ print load_fiche_titre($langs->trans("ECMArea").' - '.$langs->trans("Search")); print $langs->trans("FeatureNotYetAvailable").'.

'; // Tool bar -$head = ecm_prepare_head_fm($ecmdir, $module, $section); +$head = ecm_prepare_head_fm($ecmdir); //print dol_get_fiche_head($head, 'search_form', '', 1); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 28dbc0835e7..69d1ea61a30 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -128,7 +128,7 @@ class EmailCollector extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), - 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax150'), + 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'help'=>'Example: MyCollector1', 'csslist'=>'tdoverflowmax200'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>-1, 'searchall'=>1, 'help'=>'Example: My Email collector', 'csslist'=>'tdoverflowmax150'), 'description' => array('type'=>'text', 'label'=>'Description', 'visible'=>-1, 'enabled'=>1, 'position'=>60, 'notnull'=>-1, 'csslist'=>'small'), 'host' => array('type'=>'varchar(255)', 'label'=>'EMailHost', 'visible'=>1, 'enabled'=>1, 'position'=>90, 'notnull'=>1, 'searchall'=>1, 'comment'=>"IMAP server", 'help'=>'Example: imap.gmail.com', 'csslist'=>'tdoverflowmax125'), @@ -145,7 +145,7 @@ class EmailCollector extends CommonObject 'maxemailpercollect' => array('type'=>'integer', 'label'=>'MaxEmailCollectPerCollect', 'visible'=>-1, 'enabled'=>1, 'position'=>111, 'default'=>100), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastCollectResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'csslist'=>'small'), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1, 'csslist'=>'small tdoverflowmax200'), 'datelastok' => array('type'=>'datetime', 'label'=>'DateLastcollectResultOk', 'visible'=>1, 'enabled'=>'$action != "create"', 'position'=>125, 'notnull'=>-1, 'csslist'=>'nowraponall'), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), @@ -1518,7 +1518,7 @@ class EmailCollector extends CommonObject $trackidfoundintorecipientid = 0; $reg = array(); // See also later list of all supported tags... - if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|job|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { + if (preg_match('/\+(thi|ctc|use|mem|sub|proj|tas|con|tic|pro|ord|inv|spro|sor|sin|leav|stockinv|job|surv|salary)([0-9]+)@/', $emailto, $reg)) { $trackidfoundintorecipienttype = $reg[1]; $trackidfoundintorecipientid = $reg[2]; } elseif (preg_match('/\+emailing-(\w+)@/', $emailto, $reg)) { // Can be 'emailing-test' or 'emailing-IdMailing-IdRecipient' @@ -2158,6 +2158,118 @@ class EmailCollector extends CommonObject } } } + } elseif ($operation['type'] == 'loadandcreatecontact') { // Search and create contact + if (empty($operation['actionparam'])) { + $errorforactions++; + $this->error = "Action loadandcreatecontact has empty parameter. Must be 'SET:xxx' or 'EXTRACT:(body|subject):regex' to define how to extract data"; + $this->errors[] = $this->error; + } else { + $contact_static = new Contact($this->db); + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($contact_static, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + if ($errorforthisaction) { + $errorforactions++; + } else { + if (!empty($contact_static->email) && $contact_static->email != $from) $from = $contact_static->email; + + $result = $contactstatic->fetch(0, null, '', $from); + if ($result < 0) { + $errorforactions++; + $this->error = 'Error when getting contact with email ' . $from; + $this->errors[] = $this->error; + break; + } elseif ($result == 0) { + dol_syslog("Contact with email " . $from . " was not found. We try to create it."); + $contactstatic = new Contact($this->db); + + // Create contact + $contactstatic->email = $from; + $operationslog .= '
We set property email='.dol_escape_htmltag($from); + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($contactstatic, $operation['actionparam'], $messagetext, $subject, $header, $operationslog); + + if ($errorforthisaction) { + $errorforactions++; + } else { + // Search country by name or code + if (!empty($contactstatic->country)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $result = getCountry('', 3, $this->db, '', 1, $contactstatic->country); + if ($result == 'NotDefined') { + $errorforactions++; + $this->error = "Error country not found by this name '" . $contactstatic->country . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search country by this name '" . $contactstatic->country . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->country_id = $result; + $operationslog .= '
We set property country_id='.dol_escape_htmltag($result); + } + } elseif (!empty($contactstatic->country_code)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php'; + $result = getCountry($contactstatic->country_code, 3, $this->db); + if ($result == 'NotDefined') { + $errorforactions++; + $this->error = "Error country not found by this code '" . $contactstatic->country_code . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search country by this code '" . $contactstatic->country_code . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->country_id = $result; + $operationslog .= '
We set property country_id='.dol_escape_htmltag($result); + } + } + + if (!$errorforactions) { + // Search state by name or code (for country if defined) + if (!empty($contactstatic->state)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + $result = dol_getIdFromCode($this->db, $contactstatic->state, 'c_departements', 'nom', 'rowid'); + if (empty($result)) { + $errorforactions++; + $this->error = "Error state not found by this name '" . $contactstatic->state . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search state by this name '" . $contactstatic->state . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->state_id = $result; + $operationslog .= '
We set property state_id='.dol_escape_htmltag($result); + } + } elseif (!empty($contactstatic->state_code)) { + require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; + $result = dol_getIdFromCode($this->db, $contactstatic->state_code, 'c_departements', 'code_departement', 'rowid'); + if (empty($result)) { + $errorforactions++; + $this->error = "Error state not found by this code '" . $contactstatic->state_code . "'"; + } elseif (!($result > 0)) { + $errorforactions++; + $this->error = "Error when search state by this code '" . $contactstatic->state_code . "'"; + $this->errors[] = $this->db->lasterror(); + } else { + $contactstatic->state_id = $result; + $operationslog .= '
We set property state_id='.dol_escape_htmltag($result); + } + } + } + + if (!$errorforactions) { + $result = $contactstatic->create($user); + if ($result <= 0) { + $errorforactions++; + $this->error = $contactstatic->error; + $this->errors = $contactstatic->errors; + } else { + $operationslog .= '
Contact created -> id = '.dol_escape_htmltag($contactstatic->id); + } + } + } + } + } + } } elseif ($operation['type'] == 'recordevent') { // Create event $actioncomm = new ActionComm($this->db); @@ -2277,7 +2389,7 @@ class EmailCollector extends CommonObject 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentjobposition.class.php', 'object' => 'RecruitmentJobPosition'), - 'recruitment/recruitmentjobposition' => array('table' => 'recruitment_recruitmentcandidature', + 'recruitment/recruitmentcandidature' => array('table' => 'recruitment_recruitmentcandidature', 'fields' => array('ref'), 'class' => 'recruitment/class/recruitmentcandidature.class.php', 'object' => ' RecruitmentCandidature'), @@ -2322,7 +2434,7 @@ class EmailCollector extends CommonObject 'class' => 'compta/facture/class/facture.class.php', 'object' => 'Facture'), 'fournisseur/facture' => array('table' => 'facture_fourn', - 'fields' => array('ref', ref_client), + 'fields' => array('ref', 'ref_client'), 'class' => 'fourn/class/fournisseur.facture.class.php', 'object' => 'FactureFournisseur'), 'produit' => array('table' => 'product', @@ -2820,7 +2932,11 @@ class EmailCollector extends CommonObject // TODO Move mail using PHP-IMAP } } else { - dol_syslog("EmailCollector::doCollectOneCollector message ".$imapemail." to ".$connectstringtarget." was set to read", LOG_DEBUG); + if (empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + dol_syslog("EmailCollector::doCollectOneCollector message ".((string) $imapemail)." to ".$connectstringtarget." was set to read", LOG_DEBUG); + } else { + dol_syslog("EmailCollector::doCollectOneCollector message '".($imapemail->getHeader()->get('subject'))."' using this->host=".$this->host.", this->access_type=".$this->acces_type." was set to read", LOG_DEBUG); + } } } else { $errorforemail++; @@ -3025,13 +3141,14 @@ class EmailCollector extends CommonObject * Check if the same file name already exists in the upload folder, * append increment number to the original filename */ - while (file_exists($destdir."/" . $file_name . "." . $extension)) { - $file_name = (string) $file_name_original . ' (' . $num . ')'; + while (file_exists($destdir."/".$file_name.".".$extension)) { + $file_name = $file_name_original . ' (' . $num . ')'; $file_name_complete = $file_name . "." . $extension; $destination = $destdir.'/'.$file_name_complete; $num++; } + $destination = dol_sanitizePathName($destination); file_put_contents($destination, $data); } diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index e43a86da515..5616abbbd35 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -24,8 +24,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for EmailCollectorAction @@ -113,37 +111,6 @@ class EmailCollectorAction extends CommonObject public $status; // END MODULEBUILDER PROPERTIES - - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - //public $table_element_line = 'emailcollectoractiondet'; - - // /** - // * @var string Field with ID of parent key if this field has a parent - // */ - //public $fk_element = 'fk_emailcollectoraction'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - //public $class_element_line = 'EmailcollectorActionline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - //protected $childtables=array(); - - // /** - // * @var EmailcollectorActionLine[] Array of subtable lines - // */ - //public $lines = array(); - - - /** * Constructor * @@ -225,16 +192,14 @@ class EmailCollectorAction extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // $object->title = $langs->trans("CopyOf")." ".$object->title; + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } @@ -271,26 +236,10 @@ class EmailCollectorAction extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - // if ($result > 0 && !empty($this->table_element_line)) { - // $this->fetchLinesCommon(); - // } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); - - // Load lines with object EmailcollectorActionLine - - return count($this->lines)?1:0; - }*/ - /** * Update object into database * @@ -336,7 +285,6 @@ class EmailCollectorAction extends CommonObject } $result = ''; - $companylink = ''; $label = ''.$langs->trans("EmailcollectorAction").''; $label .= '
'; @@ -487,7 +435,7 @@ class EmailCollectorAction extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index cff80aa4153..327159f61a4 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -206,16 +206,14 @@ class EmailCollectorFilter extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // $object->title = $langs->trans("CopyOf")." ".$object->title; + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } @@ -252,26 +250,10 @@ class EmailCollectorFilter extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); - - // Load lines with object EmailcollectorFilterLine - - return count($this->lines)?1:0; - }*/ - /** * Update object into database * @@ -317,7 +299,6 @@ class EmailCollectorFilter extends CommonObject } $result = ''; - $companylink = ''; $label = ''.$langs->trans("EmailcollectorFilter").''; $label .= '
'; @@ -468,7 +449,7 @@ class EmailCollectorFilter extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); } diff --git a/htdocs/eventorganization/class/conferenceorbooth.class.php b/htdocs/eventorganization/class/conferenceorbooth.class.php index cdb67a2c37b..b15dcf3e545 100644 --- a/htdocs/eventorganization/class/conferenceorbooth.class.php +++ b/htdocs/eventorganization/class/conferenceorbooth.class.php @@ -104,21 +104,21 @@ class ConferenceOrBooth extends ActionComm */ public $fields = array( 'id' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), - 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), - 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>-1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500'), - 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1), - 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width300'), + 'ref' => array('type'=>'integer', 'label'=>'Ref', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'csslist'=>'left', 'comment'=>"Id"), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'csslist'=>'tdoverflowmax125', 'help'=>"OrganizationEvenLabelName", 'showoncombobox'=>'1', 'autofocusoncreate'=>1), + 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php:1:t.usage_organize_event=1', 'label'=>'Project', 'enabled'=>"isModEnabled('project')", 'position'=>52, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'project', 'css'=>'tdoverflowmax150 maxwidth500', 'csslist'=>'width100'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'csslist'=>'tdoverflowmax125', 'css'=>'maxwidth500'), + 'note' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3), + 'fk_action' => array('type'=>'sellist:c_actioncomm:libelle:id::module LIKE (\'%@eventorganization\')', 'label'=>'Format', 'enabled'=>'1', 'position'=>60, 'notnull'=>1, 'visible'=>1, 'css'=>'width100', 'csslist'=>'tdoverflowmax100'), 'datep' => array('type'=>'datetime', 'label'=>'DateStart', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'2',), 'datep2' => array('type'=>'datetime', 'label'=>'DateEnd', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>1, 'showoncombobox'=>'3',), - 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), - 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), - 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), + 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'), + 'fk_user_author' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid', 'csslist'=>'tdoverflowmax100'), + 'fk_user_mod' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax100'), + 'num_vote' => array('type'=>'smallint', 'label'=>'NbVotes', 'enabled'=>'1', 'position'=>800, 'notnull'=>-1, 'visible'=>5, 'default'=>'0', 'index'=>0), 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>1, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'EvntOrgDraft', '1'=>'EvntOrgSuggested', '2'=> 'EvntOrgConfirmed', '3' =>'EvntOrgNotQualified', '4' =>'EvntOrgDone', '9'=>'EvntOrgCancelled'),), - 'num_vote' => array('type'=>'smallint', 'label'=>'NbVotes', 'enabled'=>'1', 'position'=>1001, 'notnull'=>-1, 'visible'=>5, 'default'=>'0', 'index'=>0), ); public $rowid; public $id; @@ -217,7 +217,6 @@ class ConferenceOrBooth extends ActionComm $this->socid = $this->fk_soc; $this->datef = $this->datep2; $this->note_private = $this->note; - $this->fk_user_author = $this->fk_user_author; } /** @@ -250,7 +249,7 @@ class ConferenceOrBooth extends ActionComm $link_subscription = $dolibarr_main_url_root.'/public/eventorganization/attendee_new.php?id='.urlencode($id).'&type=conf'; - $encodedsecurekey = dol_hash($conf->global->EVENTORGANIZATION_SECUREKEY.'conferenceorbooth'.$id, 2); + $encodedsecurekey = dol_hash(getDolGlobalString('EVENTORGANIZATION_SECUREKEY').'conferenceorbooth'.$id, 2); $link_subscription .= '&securekey='.urlencode($encodedsecurekey); /*$this->fields['pubregister'] = array('type'=>'url', 'label'=>$langs->trans("PublicAttendeeSubscriptionPage"), 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>1); @@ -285,7 +284,7 @@ class ConferenceOrBooth extends ActionComm $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -716,8 +715,8 @@ class ConferenceOrBooth extends ActionComm $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_conferenceorbooth = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/eventorganization/class/conferenceorboothattendee.class.php b/htdocs/eventorganization/class/conferenceorboothattendee.class.php index 595eaf67eeb..afee798829f 100644 --- a/htdocs/eventorganization/class/conferenceorboothattendee.class.php +++ b/htdocs/eventorganization/class/conferenceorboothattendee.class.php @@ -108,7 +108,7 @@ class ConferenceOrBoothAttendee extends CommonObject 'email' => array('type'=>'mail', 'label'=>'EmailAttendee', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'autofocusoncreate'=>1, 'searchall'=>1), 'firstname' => array('type'=>'varchar(100)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), 'lastname' => array('type'=>'varchar(100)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>32, 'notnull'=>0, 'visible'=>1, 'index'=>1, 'searchall'=>1), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status = 1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'position'=>40, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'help'=>"OrganizationEventLinkToThirdParty", 'picto'=>'company', 'css'=>'tdoverflowmax150 maxwidth500'), 'email_company' => array('type'=>'mail', 'label'=>'EmailCompany', 'enabled'=>'1', 'position'=>41, 'notnull'=>0, 'visible'=>-2, 'searchall'=>1), 'date_subscription' => array('type'=>'datetime', 'label'=>'DateOfRegistration', 'enabled'=>'1', 'position'=>56, 'notnull'=>1, 'visible'=>1, 'showoncombobox'=>'1',), 'fk_invoice' => array('type'=>'integer:Facture:compta/facture/class/facture.class.php', 'label'=>'Invoice', 'enabled'=>'$conf->facture->enabled', 'position'=>57, 'notnull'=>0, 'visible'=>-1, 'index'=>0, 'picto'=>'bill', 'css'=>'tdoverflowmax150 maxwidth500'), @@ -423,7 +423,7 @@ class ConferenceOrBoothAttendee extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm as a on a.id = t.fk_actioncomm"; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -1102,18 +1102,18 @@ class ConferenceOrBoothAttendee extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'eventorganization_conferenceorboothattendee' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index b6932c2cf09..9928b8af33b 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -568,13 +568,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=presend&token='.newToken().'&mode=init#formmailbeforetitle'); } - print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken().'', '', $permissiontoadd); + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.$withProjectUrl.'&action=edit&token='.newToken(), '', $permissiontoadd); // Clone print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&socid='.$object->socid.'&action=clone&token='.newToken().'&object=scrumsprint', '', $permissiontoadd); // Delete (need delete permission, or if draft, just need create/modify permission) - print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken().'', '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); + print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'].'?id='.$object->id.$withProjectUrl.'&action=delete&token='.newToken(), '', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd)); } print '
'."\n"; } diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index f69d86c62e7..39aa7216e84 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -25,17 +25,14 @@ // Load Dolibarr environment require '../main.inc.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; require_once DOL_DOCUMENT_ROOT.'/eventorganization/lib/eventorganization_conferenceorbooth.lib.php'; - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; global $dolibarr_main_url_root; @@ -47,19 +44,20 @@ global $dolibarr_main_url_root; $langs->loadLangs(array("eventorganization", "other", "projects", "companies")); // Get Parameters -$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$action = GETPOST('action', 'aZ09') ? GETPOST('action', 'aZ09') : 'view'; // The action 'create'/'add', 'edit'/'update', 'view', ... $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'conferenceorboothlist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); // The output mode ('list', 'kanban', 'hierarchy', 'calendar', ...) $id = GETPOST('id', 'int'); $projectid = GETPOST('projectid', 'int'); -$projectref = GETPOST('ref'); +$projectref = GETPOST('ref', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -67,8 +65,9 @@ $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 or if we click on clear filters +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -77,7 +76,7 @@ $pagenext = $page + 1; $object = new ConferenceOrBooth($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->eventorganization->dir_output.'/temp/massgeneration/'.$user->id; -$hookmanager->initHooks(array('conferenceorboothlist')); // Note that conf->hooks_modules contains array +$hookmanager->initHooks(array($contextpage)); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); @@ -120,11 +119,11 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -141,8 +140,8 @@ $permissiontoadd = $user->rights->eventorganization->write; $permissiontodelete = $user->rights->eventorganization->delete; // Security check -if (empty($conf->eventorganization->enabled)) { - accessforbidden('Module not enabled'); +if (!isModEnabled('eventorganization')) { + accessforbidden('Module eventorganization not enabled'); } $socid = 0; if ($user->socid > 0) { // Protection if external user @@ -235,9 +234,11 @@ if (empty($reshook)) { $form = new Form($db); $now = dol_now(); -$title = $langs->trans('ListOfConferencesOrBooths'); -//$help_url="EN:Module_ConferenceOrBooth|FR:Module_ConferenceOrBooth_FR|ES:Módulo_ConferenceOrBooth"; +//$help_url = "EN:Module_ConferenceOrBooth|FR:Module_ConferenceOrBooth_FR|ES:Módulo_ConferenceOrBooth"; $help_url = ''; +$title = $langs->trans('ListOfConferencesOrBooths'); +$morejs = array(); +$morecss = array(); if ($projectid > 0 || $projectref) { $project = new Project($db); @@ -257,7 +258,7 @@ if ($projectid > 0 || $projectref) { } $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; - $title = $langs->trans("Project") . ' - ' . $langs->trans("ListOfConferencesOrBooths") . ' - ' . $project->ref . ' ' . $project->name; + $title = $langs->trans("Project") . ' - ' . $langs->trans("EventOrganizationConfOrBoothes") . ' - ' . $project->ref . ' ' . $project->name; if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $project->name) { $title = $project->ref . ' ' . $project->name . ' - ' . $langs->trans("ListOfConferencesOrBooths"); } @@ -524,9 +525,13 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); +//$sql .= ", COUNT(rc.rowid) as anotherfield"; + +$sqlfields = $sql; // $sql fields to remove for count total + $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (!empty($extrafields->attributes[$object->table_element]['label']) && 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 (t.id = ef.fk_object)"; +if (isset($extrafields->attributes[$object->table_element]['label']) && 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 (t.rowid = ef.fk_object)"; } $sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_actioncomm as cact ON cact.id=t.fk_action AND cact.module LIKE '%@eventorganization'"; // Add table from hooks @@ -554,17 +559,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -582,35 +587,42 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^'.preg_quote($sqlfields, '/').'/', 'SELECT COUNT(*) as nbtotalofrecords', $sql); + $sqlforcount = preg_replace('/GROUP BY .*$/', '', $sqlforcount); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); - $num = $db->num_rows($resql); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); @@ -622,6 +634,9 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -629,11 +644,17 @@ if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { + if (is_array($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif (preg_match('/(_dtstart|_dtend)$/', $key) && !empty($val)) { + $param .= '&search_'.$key.'month='.((int) GETPOST('search_'.$key.'month', 'int')); + $param .= '&search_'.$key.'day='.((int) GETPOST('search_'.$key.'day', 'int')); + $param .= '&search_'.$key.'year='.((int) GETPOST('search_'.$key.'year', 'int')); + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -655,7 +676,7 @@ $arrayofmassactions = array( 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail").' ('.$langs->trans("ToSpeakers").')', //'presend_attendees'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail").' - '.$langs->trans("Attendees"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -672,10 +693,13 @@ print ''; print ''; print ''; +print ''; print ''; print ''; +print ''; -$title = $langs->trans("ListOfConferencesOrBooths"); + +$title = $langs->trans("EventOrganizationConfOrBoothes"); $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/eventorganization/conferenceorbooth_card.php?action=create'.(!empty($project->id)?'&withproject=1&fk_project='.$project->id:'').(!empty($project->socid)?'&fk_soc='.$project->socid:'').'&backtopage='.urlencode($_SERVER['PHP_SELF']).(!empty($project->id)?'?projectid='.$project->id:''), '', $permissiontoadd); @@ -683,7 +707,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort // Add code for pre mass action (confirmation or email presend form) -$topicmail = $projectstatic->title; +$topicmail = ''; $modelmail = "conferenceorbooth"; $objecttmp = new ConferenceOrBooth($db); $trackid = 'conferenceorbooth_'.$object->id; @@ -692,10 +716,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -718,7 +745,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); @@ -729,9 +756,15 @@ print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} foreach ($object->fields as $key => $val) { - $searchkey = (empty($search[$key]) ? '' : $search[$key]); - + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -739,17 +772,15 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $key != 'ref' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -769,16 +806,23 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -787,27 +831,32 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'rowid' && $key != 'ref' && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // 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); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -819,8 +868,11 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // Loop on record // -------------------------------------------------------------------- $i = 0; +$savnbfield = $totalarray['nbfield']; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -829,76 +881,110 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Store properties in $object $object->setVarsFromFetchObj($obj); - // Show here line of result - print ''; - $totalarray['nbfield'] = 0; - foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; - } elseif ($key == 'status') { - $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; } - - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'right'; - } - //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - - if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; - if ($key == 'status') { - print $object->getLibStatut(5); - } elseif ($key == 'ref') { - print $object->getNomUrl(1, 0, '', (($projectid > 0)?'withproject':'')); - } else { - print $object->showOutputField($val, $key, $object->$key, ''); + } else { + // Show here line of result + $j = 0; + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; if (!$i) { $totalarray['nbfield']++; } - if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + } + foreach ($object->fields as $key => $val) { + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } + + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } + + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'ref', 'status')) && empty($val['arrayofkeyval'])) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; + + if (!empty($arrayfields['t.'.$key]['checked'])) { + print ''; + if ($key == 'status') { + print $object->getLibStatut(5); + } elseif ($key == 'ref') { + print $object->getNomUrl(1, 0, '', (($projectid > 0)?'withproject':'')); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } + print ''; if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + $totalarray['nbfield']++; } - if (!isset($totalarray['val'])) { - $totalarray['val'] = array(); + if (!empty($val['isameasure']) && $val['isameasure'] == 1) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } + if (!isset($totalarray['val'])) { + $totalarray['val'] = array(); + } + if (!isset($totalarray['val']['t.'.$key])) { + $totalarray['val']['t.'.$key] = 0; + } + $totalarray['val']['t.'.$key] += $object->$key; } - if (!isset($totalarray['val']['t.'.$key])) { - $totalarray['val']['t.'.$key] = 0; - } - $totalarray['val']['t.'.$key] += $object->$key; } } - } - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - print ''."\n"; + print ''."\n"; + } $i++; } @@ -914,14 +1000,14 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $searchkey, $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, $searchkey, '', '', 'search_', 'maxwidth125', 1); - } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { - print ''; + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100'.($key == 'status' ? ' search_status onrightofpage' : ''), 1); + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -757,6 +788,12 @@ foreach ($object->fields as $key => $val) { print '
'; print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + print '
'; } - - if (in_array($val['type'], array('timestamp'))) { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif ($key == 'ref') { - $cssforfield .= ($cssforfield ? ' ' : '').'nowrap left'; + // Output Kanban + print $object->getKanbanView(''); + if ($i == ($imaxinloop - 1)) { + print '
'; + print '
'; + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } print ''; - 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($object->id, $arrayofselected)) { - $selected = 1; + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + 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($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index ab8c4a28cbc..8c62cdc3914 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1647,7 +1647,7 @@ if ($action == 'create') { dol_print_error($db); } } -} elseif ($id || $ref) { +} elseif ($object->id > 0) { /* *************************************************************************** */ /* */ /* Edit and view mode */ @@ -1657,828 +1657,826 @@ if ($action == 'create') { $num_prod = count($lines); - if ($object->id > 0) { - if (!empty($object->origin) && $object->origin_id > 0) { - $typeobject = $object->origin; - $origin = $object->origin; - $origin_id = $object->origin_id; - $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + if (!empty($object->origin) && $object->origin_id > 0) { + $typeobject = $object->origin; + $origin = $object->origin; + $origin_id = $object->origin_id; + $object->fetch_origin(); // Load property $object->commande, $object->propal, ... + } + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $res = $object->fetch_optionals(); + + $head = shipping_prepare_head($object); + print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + + $formconfirm = ''; + + // Confirm deleteion + if ($action == 'delete') { + $formquestion = array(); + if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { + $formquestion = array( + array( + 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), + 'name' => 'alsoUpdateStock', + 'type' => 'checkbox', + 'value' => 0 + ), + ); + } + $formconfirm = $form->formconfirm( + $_SERVER['PHP_SELF'].'?id='.$object->id, + $langs->trans('DeleteSending'), + $langs->trans("ConfirmDeleteSending", $object->ref), + 'confirm_delete', + $formquestion, + 0, + 1 + ); + } + + // Confirmation validation + if ($action == 'valid') { + $objectref = substr($object->ref, 1, 4); + if ($objectref == 'PROV') { + $numref = $object->getNextNumRef($soc); + } else { + $numref = $object->ref; } - $soc = new Societe($db); - $soc->fetch($object->socid); + $text = $langs->trans("ConfirmValidateSending", $numref); - $res = $object->fetch_optionals(); + if (isModEnabled('notification')) { + require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; + $notify = new Notify($db); + $text .= '
'; + $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); + } - $head = shipping_prepare_head($object); - print dol_get_fiche_head($head, 'shipping', $langs->trans("Shipment"), -1, $object->picto); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); + } + // Confirm cancelation + if ($action == 'cancel') { + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); + } - $formconfirm = ''; + // Call Hook formConfirm + $parameters = array('formConfirm' => $formconfirm); + $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $formconfirm .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $formconfirm = $hookmanager->resPrint; + } - // Confirm deleteion - if ($action == 'delete') { - $formquestion = array(); - if ($object->statut == Expedition::STATUS_CLOSED && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE)) { - $formquestion = array( - array( - 'label' => $langs->trans('ShipmentIncrementStockOnDelete'), - 'name' => 'alsoUpdateStock', - 'type' => 'checkbox', - 'value' => 0 - ), - ); + // Print form confirm + print $formconfirm; + + // Calculate totalWeight and totalVolume for all products + // by adding weight and volume of each product line. + $tmparray = $object->getTotalWeightVolume(); + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + + + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { + $objectsrc = new Commande($db); + $objectsrc->fetch($object->$typeobject->id); + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + $objectsrc = new Propal($db); + $objectsrc->fetch($object->$typeobject->id); + } + + // Shipment card + $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + // Ref customer shipment + $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); + // Thirdparty + $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + $morehtmlref .= '
'; + if (0) { // Do not change on shipment + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $formconfirm = $form->formconfirm( - $_SERVER['PHP_SELF'].'?id='.$object->id, - $langs->trans('DeleteSending'), - $langs->trans("ConfirmDeleteSending", $object->ref), - 'confirm_delete', - $formquestion, - 0, - 1 - ); - } - - // Confirmation validation - if ($action == 'valid') { - $objectref = substr($object->ref, 1, 4); - if ($objectref == 'PROV') { - $numref = $object->getNextNumRef($soc); - } else { - $numref = $object->ref; - } - - $text = $langs->trans("ConfirmValidateSending", $numref); - - if (isModEnabled('notification')) { - require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; - $notify = new Notify($db); - $text .= '
'; - $text .= $notify->confirmMessage('SHIPPING_VALIDATE', $object->socid, $object); - } - - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateSending'), $text, 'confirm_valid', '', 0, 1); - } - // Confirm cancelation - if ($action == 'cancel') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelSending'), $langs->trans("ConfirmCancelSending", $object->ref), 'confirm_cancel', '', 0, 1); - } - - // Call Hook formConfirm - $parameters = array('formConfirm' => $formconfirm); - $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if (empty($reshook)) { - $formconfirm .= $hookmanager->resPrint; - } elseif ($reshook > 0) { - $formconfirm = $hookmanager->resPrint; - } - - // Print form confirm - print $formconfirm; - - // Calculate totalWeight and totalVolume for all products - // by adding weight and volume of each product line. - $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; - - - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - $objectsrc = new Commande($db); - $objectsrc->fetch($object->$typeobject->id); - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - $objectsrc = new Propal($db); - $objectsrc->fetch($object->$typeobject->id); - } - - // Shipment card - $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - // Ref customer shipment - $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string', '', 0, 1); - $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, $user->rights->expedition->creer, 'string'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); - // Thirdparty - $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); - // Project - if (isModEnabled('project')) { - $langs->load("projects"); - $morehtmlref .= '
'; - if (0) { // Do not change on shipment - $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); - if ($action != 'classify') { - $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; - } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); - } else { - if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { - $proj = new Project($db); - $proj->fetch($objectsrc->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - if ($proj->title) { - $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; - } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $objectsrc->socid, $objectsrc->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { + $proj = new Project($db); + $proj->fetch($objectsrc->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; } } } - $morehtmlref .= '
'; + } + $morehtmlref .= '
'; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - print '
'; - print '
'; - print '
'; + print '
'; + print '
'; + print '
'; - print ''; + print '
'; - // Linked documents - if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { - print ''; - print '\n"; - print ''; - } - if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { - print ''; - print '\n"; - print ''; - } - - // Date creation - print ''; - print '\n"; - print ''; - - // Delivery date planned - print ''; - print ''; - - // Weight + // Linked documents + if ($typeobject == 'commande' && $object->$typeobject->id && isModEnabled('commande')) { print ''; - - // Width - print ''; - - // Height - print ''; - - // Depth - print ''; - - // Volume - print ''; + print $langs->trans("RefOrder").''; print '\n"; print ''; - - // Other attributes - $cols = 2; - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - - print '
'; - print $langs->trans("RefOrder").''; - print $objectsrc->getNomUrl(1, 'commande'); - print "
'; - print $langs->trans("RefProposal").''; - print $objectsrc->getNomUrl(1, 'expedition'); - print "
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print ''; - - if ($action != 'editdate_livraison') { - print ''; - } - print '
'; - print $langs->trans('DateDeliveryPlanned'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; - print '
'; - if ($action == 'editdate_livraison') { - print '
'; - print ''; - print ''; - print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); - print ''; - print '
'; - } else { - print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; - } - print '
'; - print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); - print ''; - - if ($action == 'edittrueWeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - - // Calculated - if ($totalWeight > 0) { - if (!empty($object->trueWeight)) { - print ' ('.$langs->trans("SumOfProductWeights").': '; - } - print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - if (!empty($object->trueWeight)) { - print ')'; - } - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; - print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; - if ($action == 'edittrueHeight') { - print '
'; - print ''; - print ''; - print ''; - print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); - print ' '; - print ' '; - print '
'; - } else { - print $object->trueHeight; - print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; - } - - print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; - print '
'; - print $langs->trans("Volume"); - print ''; - $calculatedVolume = 0; - $volumeUnit = 0; - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); - $volumeUnit = $object->size_units * 3; - } - // If sending volume not defined we use sum of products - if ($calculatedVolume > 0) { - if ($volumeUnit < 50) { - print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - } else { - print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); - } - } - if ($totalVolume > 0) { - if ($calculatedVolume) { - print ' ('.$langs->trans("SumOfProductVolumes").': '; - } - print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); - //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; - if ($calculatedVolume) { - print ')'; - } - } + print $objectsrc->getNomUrl(1, 'commande'); print "
'; - - print '
'; - print '
'; - print '
'; - - print ''; - - // Sending method - print ''; + } + if ($typeobject == 'propal' && $object->$typeobject->id && isModEnabled("propal")) { + print ''; + print '\n"; print ''; + } - // Tracking Number - print ''; + // Date creation + print ''; + print '\n"; + print ''; - // Incoterms - if (isModEnabled('incoterm')) { - print ''; - print ''; + // Delivery date planned + print ''; + print ''; + + // Weight + print '
'; - print ''; - - if ($action != 'editshipping_method_id') { - print ''; - } - print '
'; - print $langs->trans('SendingMethod'); - print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; - print '
'; - if ($action == 'editshipping_method_id') { - print '
'; - print ''; - print ''; - $object->fetch_delivery_methods(); - print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); - if ($user->admin) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; - print '
'; - } else { - if ($object->shipping_method_id > 0) { - // Get code using getLabelFromKey - $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); - print $langs->trans("SendingMethod".strtoupper($code)); - } - } - print '
'; + print $langs->trans("RefProposal").''; + print $objectsrc->getNomUrl(1, 'expedition'); + print "
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; - print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); - print '
'.$langs->trans("DateCreation").''.dol_print_date($object->date_creation, "dayhour")."
'; - print '
'; - print $langs->trans('IncotermLabel'); - print ''; - if ($user->rights->expedition->creer) { - print ''.img_edit().''; - } else { - print ' '; - } - print '
'; - print '
'; - if ($action != 'editincoterm') { - print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); - } else { - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); - } - print '
'; + print ''; + + if ($action != 'editdate_livraison') { + print ''; + } + print '
'; + print $langs->trans('DateDeliveryPlanned'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'
'; + print '
'; + if ($action == 'editdate_livraison') { + print '
'; + print ''; + print ''; + print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); + print ''; + print '
'; + } else { + print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; + } + print '
'; + print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->expedition->creer); + print ''; + + if ($action == 'edittrueWeight') { + print '
'; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); + print ' '; + print ' '; + print '
'; + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + + // Calculated + if ($totalWeight > 0) { + if (!empty($object->trueWeight)) { + print ' ('.$langs->trans("SumOfProductWeights").': '; } - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print "
"; - - print '
'; - print '
'; - - print '
'; - - - // Lines of products - - if ($action == 'editline') { - print '
- - - - - '; + print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + if (!empty($object->trueWeight)) { + print ')'; } - print '
'; + } + print '
'; - print ''; - print ''; - // Adds a line numbering column - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - // Product/Service - print ''; - // Qty - print ''; - if ($origin && $origin_id > 0) { - print ''; - } - if ($action == 'editline') { - $editColspan = 3; - if (!isModEnabled('stock')) { - $editColspan--; - } - if (empty($conf->productbatch->enabled)) { - $editColspan--; - } - print ''; + // Width + print ''; + + // Height + print ''; + + // Depth + print ''; + + // Volume + print ''; + print ''; - } else { - print ''; - } - if (isModEnabled('stock')) { - print ''; - } - - if (isModEnabled('productbatch')) { - print ''; - } + print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); } - print ''; - print ''; - //print ''; - if ($object->statut == 0) { - print ''; - print ''; + } + if ($totalVolume > 0) { + if ($calculatedVolume) { + print ' ('.$langs->trans("SumOfProductVolumes").': '; } - print "\n"; - print ''; + print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); + //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; + if ($calculatedVolume) { + print ')'; + } + } + print "\n"; + print ''; - $outputlangs = $langs; + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $object->fetch_thirdparty(); - $newlang = ''; - if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { - $newlang = GETPOST('lang_id', 'aZ09'); - } - if (empty($newlang)) { - $newlang = $object->thirdparty->default_lang; - } - if (!empty($newlang)) { - $outputlangs = new Translate("", $conf); - $outputlangs->setDefaultLang($newlang); - } + print '
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; - if ($object->statut <= 1) { - print $langs->trans("QtyToShip").' - '; - } else { - print $langs->trans("QtyShipped").' - '; - } - if (isModEnabled('stock')) { - print $langs->trans("WarehouseSource").' - '; - } - if (isModEnabled('productbatch')) { - print $langs->trans("Batch"); - } - print '
'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); + print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; + print '
'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->expedition->creer).''; + if ($action == 'edittrueHeight') { + print ''; + print ''; + print ''; + print ''; + print ''; + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); + print ' '; + print ' '; + print ''; + } else { + print $object->trueHeight; + print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; + } + + print '
'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); + print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; + print '
'; + print $langs->trans("Volume"); + print ''; + $calculatedVolume = 0; + $volumeUnit = 0; + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { + $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); + $volumeUnit = $object->size_units * 3; + } + // If sending volume not defined we use sum of products + if ($calculatedVolume > 0) { + if ($volumeUnit < 50) { + print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); } else { - if ($object->statut <= 1) { - print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'; + + print ''; + print '
'; + print '
'; + + print ''; + + // Sending method + print ''; + print ''; + + // Tracking Number + print ''; + + // Incoterms + if (isModEnabled('incoterm')) { + print ''; + print ''; + } + + // Other attributes + $parameters = array('colspan' => ' colspan="3"', 'cols' => '3'); + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + print "
'; + print ''; + + if ($action != 'editshipping_method_id') { + print ''; + } + print '
'; + print $langs->trans('SendingMethod'); + print 'id.'">'.img_edit($langs->trans('SetSendingMethod'), 1).'
'; + print '
'; + if ($action == 'editshipping_method_id') { + print '
'; + print ''; + print ''; + $object->fetch_delivery_methods(); + print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); + if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; + print '
'; + } else { + if ($object->shipping_method_id > 0) { + // Get code using getLabelFromKey + $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + print $langs->trans("SendingMethod".strtoupper($code)); + } + } + print '
'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->expedition->creer).''; + print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->expedition->creer, 'safehtmlstring', $object->tracking_number); + print '
'; + print '
'; + print $langs->trans('IncotermLabel'); + print ''; + if ($user->rights->expedition->creer) { + print ''.img_edit().''; + } else { + print ' '; + } + print '
'; + print '
'; + if ($action != 'editincoterm') { + print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); + } else { + print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); + } + print '
"; + + print '
'; + print ''; + + print '
'; + + + // Lines of products + + if ($action == 'editline') { + print '
+ + + + + '; + } + print '
'; + + print '
'; + print ''; + print ''; + print ''; + // Adds a line numbering column + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; + } + // Product/Service + print ''; + // Qty + print ''; + if ($origin && $origin_id > 0) { + print ''; + } + if ($action == 'editline') { + $editColspan = 3; + if (!isModEnabled('stock')) { + $editColspan--; + } + if (empty($conf->productbatch->enabled)) { + $editColspan--; + } + print ''; + } else { + if ($object->statut <= 1) { + print ''; + } else { + print ''; + } + if (isModEnabled('stock')) { + print ''; } - // Get list of products already sent for same source object into $alreadysent - $alreadysent = array(); - if ($origin && $origin_id > 0) { - $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; - $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; - $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; - //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; - $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; - $sql .= ', p.description as product_desc'; - $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; - $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; - $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; - //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; - $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; - $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); - $sql .= " AND obj.rowid = ed.fk_origin_line"; - $sql .= " AND ed.fk_expedition = e.rowid"; - //if ($filter) $sql.= $filter; - $sql .= " ORDER BY obj.fk_product"; + if (isModEnabled('productbatch')) { + print ''; + } + } + print ''; + print ''; + //print ''; + if ($object->statut == 0) { + print ''; + print ''; + } + print "\n"; + print ''; - dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); - $resql = $db->query($sql); - if ($resql) { - $num = $db->num_rows($resql); - $i = 0; + $outputlangs = $langs; - while ($i < $num) { - $obj = $db->fetch_object($resql); - if ($obj) { - // $obj->rowid is rowid in $origin."det" table - $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( - 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, - 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, - 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); - } - $i++; + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $object->fetch_thirdparty(); + $newlang = ''; + if (empty($newlang) && GETPOST('lang_id', 'aZ09')) { + $newlang = GETPOST('lang_id', 'aZ09'); + } + if (empty($newlang)) { + $newlang = $object->thirdparty->default_lang; + } + if (!empty($newlang)) { + $outputlangs = new Translate("", $conf); + $outputlangs->setDefaultLang($newlang); + } + } + + // Get list of products already sent for same source object into $alreadysent + $alreadysent = array(); + if ($origin && $origin_id > 0) { + $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.fk_unit, obj.date_start, obj.date_end"; + $sql .= ", ed.rowid as shipmentline_id, ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line, ed.fk_entrepot"; + $sql .= ", e.rowid as shipment_id, e.ref as shipment_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_expedition"; + //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; + $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tosell as product_tosell, p.tobuy as product_tobuy, p.tobatch as product_tobatch'; + $sql .= ', p.description as product_desc'; + $sql .= " FROM ".MAIN_DB_PREFIX."expeditiondet as ed"; + $sql .= ", ".MAIN_DB_PREFIX."expedition as e"; + $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; + //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_expedition = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; + $sql .= " WHERE e.entity IN (".getEntity('expedition').")"; + $sql .= " AND obj.fk_".$origin." = ".((int) $origin_id); + $sql .= " AND obj.rowid = ed.fk_origin_line"; + $sql .= " AND ed.fk_expedition = e.rowid"; + //if ($filter) $sql.= $filter; + $sql .= " ORDER BY obj.fk_product"; + + dol_syslog("expedition/card.php get list of shipment lines", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $obj = $db->fetch_object($resql); + if ($obj) { + // $obj->rowid is rowid in $origin."det" table + $alreadysent[$obj->rowid][$obj->shipmentline_id] = array( + 'shipment_ref'=>$obj->shipment_ref, 'shipment_id'=>$obj->shipment_id, 'warehouse'=>$obj->fk_entrepot, 'qty_shipped'=>$obj->qty_shipped, + 'product_tosell'=>$obj->product_tosell, 'product_tobuy'=>$obj->product_tobuy, 'product_tobatch'=>$obj->product_tobatch, + 'date_valid'=>$db->jdate($obj->date_valid), 'date_delivery'=>$db->jdate($obj->date_delivery)); } + $i++; } - //var_dump($alreadysent); + } + //var_dump($alreadysent); + } + + print ''; + + // Loop on each product to send/sent + for ($i = 0; $i < $num_prod; $i++) { + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); + $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - print ''; + if (empty($reshook)) { + print ''; // id of order line + print ''; - // Loop on each product to send/sent - for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => $outputlangs); - $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); - if ($reshook < 0) { - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + // # + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { + print ''; } - if (empty($reshook)) { - print ''; // id of order line - print ''; - - // # - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { - print ''; - } - - // Predefined product or service - if ($lines[$i]->fk_product > 0) { - // Define output language - if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { - $prod = new Product($db); - $prod->fetch($lines[$i]->fk_product); - $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; - } else { - $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); - } - - print '\n"; + // Predefined product or service + if ($lines[$i]->fk_product > 0) { + // Define output language + if (getDolGlobalInt('MAIN_MULTILANGS') && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { + $prod = new Product($db); + $prod->fetch($lines[$i]->fk_product); + $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product_label; } else { - print '\n"; + $label = (!empty($lines[$i]->label) ? $lines[$i]->label : $lines[$i]->product_label); } - $unit_order = ''; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $unit_order = measuringUnitString($lines[$i]->fk_unit); + print '\n"; + } else { + print ''; + if (!empty($lines[$i]->label)) { + $text .= ' '.$lines[$i]->label.''; + print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); + } else { + print $text.' '.nl2br($lines[$i]->description); + } - // Qty in other shipments (with shipment and warehouse used) - if ($origin && $origin_id > 0) { - print '\n"; + } - $j++; - if ($j > 1) { - print '
'; - } - $shipment_static->fetch($shipmentline_var['shipment_id']); - print $shipment_static->getNomUrl(1); - print ' - '.$shipmentline_var['qty_shipped']; - $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); - if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { - $warehousestatic->fetch($shipmentline_var['warehouse']); - $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); - } - print ' '.$form->textwithpicto('', $htmltext, 1); + $unit_order = ''; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $unit_order = measuringUnitString($lines[$i]->fk_unit); + } + + // Qty ordered + print ''; + + // Qty in other shipments (with shipment and warehouse used) + if ($origin && $origin_id > 0) { + print ''; } + print ''; + } - if ($action == 'editline' && $lines[$i]->id == $line_id) { - // edit mode - print ''; + } else { + // Qty to ship or shipped + print ''; + + // Warehouse source + if (isModEnabled('stock')) { + print ''; + } + + // Batch number managment + if (isModEnabled('productbatch')) { + if (isset($lines[$i]->detail_batch)) { + print ''; + print ''; - } - - // Batch number managment - if (isModEnabled('productbatch')) { - if (isset($lines[$i]->detail_batch)) { - print ''; - print ''; - } else { - print ''; - } - } - } - - // Weight - print ''; - - // Volume - print ''; - - // Size - //print ''; - - if ($action == 'editline' && $lines[$i]->id == $line_id) { - print ''; - } elseif ($object->statut == Expedition::STATUS_DRAFT) { - // edit-delete buttons - print ''; - print ''; - - // Display lines extrafields - if (!empty($rowExtrafieldsStart)) { - print $rowExtrafieldsStart; - print $rowExtrafieldsView; - print $rowEnd; - } - } - print ""; - - // Display lines extrafields. - // $line is a line of shipment - if (!empty($extrafields)) { - $colspan = 6; - if ($origin && $origin_id > 0) { - $colspan++; - } - if (isModEnabled('productbatch')) { - $colspan++; - } - if (isModEnabled('stock')) { - $colspan++; - } - - $line = $lines[$i]; - $line->fetch_optionals(); - - // TODO Show all in same line by setting $display_type = 'line' - if ($action == 'editline' && $line->id == $line_id) { - print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } else { - print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + print ''; } } } + + // Weight + print ''; + + // Volume + print ''; + + // Size + //print ''; + + if ($action == 'editline' && $lines[$i]->id == $line_id) { + print ''; + } elseif ($object->statut == Expedition::STATUS_DRAFT) { + // edit-delete buttons + print ''; + print ''; + + // Display lines extrafields + if (!empty($rowExtrafieldsStart)) { + print $rowExtrafieldsStart; + print $rowExtrafieldsView; + print $rowEnd; + } + } + print ""; + + // Display lines extrafields. + // $line is a line of shipment + if (!empty($extrafields)) { + $colspan = 6; + if ($origin && $origin_id > 0) { + $colspan++; + } + if (isModEnabled('productbatch')) { + $colspan++; + } + if (isModEnabled('stock')) { + $colspan++; + } + + $line = $lines[$i]; + $line->fetch_optionals(); + + // TODO Show all in same line by setting $display_type = 'line' + if ($action == 'editline' && $line->id == $line_id) { + print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } else { + print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); + } + } } - - // TODO Show also lines ordered but not delivered - - print "
 '.$langs->trans("Products").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyInOtherShipments").''; + if ($object->statut <= 1) { + print $langs->trans("QtyToShip").' - '; + } else { + print $langs->trans("QtyShipped").' - '; + } + if (isModEnabled('stock')) { + print $langs->trans("WarehouseSource").' - '; + } + if (isModEnabled('productbatch')) { + print $langs->trans("Batch"); + } + print ''.$langs->trans("QtyToShip").''.$langs->trans("QtyShipped").''.$langs->trans("WarehouseSource").''.$langs->trans("Batch").''.$langs->trans("CalculatedWeight").''.$langs->trans("CalculatedVolume").''.$langs->trans("Size").'
'.($i + 1).'
'.($i + 1).''; - - // Show product and description - $product_static->type = $lines[$i]->fk_product_type; - $product_static->id = $lines[$i]->fk_product; - $product_static->ref = $lines[$i]->ref; - $product_static->status = $lines[$i]->product_tosell; - $product_static->status_buy = $lines[$i]->product_tobuy; - $product_static->status_batch = $lines[$i]->product_tobatch; - - $product_static->weight = $lines[$i]->weight; - $product_static->weight_units = $lines[$i]->weight_units; - $product_static->length = $lines[$i]->length; - $product_static->length_units = $lines[$i]->length_units; - $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; - $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; - $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; - $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; - $product_static->surface = $lines[$i]->surface; - $product_static->surface_units = $lines[$i]->surface_units; - $product_static->volume = $lines[$i]->volume; - $product_static->volume_units = $lines[$i]->volume_units; - - $text = $product_static->getNomUrl(1); - $text .= ' - '.$label; - $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); - print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); - if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { - print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; - } - print "
'; - if ($lines[$i]->product_type == Product::TYPE_SERVICE) { - $text = img_object($langs->trans('Service'), 'service'); - } else { - $text = img_object($langs->trans('Product'), 'product'); - } - - if (!empty($lines[$i]->label)) { - $text .= ' '.$lines[$i]->label.''; - print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); - } else { - print $text.' '.nl2br($lines[$i]->description); - } - - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); - print "'; + + // Show product and description + $product_static->type = $lines[$i]->fk_product_type; + $product_static->id = $lines[$i]->fk_product; + $product_static->ref = $lines[$i]->ref; + $product_static->status = $lines[$i]->product_tosell; + $product_static->status_buy = $lines[$i]->product_tobuy; + $product_static->status_batch = $lines[$i]->product_tobatch; + + $product_static->weight = $lines[$i]->weight; + $product_static->weight_units = $lines[$i]->weight_units; + $product_static->length = $lines[$i]->length; + $product_static->length_units = $lines[$i]->length_units; + $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; + $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; + $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; + $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; + $product_static->surface = $lines[$i]->surface; + $product_static->surface_units = $lines[$i]->surface_units; + $product_static->volume = $lines[$i]->volume; + $product_static->volume_units = $lines[$i]->volume_units; + + $text = $product_static->getNomUrl(1); + $text .= ' - '.$label; + $description = (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE') ? '' : dol_htmlentitiesbr($lines[$i]->description)); + print $form->textwithtooltip($text, $description, 3, '', '', $i); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); + if (getDolGlobalInt('PRODUIT_DESC_IN_FORM_ACCORDING_TO_DEVICE')) { + print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; + } + print "
'; + if ($lines[$i]->product_type == Product::TYPE_SERVICE) { + $text = img_object($langs->trans('Service'), 'service'); + } else { + $text = img_object($langs->trans('Product'), 'product'); } - // Qty ordered - print ''.$lines[$i]->qty_asked.' '.$unit_order.''; - foreach ($alreadysent as $key => $val) { - if ($lines[$i]->fk_origin_line == $key) { - $j = 0; - foreach ($val as $shipmentline_id => $shipmentline_var) { - if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { - continue; // We want to show only "other shipments" - } + print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print "'.$lines[$i]->qty_asked.' '.$unit_order.''; + foreach ($alreadysent as $key => $val) { + if ($lines[$i]->fk_origin_line == $key) { + $j = 0; + foreach ($val as $shipmentline_id => $shipmentline_var) { + if ($shipmentline_var['shipment_id'] == $lines[$i]->fk_expedition) { + continue; // We want to show only "other shipments" } + + $j++; + if ($j > 1) { + print '
'; + } + $shipment_static->fetch($shipmentline_var['shipment_id']); + print $shipment_static->getNomUrl(1); + print ' - '.$shipmentline_var['qty_shipped']; + $htmltext = $langs->trans("DateValidation").' : '.(empty($shipmentline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($shipmentline_var['date_valid'], 'dayhour')); + if (isModEnabled('stock') && $shipmentline_var['warehouse'] > 0) { + $warehousestatic->fetch($shipmentline_var['warehouse']); + $htmltext .= '
'.$langs->trans("FromLocation").' : '.$warehousestatic->getNomUrl(1, '', 0, 1); + } + print ' '.$form->textwithpicto('', $htmltext, 1); } } - print '
'; - if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { - print ''; - $line = new ExpeditionLigne($db); - foreach ($lines[$i]->detail_batch as $detail_batch) { - print ''; - // Qty to ship or shipped - print ''; - // Batch number managment - if ($lines[$i]->entrepot_id == 0) { - // only show lot numbers from src warehouse when shipping from multiple warehouses - $line->fetch($detail_batch->fk_expeditiondet); - } - $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; - print ''; - print ''; - } - // add a 0 qty lot row to be able to add a lot + if ($action == 'editline' && $lines[$i]->id == $line_id) { + // edit mode + print ''; - } else { + } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. + print ''; + print ''; // Qty to ship or shipped - print ''; - + print ''; // Warehouse source - if (isModEnabled('stock')) { - print ''; + // Batch number managment + print ''; + print ''; + } + + print '
'.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'; + if (is_array($lines[$i]->detail_batch) && count($lines[$i]->detail_batch) > 0) { + print ''; + $line = new ExpeditionLigne($db); + foreach ($lines[$i]->detail_batch as $detail_batch) { print ''; // Qty to ship or shipped - print ''; + print ''; // Batch number managment - print ''; + if ($lines[$i]->entrepot_id == 0) { + // only show lot numbers from src warehouse when shipping from multiple warehouses + $line->fetch($detail_batch->fk_expeditiondet); + } + $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; + print ''; print ''; - } elseif (isModEnabled('stock')) { - if ($lines[$i]->fk_product > 0) { - if ($lines[$i]->entrepot_id > 0) { - print ''; - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } elseif (count($lines[$i]->details_entrepot) > 1) { - print ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - print ''; - // Qty to ship or shipped - print ''; - // Warehouse source - print ''; - // Batch number managment - print ''; - print ''; - } - } else { - print ''; - print ''; - } - } else { - print ''; + } + // add a 0 qty lot row to be able to add a lot + print ''; + // Qty to ship or shipped + print ''; + // Batch number managment + print ''; + print ''; + } elseif (isModEnabled('stock')) { + if ($lines[$i]->fk_product > 0) { + if ($lines[$i]->entrepot_id > 0) { + print ''; print ''; // Qty to ship or shipped print ''; // Warehouse source - print ''; + print ''; // Batch number managment - print ''; + print ''; print ''; + } elseif (count($lines[$i]->details_entrepot) > 1) { + print ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + print ''; + // Qty to ship or shipped + print ''; + // Warehouse source + print ''; + // Batch number managment + print ''; + print ''; + } + } else { + print ''; + print ''; } - } elseif (!isModEnabled('stock') && empty($conf->productbatch->enabled)) { // both product batch and stock are not activated. - print ''; + } else { + print ''; print ''; // Qty to ship or shipped - print ''; + print ''; // Warehouse source print ''; // Batch number managment print ''; print ''; } - - print '
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'
'.$unit_order.''.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$unit_order.''.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).' - '.$langs->trans("NA").'
'.$langs->trans("NotEnoughStock").'
'.$unit_order.'
'.$lines[$i]->qty_shipped.' '.$unit_order.''; - if ($lines[$i]->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($lines[$i]->entrepot_id); - print $entrepot->getNomUrl(1); - } elseif (count($lines[$i]->details_entrepot) > 1) { - $detail = ''; - foreach ($lines[$i]->details_entrepot as $detail_entrepot) { - if ($detail_entrepot->entrepot_id > 0) { - $entrepot = new Entrepot($db); - $entrepot->fetch($detail_entrepot->entrepot_id); - $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; - } + print '
'.$lines[$i]->qty_shipped.' '.$unit_order.''; + if ($lines[$i]->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($lines[$i]->entrepot_id); + print $entrepot->getNomUrl(1); + } elseif (count($lines[$i]->details_entrepot) > 1) { + $detail = ''; + foreach ($lines[$i]->details_entrepot as $detail_entrepot) { + if ($detail_entrepot->entrepot_id > 0) { + $entrepot = new Entrepot($db); + $entrepot->fetch($detail_entrepot->entrepot_id); + $detail .= $langs->trans("DetailWarehouseFormat", $entrepot->libelle, $detail_entrepot->qty_shipped).'
'; } - print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print $form->textwithtooltip(img_picto('', 'object_stock').' '.$langs->trans("DetailWarehouseNumber"), $detail); + } + print '
'; + if ($lines[$i]->product_tobatch) { + $detail = ''; + foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch + $detail .= $langs->trans("Batch").': '.$dbatch->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); + } + $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; + $detail .= '
'; + } + print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); + } else { + print $langs->trans("NA"); } print '
'; - if ($lines[$i]->product_tobatch) { - $detail = ''; - foreach ($lines[$i]->detail_batch as $dbatch) { // $dbatch is instance of ExpeditionLineBatch - $detail .= $langs->trans("Batch").': '.$dbatch->batch; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($dbatch->sellby, "day"); - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($dbatch->eatby, "day"); - } - $detail .= ' - '.$langs->trans("Qty").': '.$dbatch->qty; - $detail .= '
'; - } - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); - } else { - print $langs->trans("NA"); - } - print '
'; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); - } else { - print ' '; - } - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { - print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); - } else { - print ' '; - } - print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; - print '
'; - print '
'; - print '
'; - print 'id.'">'.img_edit().''; - print ''; - print 'id.'">'.img_delete().''; - print '
'; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->weight * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "weight", $lines[$i]->weight_units); + } else { + print ' '; + } + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + print $lines[$i]->volume * $lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units); + } else { + print ' '; + } + print ''.$lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuringUnitString(0, "volume", $lines[$i]->volume_units).''; + print '
'; + print '
'; + print '
'; + print 'id.'">'.img_edit().''; + print ''; + print 'id.'">'.img_delete().''; + print '
\n"; - print '
\n"; + print '
'; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage'); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusSendingDraftShort'), '1'=>$langs->trans('StatusSendingValidatedShort'), '2'=>$langs->trans('StatusSendingProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; + print '
'; + } + $object->socid = $companystatic->getNomUrl(1); + $object->date_delivery = $obj->delivery_date; + $object->town = $obj->town; + print $object->getKanbanView(''); + if ($i == min($num, $limit) - 1) { + print '
'; + print '
'; - 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; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + 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 ''; } - print ''; - } - print ''; - print $shipment->getNomUrl(1); - print ""; - print $obj->ref_customer; - print "'; - print $companystatic->getNomUrl(1); - print ''; - print $obj->town; - print ''; - print $obj->zip; - print ''.$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (isset($typenArray[$obj->typent_code])) { - print $typenArray[$obj->typent_code]; - } - print ''; - if (empty($object->trueWeight)) { - $tmparray = $object->getTotalWeightVolume(); - print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); - print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); - } else { - print $object->trueWeight; - print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; - } - print ''; - print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); - print "'; - if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); - print ''.$shipment->tracking_url."'; - print !empty($receiving) ? $receiving->getNomUrl($db) : ''; print ''; - print dol_print_date($db->jdate($obj->date_reception), "day"); - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$shipment->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; - 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; + // Ref + if (!empty($arrayfields['e.ref']['checked'])) { + print ''; + print $shipment->getNomUrl(1); + print "
"; + print $obj->ref_customer; + print "'; + print $companystatic->getNomUrl(1); + print ''; + print $obj->town; + print ''; + print $obj->zip; + print ''.$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (isset($typenArray[$obj->typent_code])) { + print $typenArray[$obj->typent_code]; + } + print ''; + if (empty($object->trueWeight)) { + $tmparray = $object->getTotalWeightVolume(); + print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); + print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1); + } else { + print $object->trueWeight; + print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; + } + print ''; + print dol_print_date($db->jdate($obj->delivery_date), "dayhour"); + print "'; + if ($shipment->shipping_method_id > 0) print $langs->trans("SendingMethod".strtoupper($code)); + print ''.$shipment->tracking_url."'; + print !empty($receiving) ? $receiving->getNomUrl($db) : ''; + print ''; + print dol_print_date($db->jdate($obj->date_reception), "day"); + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$shipment->LibStatut($obj->fk_statut, 5).''.yn($obj->billed).''; + 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 ''; + } + print '
'.$langs->trans('Discounts').''; + print '
'.$langs->trans('Discounts').''; $absolute_discount = $soc->getAvailableDiscounts('', $filterabsolutediscount); $absolute_creditnote = $soc->getAvailableDiscounts('', $filtercreditnote); @@ -393,7 +393,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetAvailability'), 1).'
'; - print ''; + print ''; if ($action == 'editavailability') { $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id, $object->availability_id, 'availability_id', 1); } else { @@ -450,7 +450,7 @@ if ($id > 0 || !empty($ref)) { print 'id.'">'.img_edit($langs->trans('SetDemandReason'), 1).''; } print ''; - print ''; + print ''; if ($action == 'editdemandreason') { $form->formInputReason($_SERVER['PHP_SELF'].'?id='.$object->id, $object->demand_reason_id, 'demand_reason_id', 1); } else { @@ -500,11 +500,11 @@ if ($id > 0 || !empty($ref)) { $totalVolume = $tmparray['volume']; if ($totalWeight || $totalVolume) { print ''.$langs->trans("CalculatedWeight").''; - print ''; + print ''; print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); print ''; print ''.$langs->trans("CalculatedVolume").''; - print ''; + print ''; print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); print ''; } @@ -524,7 +524,7 @@ if ($id > 0 || !empty($ref)) { } print ''; print ''; - print ''; + print ''; if ($action != 'editincoterm') { print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); } else { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 1b5a8079a1e..7f3fb7d8b32 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -295,7 +295,7 @@ if (empty($reshook)) { } if (!$error && empty($conf->global->EXPENSEREPORT_ALLOW_OVERLAPPING_PERIODS)) { - $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin, true); + $overlappingExpenseReportID = $object->periode_existe($fuser, $object->date_debut, $object->date_fin); if ($overlappingExpenseReportID > 0) { $error++; @@ -971,7 +971,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } else { - setEventMessages("NOT_AUTHOR", '', 'errors'); + setEventMessages("NOT_AUTHOR", null, 'errors'); } } @@ -1210,11 +1210,17 @@ if (empty($reshook)) { unset($date); } else { + $error++; setEventMessages($object->error, $object->errors, 'errors'); } } - $action = ''; + if (!$error) { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int')); + exit; + } else { + $action = ''; + } } if ($action == 'confirm_delete_line' && GETPOST("confirm", 'alpha') == "yes" && $user->rights->expensereport->creer) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index ecb1cf3d65b..06adcd92770 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -462,6 +462,8 @@ class ExpenseReport extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -985,6 +987,8 @@ class ExpenseReport extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1328,8 +1332,6 @@ class ExpenseReport extends CommonObject public function set_save_from_refuse($fuser) { // phpcs:enable - global $conf, $langs; - // Sélection de la date de début de la NDF $sql = 'SELECT date_debut'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -1357,6 +1359,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_save_from_refuse expensereport already with save status", LOG_WARNING); } + + return 0; } /** @@ -1465,6 +1469,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::setDeny expensereport already with refuse status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1531,6 +1537,8 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_unpaid expensereport already with unpaid status", LOG_WARNING); } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1553,7 +1561,7 @@ class ExpenseReport extends CommonObject $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= " SET fk_statut = ".self::STATUS_CANCELED.", fk_user_cancel = ".((int) $fuser->id); $sql .= ", date_cancel='".$this->db->idate($this->date_cancel)."'"; - $sql .= " ,detail_cancel='".$this->db->escape($detail)."'"; + $sql .= ", detail_cancel='".$this->db->escape($detail)."'"; $sql .= " WHERE rowid = ".((int) $this->id); dol_syslog(get_class($this)."::set_cancel", LOG_DEBUG); @@ -1585,6 +1593,7 @@ class ExpenseReport extends CommonObject } else { dol_syslog(get_class($this)."::set_cancel expensereport already with cancel status", LOG_WARNING); } + return 0; } /** @@ -1733,9 +1742,9 @@ class ExpenseReport extends CommonObject /** * Update total of an expense report when you add a line. * - * @param string $ligne_total_ht Amount without taxes + * @param string $ligne_total_ht Amount without taxes * @param string $ligne_total_tva Amount of all taxes - * @return void + * @return int */ public function update_totaux_add($ligne_total_ht, $ligne_total_tva) { @@ -1884,7 +1893,7 @@ class ExpenseReport extends CommonObject * * @param int $type Type of line * @param string $seller Seller, but actually he is unknown - * @return true or false + * @return boolean true or false */ public function checkRules($type = 0, $seller = '') { @@ -2179,6 +2188,8 @@ class ExpenseReport extends CommonObject return -2; } } + + return 0; } /** @@ -2572,14 +2583,13 @@ class ExpenseReport extends CommonObject * \brief Compute the cost of the kilometers expense based on the number of kilometers and the vehicule category * * @param int $fk_cat Category of the vehicule used - * @param real $qty Number of kilometers - * @param real $tva VAT rate + * @param float $qty Number of kilometers + * @param float $tva VAT rate * @return int <0 if KO, total ttc if OK */ public function computeTotalKm($fk_cat, $qty, $tva) { - global $langs,$user,$db,$conf; - + global $langs, $db, $conf; $cumulYearQty = 0; $ranges = array(); @@ -2667,6 +2677,44 @@ class ExpenseReport extends CommonObject return -1; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs, $selected,$arrayofselected; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (in_array($this->id, $arrayofselected)) { + $selected = 1; + } + $return .= ''; + if (property_exists($this, 'fk_user_author') && !empty($this->id)) { + $return .= '
'.$this->fk_user_author.''; + } + if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) { + $return .= '
'.dol_print_date($this->date_debut, 'day').''; + $return .= ' '.$langs->trans("To").' '; + $return .= ''.dol_print_date($this->date_fin, 'day').''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -2814,8 +2862,11 @@ class ExpenseReportLine extends CommonObjectLine $this->rule_warning_message = $objp->rule_warning_message; $this->db->free($result); + + return $this->id; } else { dol_print_error($this->db); + return -1; } } @@ -2828,7 +2879,7 @@ class ExpenseReportLine extends CommonObjectLine */ public function insert($notrigger = 0, $fromaddline = false) { - global $langs, $user, $conf; + global $user, $conf; $error = 0; diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index e871cba86b3..053f46d20cf 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -317,7 +317,7 @@ class PaymentExpenseReport extends CommonObject $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; - $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null"); $sql .= " WHERE rowid=".((int) $this->id); @@ -713,4 +713,42 @@ class PaymentExpenseReport extends CommonObject dol_print_error($this->db); } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'datep')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->datep), 'dayhour').''; + } + if (property_exists($this, 'fk_typepayment')) { + $return .= '
'.$langs->trans("Type").' : '.$this->fk_typepayment.''; + } + if (property_exists($this, 'fk_bank') && !is_null($this->fk_bank)) { + $return .= '
'.$langs->trans("Account").' : '.$this->fk_bank.''; + } + if (property_exists($this, 'amount') ) { + $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index fced8a58e14..c8048e78621 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -78,7 +78,7 @@ $childids[] = $user->id; $help_url = "EN:Module_Expense_Reports|FR:Module_Notes_de_frais"; -llxHeader('', $langs->trans("ListOfFees"), $help_url); +llxHeader('', $langs->trans("TripsAndExpenses"), $help_url); $label = $somme = $nb = array(); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index bded18fa597..918c916a52c 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -50,6 +50,7 @@ $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'expensereportlist'; +$mode = GETPOST('mode', 'alpha'); $childids = $user->getAllChildIds(1); @@ -254,7 +255,7 @@ $formexpensereport = new FormExpenseReport($db); $fuser = new User($db); -$title = $langs->trans("ListOfTrips"); +$title = $langs->trans("TripsAndExpenses"); llxHeader('', $title); $max_year = 5; @@ -378,6 +379,9 @@ if ($resql) { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -471,6 +475,7 @@ if ($resql) { print ''; print ''; print ''; + print ''; if ($id > 0) { print ''; } @@ -512,7 +517,10 @@ if ($resql) { if (!empty($socid)) { $url .= '&socid='.$socid; } - $newcardbutton = dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewTrip'), '', 'fa fa-plus-circle', $url, '', $user->rights->expensereport->creer); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'trip', 0, $newcardbutton, '', $limit, 0, 0, 1); } @@ -739,185 +747,204 @@ if ($resql) { $expensereportstatic->note_private = $obj->note_private; $expensereportstatic->note_public = $obj->note_public; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + $usertmp->fetch($obj->id_user); + $expensereportstatic->fk_user_author = $usertmp->getNomUrl(1); - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - 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; + // Output Kanban + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + if ($massactionbutton || $massaction) { + $selected = 0; + + print $expensereportstatic->getKanbanView(''); } - print ''; } - print ''; - } - // Ref - if (!empty($arrayfields['d.ref']['checked'])) { - print ''; - print ''; - print ''; - // Warning late icon and note - print ''; } - if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) { - print img_warning($langs->trans("Late")); - } - if (!empty($obj->note_private) || !empty($obj->note_public)) { - print ' '; - print ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - print ''; - } - print ''; - print ''; - print '
'; - print $expensereportstatic->getNomUrl(1); - print ''; - if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) { - print img_warning($langs->trans("Late")); + if ($i == (min($num, $limit) - 1)) { + print ''; + print '
'; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir); - print '
'; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // User - if (!empty($arrayfields['user']['checked'])) { - print ''; - $usertmp->id = $obj->id_user; - $usertmp->lastname = $obj->lastname; - $usertmp->firstname = $obj->firstname; - $usertmp->login = $obj->login; - $usertmp->statut = $obj->statut; - $usertmp->photo = $obj->photo; - $usertmp->email = $obj->email; - print $usertmp->getNomUrl(-1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Start date - if (!empty($arrayfields['d.date_debut']['checked'])) { - print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // End date - if (!empty($arrayfields['d.date_fin']['checked'])) { - print ''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date validation - if (!empty($arrayfields['d.date_valid']['checked'])) { - print ''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date approval - if (!empty($arrayfields['d.date_approve']['checked'])) { - print ''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['d.total_ht']['checked'])) { - print ''.price($obj->total_ht)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; - } - $totalarray['val']['d.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['d.total_vat']['checked'])) { - print ''.price($obj->total_tva)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; - } - $totalarray['val']['d.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['d.total_ttc']['checked'])) { - print ''.price($obj->total_ttc)."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; - } - $totalarray['val']['d.total_ttc'] += $obj->total_ttc; - } - - // Extra fields - include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; - // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['d.date_create']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_create), 'dayhour'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['d.tms']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['d.fk_statut']['checked'])) { - print ''.$expensereportstatic->getLibStatut(5).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - 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; + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + 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 ''; } - print ''; + print ''; } - print ''; + // Ref + if (!empty($arrayfields['d.ref']['checked'])) { + print ''; + print ''; + print ''; + // Warning late icon and note + print ''; + print ''; + print '
'; + print $expensereportstatic->getNomUrl(1); + print ''; + if ($expensereportstatic->status == 2 && $expensereportstatic->hasDelay('toappove')) { + print img_warning($langs->trans("Late")); + } + if ($expensereportstatic->status == 5 && $expensereportstatic->hasDelay('topay')) { + print img_warning($langs->trans("Late")); + } + if (!empty($obj->note_private) || !empty($obj->note_public)) { + print ' '; + print ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + print ''; + } + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($expensereportstatic->element, $filename, $filedir); + print '
'; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // User + if (!empty($arrayfields['user']['checked'])) { + print ''; + $usertmp->id = $obj->id_user; + $usertmp->lastname = $obj->lastname; + $usertmp->firstname = $obj->firstname; + $usertmp->login = $obj->login; + $usertmp->statut = $obj->statut; + $usertmp->photo = $obj->photo; + $usertmp->email = $obj->email; + print $usertmp->getNomUrl(-1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Start date + if (!empty($arrayfields['d.date_debut']['checked'])) { + print ''.($obj->date_debut > 0 ? dol_print_date($db->jdate($obj->date_debut), 'day') : '').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // End date + if (!empty($arrayfields['d.date_fin']['checked'])) { + print ''.($obj->date_fin > 0 ? dol_print_date($db->jdate($obj->date_fin), 'day') : '').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date validation + if (!empty($arrayfields['d.date_valid']['checked'])) { + print ''.($obj->date_valid > 0 ? dol_print_date($db->jdate($obj->date_valid), 'day') : '').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date approval + if (!empty($arrayfields['d.date_approve']['checked'])) { + print ''.($obj->date_approve > 0 ? dol_print_date($db->jdate($obj->date_approve), 'day') : '').''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['d.total_ht']['checked'])) { + print ''.price($obj->total_ht)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ht'; + } + $totalarray['val']['d.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['d.total_vat']['checked'])) { + print ''.price($obj->total_tva)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_tva'; + } + $totalarray['val']['d.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['d.total_ttc']['checked'])) { + print ''.price($obj->total_ttc)."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'd.total_ttc'; + } + $totalarray['val']['d.total_ttc'] += $obj->total_ttc; + } + + // Extra fields + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; + // Fields from hook + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['d.date_create']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_create), 'dayhour'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['d.tms']['checked'])) { + print ''; + print dol_print_date($db->jdate($obj->date_modif), 'dayhour'); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['d.fk_statut']['checked'])) { + print ''.$expensereportstatic->getLibStatut(5).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + 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 ''; + } + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; } - if (!$i) { - $totalarray['nbfield']++; - } - - print "\n"; - - $total_total_ht = $total_total_ht + $obj->total_ht; - $total_total_tva = $total_total_tva + $obj->total_tva; - $total_total_ttc = $total_total_ttc + $obj->total_ttc; - + $total_total_ht = $total_total_ht + $obj->total_ht; + $total_total_tva = $total_total_tva + $obj->total_tva; + $total_total_ttc = $total_total_ttc + $obj->total_ttc; $i++; } } else { diff --git a/htdocs/expensereport/payment/card.php b/htdocs/expensereport/payment/card.php index db6c21e202f..bdc7b51312a 100644 --- a/htdocs/expensereport/payment/card.php +++ b/htdocs/expensereport/payment/card.php @@ -209,7 +209,7 @@ if ($resql) { print ''.price($objp->total_ttc - $objp->amount).''; // Status - print ''.$expensereport->getLibStatut(4, $objp->amount).''; + print ''.$expensereport->getLibStatut(4).''; print "\n"; diff --git a/htdocs/expensereport/payment/info.php b/htdocs/expensereport/payment/info.php index b5d87b81a51..c1e00ffa0fb 100644 --- a/htdocs/expensereport/payment/info.php +++ b/htdocs/expensereport/payment/info.php @@ -52,7 +52,7 @@ $confirm = GETPOST('confirm', 'alpha'); llxHeader('', $langs->trans("Payment")); $object = new PaymentExpenseReport($db); -$object->fetch($id, $ref); +$object->fetch($id); $object->info($object->id); $head = payment_expensereport_prepare_head($object); diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index cb93aae4ff0..4c838a73b1e 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -48,6 +48,7 @@ $action = GETPOST('action', 'alpha'); $massaction = GETPOST('massaction', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'vendorpaymentlist'; +$mode = GETPOST('mode', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -254,6 +255,9 @@ $num = $db->num_rows($resql); $i = 0; $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) { $param .= '&contextpage='.urlencode($contextpage); } @@ -315,8 +319,13 @@ print ''; print ''; print ''; +print ''; -print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, '', '', $limit, 0, 0, 1); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + +print_barre_liste($langs->trans('ExpenseReportPayments'), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'expensereport', 0, $newcardbutton, '', $limit, 0, 0, 1); if ($search_all) { foreach ($fieldstosearchall as $key => $val) { @@ -473,116 +482,138 @@ while ($i < min($num, $limit)) { $paymentexpensereportstatic->id = $objp->rowid; $paymentexpensereportstatic->ref = $objp->ref; - $paymentexpensereportstatic->datepaye = $objp->datep; + $paymentexpensereportstatic->datep = $objp->datep; + $paymentexpensereportstatic->amount = $objp->pamount; + $paymentexpensereportstatic->fk_typepayment = $objp->paiement_type; + + if ($objp->bid) { + $accountstatic->fetch($objp->bid); + $paymentexpensereportstatic->fk_bank = $accountstatic->getNomUrl(1); + } else { + $paymentexpensereportstatic->fk_bank = null; + } $userstatic->id = $objp->userid; $userstatic->lastname = $objp->lastname; $userstatic->firstname = $objp->firstname; - print ''; + if ($mode == 'kanban') { + if ($i == 0) { + print ''; + print '
'; + } + // Output Kanban + print $paymentexpensereportstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print ''; + } + } else { + print ''; - // No - if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { - print ''.(($offset * $limit) + $i).''; + // No + if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) { + print ''.(($offset * $limit) + $i).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Ref + if (!empty($arrayfields['pndf.rowid']['checked'])) { + print ''.$paymentexpensereportstatic->getNomUrl(1).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['pndf.datep']['checked'])) { + $dateformatforpayment = 'dayhour'; + print ''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Thirdparty + if (!empty($arrayfields['u.login']['checked'])) { + print ''; + if ($userstatic->id > 0) { + print $userstatic->getNomUrl(1); + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Pyament type + if (!empty($arrayfields['c.libelle']['checked'])) { + $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; + print ''.$payment_type.' '.dol_trunc($objp->num_payment, 32).''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Cheque number (fund transfer) + if (!empty($arrayfields['pndf.num_payment']['checked'])) { + print ''.$objp->num_payment.''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Bank account + if (!empty($arrayfields['ba.label']['checked'])) { + print ''; + if ($objp->bid) { + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->blabel; + $accountstatic->number = $objp->number; + $accountstatic->iban = $objp->iban_prefix; + $accountstatic->bic = $objp->bic; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->accountancy_journal); + $accountstatic->accountancy_journal = $accountingjournal->code; + + print $accountstatic->getNomUrl(1); + } else { + print ' '; + } + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount + if (!empty($arrayfields['pndf.amount']['checked'])) { + print ''.price($objp->pamount).''; + if (!$i) { + $totalarray['nbfield']++; + } + $totalarray['pos'][$checkedCount] = 'amount'; + if (empty($totalarray['val']['amount'])) { + $totalarray['val']['amount'] = $objp->pamount; + } else { + $totalarray['val']['amount'] += $objp->pamount; + } + } + + // Buttons + print ''; if (!$i) { $totalarray['nbfield']++; } + + print ''; } - - // Ref - if (!empty($arrayfields['pndf.rowid']['checked'])) { - print ''.$paymentexpensereportstatic->getNomUrl(1).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['pndf.datep']['checked'])) { - $dateformatforpayment = 'dayhour'; - print ''.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Thirdparty - if (!empty($arrayfields['u.login']['checked'])) { - print ''; - if ($userstatic->id > 0) { - print $userstatic->getNomUrl(1); - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Pyament type - if (!empty($arrayfields['c.libelle']['checked'])) { - $payment_type = $langs->trans("PaymentType".$objp->paiement_type) != ("PaymentType".$objp->paiement_type) ? $langs->trans("PaymentType".$objp->paiement_type) : $objp->paiement_libelle; - print ''.$payment_type.' '.dol_trunc($objp->num_payment, 32).''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Cheque number (fund transfer) - if (!empty($arrayfields['pndf.num_payment']['checked'])) { - print ''.$objp->num_payment.''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Bank account - if (!empty($arrayfields['ba.label']['checked'])) { - print ''; - if ($objp->bid) { - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->blabel; - $accountstatic->number = $objp->number; - $accountstatic->iban = $objp->iban_prefix; - $accountstatic->bic = $objp->bic; - $accountstatic->currency_code = $objp->currency_code; - $accountstatic->account_number = $objp->account_number; - - $accountingjournal = new AccountingJournal($db); - $accountingjournal->fetch($objp->accountancy_journal); - $accountstatic->accountancy_journal = $accountingjournal->code; - - print $accountstatic->getNomUrl(1); - } else { - print ' '; - } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount - if (!empty($arrayfields['pndf.amount']['checked'])) { - print ''.price($objp->pamount).''; - if (!$i) { - $totalarray['nbfield']++; - } - $totalarray['pos'][$checkedCount] = 'amount'; - if (empty($totalarray['val']['amount'])) { - $totalarray['val']['amount'] = $objp->pamount; - } else { - $totalarray['val']['amount'] += $objp->pamount; - } - } - - // Buttons - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - - print ''; $i++; } diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index 4591ccd0bf3..f35ae3a3121 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -1187,7 +1187,7 @@ if ($step == 5 && $datatoexport) { $htmltabloflibs .= ''.$langs->trans("LibraryVersion").''; $htmltabloflibs .= ''."\n"; - $liste = $objmodelexport->liste_modeles($db); + $liste = $objmodelexport->listOfAvailableExportFormat($db); $listeall = $liste; foreach ($listeall as $key => $val) { if (preg_match('/__\(Disabled\)__/', $listeall[$key])) { diff --git a/htdocs/exports/index.php b/htdocs/exports/index.php index 41d6cd18ed0..6039a9c447a 100644 --- a/htdocs/exports/index.php +++ b/htdocs/exports/index.php @@ -72,7 +72,7 @@ print ''; include_once DOL_DOCUMENT_ROOT.'/core/modules/export/modules_export.php'; $model = new ModeleExports($db); -$liste = $model->liste_modeles($db); // This is not a static method for exports because method load non static properties +$liste = $model->listOfAvailableExportFormat($db); // This is not a static method for exports because method load non static properties foreach ($liste as $key => $val) { if (preg_match('/__\(Disabled\)__/', $liste[$key])) { diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php index 45779950ea6..bfed76168d5 100644 --- a/htdocs/fichinter/card-rec.php +++ b/htdocs/fichinter/card-rec.php @@ -234,7 +234,7 @@ if ($action == 'add') { } elseif ($action == 'delete' && $user->rights->ficheinter->supprimer) { // delete modele $object->fetch($id); - $object->delete(); + $object->delete($user); $id = 0; header('Location: '.$_SERVER["PHP_SELF"]); exit; @@ -527,7 +527,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -761,7 +761,7 @@ if ($action == 'create') { if ($user->rights->ficheinter->creer) { print ''; } diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index aff1076eda5..accf1bb3cb5 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1177,7 +1177,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 6cd6595432d..78b324c288d 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -64,11 +64,10 @@ class Interventions extends DolibarrApi /** * Get properties of a Expense Report object - * * Return an array with Expense Report information * * @param int $id ID of Expense Report - * @return array|mixed Data without useless information + * @return Object Object with cleaned properties * * @throws RestException */ @@ -93,7 +92,6 @@ class Interventions extends DolibarrApi /** * List of interventions - * * Return a list of interventions * * @param string $sortfield Sort field @@ -336,8 +334,8 @@ class Interventions extends DolibarrApi * "notrigger": 0 * } * - * @param int $id Intervention ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $id Intervention ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * * @url POST {id}/validate * @@ -373,7 +371,7 @@ class Interventions extends DolibarrApi /** * Close an intervention * - * @param int $id Intervention ID + * @param int $id Intervention ID * * @url POST {id}/close * diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index e36598d04bc..450e2c63af3 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -38,7 +38,7 @@ class Fichinter extends CommonObject { public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>'isModEnabled("project")', 'visible'=>-1, 'position'=>20), 'fk_contrat' =>array('type'=>'integer', 'label'=>'Fk contrat', 'enabled'=>'$conf->contrat->enabled', 'visible'=>-1, 'position'=>25), 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>30), @@ -501,6 +501,8 @@ class Fichinter extends CommonObject $this->db->free($resql); return 1; } + + return 0; } else { $this->error = $this->db->lasterror(); return -1; @@ -515,8 +517,6 @@ class Fichinter extends CommonObject */ public function setDraft($user) { - global $langs, $conf; - $error = 0; // Protection @@ -664,6 +664,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } /** @@ -747,25 +749,25 @@ class Fichinter extends CommonObject { // phpcs:enable // Init/load array of translation of status - if (empty($this->statuts) || empty($this->statuts_short) || empty($this->statuts_logo)) { + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { global $langs; $langs->load("fichinter"); - $this->statuts[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->statuts[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->statuts[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); - $this->statuts[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); - $this->statuts_short[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); - $this->statuts_short[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->statuts_short[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); - $this->statuts_short[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); - $this->statuts_logo[self::STATUS_DRAFT] = 'status0'; - $this->statuts_logo[self::STATUS_VALIDATED] = 'status1'; - $this->statuts_logo[self::STATUS_BILLED] = 'status6'; - $this->statuts_logo[self::STATUS_CLOSED] = 'status6'; + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatus[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); + $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); + $this->labelStatusShort[self::STATUS_BILLED] = $langs->transnoentitiesnoconv('StatusInterInvoiced'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Done'); } - return dolGetStatus($this->statuts[$status], $this->statuts_short[$status], '', $this->statuts_logo[$status], $mode); + $statuscode = 'status'.$status; + if ($status == self::STATUS_BILLED || $status == self::STATUS_CLOSED) { + $statuscode = 'status6'; + } + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statuscode, $mode); } /** @@ -904,8 +906,6 @@ class Fichinter extends CommonObject */ public function info($id) { - global $conf; - $sql = "SELECT f.rowid,"; $sql .= " f.datec,"; $sql .= " f.tms as date_modification,"; @@ -955,7 +955,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1074,13 +1074,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who define * @param integer $date_delivery date of delivery - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_date_delivery($user, $date_delivery) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET datei = '".$this->db->idate($date_delivery)."'"; @@ -1096,6 +1094,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -1109,8 +1109,6 @@ class Fichinter extends CommonObject public function set_description($user, $description) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET description = '".$this->db->escape($description)."',"; @@ -1126,6 +1124,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1135,13 +1135,11 @@ class Fichinter extends CommonObject * * @param User $user Object user who modify * @param int $contractid Description - * @return int <0 if ko, >0 if ok + * @return int <0 if KO, >0 if OK */ public function set_contrat($user, $contractid) { // phpcs:enable - global $conf; - if ($user->rights->ficheinter->creer) { $sql = "UPDATE ".MAIN_DB_PREFIX."fichinter "; $sql .= " SET fk_contrat = ".((int) $contractid); @@ -1155,6 +1153,7 @@ class Fichinter extends CommonObject return -1; } } + return -2; } @@ -1228,6 +1227,8 @@ class Fichinter extends CommonObject $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -1261,7 +1262,7 @@ class Fichinter extends CommonObject { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); - if ($this->statut == 0) { + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); // Insertion ligne @@ -1288,6 +1289,8 @@ class Fichinter extends CommonObject return -1; } } + + return 0; } @@ -1300,7 +1303,7 @@ class Fichinter extends CommonObject */ public function initAsSpecimen() { - global $user, $langs, $conf; + global $langs; $now = dol_now(); @@ -1383,18 +1386,18 @@ class Fichinter extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'fichinter' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -1453,6 +1456,39 @@ class Fichinter extends CommonObject return -1; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= '
'.$this->socid.''; + } + if (property_exists($this, 'duration')) { + $return .= '
'.$langs->trans("Duration").' : '.convertSecondToTime($this->duration, 'allhourmin').''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } /** diff --git a/htdocs/fichinter/class/fichinterrec.class.php b/htdocs/fichinter/class/fichinterrec.class.php index 6f9beb5d051..44dd63abcd2 100644 --- a/htdocs/fichinter/class/fichinterrec.class.php +++ b/htdocs/fichinter/class/fichinterrec.class.php @@ -150,7 +150,7 @@ class FichinterRec extends Fichinter $fichintsrc = new Fichinter($this->db); $result = $fichintsrc->fetch($this->id_origin); - $result = $fichintsrc->fetch_lines(1); // to get all lines + $result = $fichintsrc->fetch_lines(); // to get all lines if ($result > 0) { @@ -411,16 +411,13 @@ class FichinterRec extends Fichinter /** * Delete template fichinter rec * - * @param int $rowid Id of fichinter rec to delete. If empty, we delete current instance of fichinter rec - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers - * @param int $idwarehouse Id warehouse to use for stock change. + * @param User $user Object user who delete + * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - public function delete($rowid = 0, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0) { - if (empty($rowid)) { - $rowid = $this->id; - } + $rowid = $this->id; dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG); @@ -664,18 +661,15 @@ class FichinterRec extends Fichinter * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * - * @param string $option ''=Create a specimen fichinter with lines, 'nolines'=No lines * @return void */ - public function initAsSpecimen($option = '') + public function initAsSpecimen() { - global $user, $langs, $conf; + //$now = dol_now(); + //$arraynow = dol_getdate($now); + //$nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - $now = dol_now(); - $arraynow = dol_getdate($now); - $nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']); - - parent::initAsSpecimen($option); + parent::initAsSpecimen(); $this->usenewprice = 1; } @@ -683,16 +677,16 @@ class FichinterRec extends Fichinter /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array('fichinter_rec'); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 02099d959c7..aa0fe5b482f 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -141,7 +141,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 1b388763c02..3b4721d63a0 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -141,7 +141,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php index c556ba022e0..da1af1d613b 100644 --- a/htdocs/fichinter/info.php +++ b/htdocs/fichinter/info.php @@ -96,7 +96,7 @@ if (isModEnabled('project')) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index ecc8c22ab1f..705dac46e50 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -57,6 +57,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'interventionlist'; +$mode = GETPOST('mode', 'alpha'); $search_ref = GETPOST('search_ref') ?GETPOST('search_ref', 'alpha') : GETPOST('search_inter', 'alpha'); $search_ref_client = GETPOST('search_ref_client', 'alpha'); @@ -213,7 +214,7 @@ if (isModEnabled('contrat')) { $now = dol_now(); $help_url = ''; -$title = $langs->trans("ListOfInterventions"); +$title = $langs->trans("Interventions"); $morejs = array(); $morecss = array(); @@ -460,7 +461,10 @@ $url = DOL_URL_ROOT.'/fichinter/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.$socid; } -$newcardbutton = dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewIntervention'), '', 'fa fa-plus-circle', $url, '', $user->rights->ficheinter->creer); print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -498,7 +502,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print ''."\n"; +print '
'."\n"; // Fields title search // -------------------------------------------------------------------- @@ -569,13 +573,13 @@ if (!empty($arrayfields['f.note_private']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; } // Fields of detail line @@ -695,197 +699,219 @@ while ($i < $imaxinloop) { $companystatic->email = $obj->email; $companystatic->status = $obj->thirdpartystatus; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!empty($arrayfields['f.ref']['checked'])) { - print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['f.ref_client']['checked'])) { - // Customer ref - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['f.ref_client']['checked'])) { + // Customer ref + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['pr.ref']['checked'])) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } } - print ''; - if (!$i) { - $totalarray['nbfield']++; + if (!empty($arrayfields['c.ref']['checked'])) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } } - } - if (!empty($arrayfields['c.ref']['checked'])) { - print ''; + 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['f.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note private + if (!empty($arrayfields['f.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Fields of detail of line + if (!empty($arrayfields['fd.description']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['fd.date']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['fd.duree']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['type'][$totalarray['nbfield']] = 'duration'; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + } + $totalarray['val']['fd.duree'] += $obj->duree; + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } if (!$i) { $totalarray['nbfield']++; } - } - if (!empty($arrayfields['f.description']['checked'])) { - print ''; - 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['f.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note private - if (!empty($arrayfields['f.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Fields of detail of line - if (!empty($arrayfields['fd.description']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['fd.date']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['fd.duree']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['type'][$totalarray['nbfield']] = 'duration'; - } - $totalarray['val']['fd.duree'] += $obj->duree; - } - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + print ''."\n"; - print ''."\n"; - - $total += $obj->duree; + $total += $obj->duree; + } $i++; } diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 5b246e55eb7..93bd60e519b 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -106,7 +106,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index 50c28742168..a5b5264052d 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -34,7 +34,7 @@ if (!defined('DOL_APPLICATION_TITLE')) { define('DOL_APPLICATION_TITLE', 'Dolibarr'); } if (!defined('DOL_VERSION')) { - define('DOL_VERSION', '18.0.0-beta'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c + define('DOL_VERSION', '18.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c } if (!defined('EURO')) { @@ -138,10 +138,10 @@ if (!empty($dolibarr_main_prod)) { } // Clean parameters -$dolibarr_main_data_root = trim($dolibarr_main_data_root); -$dolibarr_main_url_root = trim(preg_replace('/\/+$/', '', $dolibarr_main_url_root)); +$dolibarr_main_data_root = (empty($dolibarr_main_data_root) ? '' : trim($dolibarr_main_data_root)); +$dolibarr_main_url_root = trim(preg_replace('/\/+$/', '', empty($dolibarr_main_url_root) ? '' : $dolibarr_main_url_root)); $dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ? '' : trim($dolibarr_main_url_root_alt)); -$dolibarr_main_document_root = trim($dolibarr_main_document_root); +$dolibarr_main_document_root = (empty($dolibarr_main_document_root) ? '' : trim($dolibarr_main_document_root)); $dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt)); if (empty($dolibarr_main_db_port)) { diff --git a/htdocs/fourn/ajax/getSupplierPrices.php b/htdocs/fourn/ajax/getSupplierPrices.php index 29cf421059e..66001ccc5a6 100644 --- a/htdocs/fourn/ajax/getSupplierPrices.php +++ b/htdocs/fourn/ajax/getSupplierPrices.php @@ -88,7 +88,7 @@ if ($idprod > 0) { $label .= ' ('.$productSupplier->fourn_ref.')'; } - $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, 0, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() + $prices[] = array("id" => $productSupplier->product_fourn_price_id, "price" => price2num($price, '', 0), "label" => $label, "title" => $title); // For price field, we must use price2num(), for label or title, price() } } diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 90a760e14a1..19335656f51 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -98,7 +98,8 @@ if (empty($reshook)) { $action = ""; } - if ($action == 'setsupplieraccountancycode') { + // Set supplier accounting account + if ($action == 'setsupplieraccountancycode' && $user->hasRight('societe', 'creer')) { $result = $object->fetch($id); $object->code_compta_fournisseur = GETPOST("supplieraccountancycode"); $result = $object->update($object->id, $user, 1, 0, 1); @@ -106,8 +107,17 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } + // Set vat number accounting account + if ($action == 'settva_intra' && $user->hasRight('societe', 'creer')) { + $result = $object->fetch($id); + $object->tva_intra = GETPOST("tva_intra"); + $result = $object->update($object->id, $user, 1, 0, 0); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } // Set payment terms of the settlement - if ($action == 'setconditions' && $user->rights->societe->creer) { + if ($action == 'setconditions' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int')); if ($result < 0) { @@ -115,7 +125,7 @@ if (empty($reshook)) { } } // Payment mode - if ($action == 'setmode' && $user->rights->societe->creer) { + if ($action == 'setmode' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int')); if ($result < 0) { @@ -124,7 +134,7 @@ if (empty($reshook)) { } // Bank account - if ($action == 'setbankaccount' && $user->rights->societe->creer) { + if ($action == 'setbankaccount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $result = $object->setBankAccount(GETPOST('fk_account', 'int')); if ($result < 0) { @@ -133,7 +143,7 @@ if (empty($reshook)) { } // update supplier order min amount - if ($action == 'setsupplier_order_min_amount') { + if ($action == 'setsupplier_order_min_amount' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->supplier_order_min_amount = price2num(GETPOST('supplier_order_min_amount', 'alpha')); $result = $object->update($object->id, $user); @@ -142,7 +152,7 @@ if (empty($reshook)) { } } - if ($action == 'update_extras') { + if ($action == 'update_extras' && $user->hasRight('societe', 'creer')) { $object->fetch($id); $object->oldcopy = dol_clone($object); @@ -261,8 +271,12 @@ if ($object->id > 0) { } // TVA Intra - print ''; // Default terms of the settlement diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index d55a398dbd6..1b7098d9cc5 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -288,6 +288,155 @@ class SupplierOrders extends DolibarrApi return false; } + /** + * Get contacts of given supplier order + * + * Return an array with contact informations + * + * @param int $id ID of supplier order + * @param string $source Source of the contact (internal, external, all). + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) + * @return Object Object with cleaned properties + * + * @url GET {id}/contacts + * + * @throws RestException + */ + public function getContacts($id, $source, $type = '') + { + if (!DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } + + $result = $this->order->fetch($id); + if (!$result) { + throw new RestException(404, 'Supplier order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $contacts = array(); + + if ($source == 'all' || $source == 'external') { + $tmpContacts = $this->order->liste_contact(-1, 'external', 0, $type); + $contacts = array_merge($contacts, $tmpContacts); + } + + if ($source == 'all' || $source == 'internal') { + $tmpContacts = $this->order->liste_contact(-1, 'internal', 0, $type); + $contacts = array_merge($contacts, $tmpContacts); + } + + return $this->_cleanObjectDatas($contacts); + } + + /** + * Add a contact type of given supplier order + * + * @param int $id Id of supplier order to update + * @param int $contactid Id of contact/user to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...) + * @param string $source Source of the contact (external, internal) + * @return array + * + * @url POST {id}/contact/{contactid}/{type}/{source} + * + * @throws RestException 401 + * @throws RestException 404 + */ + public function postContact($id, $contactid, $type, $source) + { + if (!DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + + $result = $this->order->fetch($id); + if (!$result) { + throw new RestException(404, 'Supplier order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->order->add_contact($contactid, $type, $source); + + if ($result < 0) { + throw new RestException(500, 'Error when added the contact'); + } + + if ($result == 0) { + throw new RestException(304, 'contact already added'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the order' + ) + ); + } + + /** + * Unlink a contact type of given supplier order + * + * @param int $id Id of supplier order to update + * @param int $contactid Id of contact/user to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER, SALESREPFOLL, ...). + * @param string $source Source of the contact (internal, external). + * + * @url DELETE {id}/contact/{contactid}/{type}/{source} + * + * @return array + * + * @throws RestException 401 + * @throws RestException 404 + * @throws RestException 500 System error + */ + public function deleteContact($id, $contactid, $type, $source) + { + if (!DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + + $result = $this->order->fetch($id); + if (!$result) { + throw new RestException(404, 'Supplier order not found'); + } + + if (!DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, 'commande_fournisseur', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->order->liste_contact(-1, $source, 0, $type); + + $contactToUnlink = 0; + foreach ($contacts as $contact) { + if ($contact['id'] == $contactid && $contact['code'] == $type) { + $contactToUnlink = $contact['rowid']; + break; + } + } + + if ($contactToUnlink == 0) { + throw new RestException(404, 'Linked contact not found'); + } + + $result = $this->order->delete_contact($contact['rowid']); + + if (!$result) { + throw new RestException(500, 'Error when deleted the contact'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact unlinked from supplier order' + ) + ); + } + /** * Delete supplier order * diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index baed7051ef8..30dc5c17425 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -209,17 +209,17 @@ class Fournisseur extends Societe /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old third-party id - * @param int $dest_id New third-party id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_fourn' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 4fc242bdbcc..94415f5f1f3 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -254,7 +254,7 @@ class CommandeFournisseur extends CommonOrder 'multicurrency_total_tva' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountVAT', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>235), 'multicurrency_total_ttc' =>array('type'=>'double(24,8)', 'label'=>'MulticurrencyAmountTTC', 'enabled'=>'isModEnabled("multicurrency")', 'visible'=>-1, 'position'=>240), 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>500), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>1, 'notnull'=>1, 'position'=>46), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>1, 'notnull'=>1, 'position'=>46), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>1000, 'index'=>1), 'tms'=>array('type'=>'datetime', 'label'=>"DateModificationShort", 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>501), 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>0, 'position'=>700), @@ -1594,7 +1594,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); @@ -1704,6 +1704,8 @@ class CommandeFournisseur extends CommonOrder $action = ''; $reshook = $hookmanager->executeHooks('createFrom', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { + $this->errors += $hookmanager->errors; + $this->error = $hookmanager->error; $error++; } } @@ -2139,6 +2141,16 @@ class CommandeFournisseur extends CommonOrder return 0; } + // check if not yet received + $dispatchedLines = $this->getDispachedLines(); + foreach ($dispatchedLines as $dispatchLine) { + if ($dispatchLine['orderlineid'] == $idline) { + $this->error = "LineAlreadyDispatched"; + $this->errors[] = $this->error; + return -3; + } + } + if ($line->delete($notrigger) > 0) { $this->update_price(1); return 1; @@ -2327,7 +2339,7 @@ class CommandeFournisseur extends CommonOrder // List of already dispatched lines $sql = "SELECT p.ref, p.label,"; $sql .= " e.rowid as warehouse_id, e.ref as entrepot,"; - $sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status"; + $sql .= " cfd.rowid as dispatchedlineid, cfd.fk_product, cfd.qty, cfd.eatby, cfd.sellby, cfd.batch, cfd.comment, cfd.status, cfd.fk_commandefourndet"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e ON cfd.fk_entrepot = e.rowid"; @@ -2351,6 +2363,7 @@ class CommandeFournisseur extends CommonOrder 'productid' => $objp->fk_product, 'warehouseid' => $objp->warehouse_id, 'qty' => $objp->qty, + 'orderlineid' => $objp->fk_commandefourndet ); } @@ -3265,18 +3278,18 @@ class CommandeFournisseur extends CommonOrder /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande_fournisseur' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3544,6 +3557,39 @@ class CommandeFournisseur extends CommonOrder return -1; } } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + if (property_exists($this, 'socid') || property_exists($this, 'total_tva')) { + $return .='
'.$this->socid.''; + } + if (property_exists($this, 'billed')) { + $return .= '
'.$langs->trans("Billed").' : '.yn($this->billed).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -3901,8 +3947,8 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ", vat_src_code = '".(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'"; $sql .= ", tva_tx='".price2num($this->tva_tx)."'"; - $sql .= ", localtax1_tx='".price2num($this->total_localtax1)."'"; - $sql .= ", localtax2_tx='".price2num($this->total_localtax2)."'"; + $sql .= ", localtax1_tx='".price2num($this->localtax1_tx)."'"; + $sql .= ", localtax2_tx='".price2num($this->localtax2_tx)."'"; $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= ", qty='".price2num($this->qty)."'"; @@ -3919,10 +3965,10 @@ class CommandeFournisseurLigne extends CommonOrderLine $sql .= ($this->fk_unit ? ", fk_unit='".$this->db->escape($this->fk_unit)."'" : ", fk_unit=null"); // Multicurrency - $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= ", multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= ", multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 7c8e4acb25f..02fbff5b363 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -218,7 +218,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine $sql .= " ".(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").","; $sql .= " ".(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").","; $sql .= " ".(!isset($this->fk_reception) ? 'NULL' : "'".$this->db->escape($this->fk_reception)."'").","; - $sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'").""; + $sql .= " ".(!isset($this->cost_price) ? '0' : "'".$this->db->escape($this->cost_price)."'"); $sql .= ")"; $this->db->begin(); @@ -396,7 +396,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; $sql .= " batch=".(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").","; $sql .= " eatby=".(dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').","; - $sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').""; + $sql .= " sellby=".(dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); diff --git a/htdocs/fourn/class/fournisseur.facture-rec.class.php b/htdocs/fourn/class/fournisseur.facture-rec.class.php index 738e27a84e9..8964213f83d 100644 --- a/htdocs/fourn/class/fournisseur.facture-rec.class.php +++ b/htdocs/fourn/class/fournisseur.facture-rec.class.php @@ -181,7 +181,7 @@ class FactureFournisseurRec extends CommonInvoice 'titre' =>array('type'=>'varchar(100)', 'label'=>'Titre', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>15), 'ref_supplier' =>array('type'=>'varchar(180)', 'label'=>'RefSupplier', 'enabled'=>1, 'showoncombobox' => 1, 'visible'=>-1, 'position'=>20), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25, 'index'=>1), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>30), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>30), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>35), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>40), 'suspended' =>array('type'=>'integer', 'label'=>'Suspended', 'enabled'=>1, 'visible'=>-1, 'position'=>225), @@ -1331,7 +1331,7 @@ class FactureFournisseurRec extends CommonInvoice // We refresh the object in order to have all necessary data (like date_lim_reglement) $new_fac_fourn->fetch($new_fac_fourn->id); $result = $new_fac_fourn->generateDocument($facturerec->model_pdf, $langs); - if ($result <= 0) { + if ($result < 0) { $this->errors = $new_fac_fourn->errors; $this->error = $new_fac_fourn->error; $error++; @@ -1737,18 +1737,18 @@ class FactureFournisseurRec extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_rec' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index adf9fac3bde..2c45a8d67d5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -275,7 +275,7 @@ class FactureFournisseur extends CommonInvoice 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>25, 'index'=>1), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>30), 'type' =>array('type'=>'smallint(6)', 'label'=>'Type', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>35), - 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'$conf->societe->enabled', 'visible'=>-1, 'notnull'=>1, 'position'=>40), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>'isModEnabled("societe")', 'visible'=>-1, 'notnull'=>1, 'position'=>40), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'datef' =>array('type'=>'date', 'label'=>'Date', 'enabled'=>1, 'visible'=>-1, 'position'=>50), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>55), @@ -852,15 +852,18 @@ class FactureFournisseur extends CommonInvoice } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id supplier invoice - * @param string $ref Ref supplier invoice - * @return int <0 if KO, >0 if OK, 0 if not found + * @param int $id Id supplier invoice + * @param string $ref Ref supplier invoice + * @param string $ref_ext External reference of invoice + * @return int <0 if KO, >0 if OK, 0 if not found */ - public function fetch($id = '', $ref = '') + public function fetch($id = '', $ref = '', $ref_ext = '') { - global $langs; + if (empty($id) && empty($ref) && empty($ref_ext)) { + return -1; + } $sql = "SELECT"; $sql .= " t.rowid,"; @@ -911,10 +914,15 @@ class FactureFournisseur extends CommonInvoice $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON t.fk_mode_reglement = p.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON t.fk_incoterms = i.rowid'; if ($id) { - $sql .= " WHERE t.rowid=".((int) $id); - } - if ($ref) { - $sql .= " WHERE t.ref='".$this->db->escape($ref)."' AND t.entity IN (".getEntity('supplier_invoice').")"; + $sql .= " WHERE t.rowid = ".((int) $id); + } else { + $sql .= ' WHERE t.entity IN ('.getEntity('supplier_invoice').')'; // Don't use entity if you use rowid + if ($ref) { + $sql .= " AND t.ref = '".$this->db->escape($ref)."'"; + } + if ($ref_ext) { + $sql .= " AND t.ref_ext = '".$this->db->escape($ref_ext)."'"; + } } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -1259,7 +1267,7 @@ class FactureFournisseur extends CommonInvoice $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").","; - $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null").""; + $sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null"); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -1383,7 +1391,7 @@ class FactureFournisseur extends CommonInvoice $result = $this->update_price(1); if ($result > 0) { // Create link between discount and invoice line - $result = $remise->link_to_invoice($lineid, 0, 'supplier'); + $result = $remise->link_to_invoice($lineid, 0); if ($result < 0) { $this->error = $remise->error; $this->db->rollback(); @@ -3154,18 +3162,18 @@ class FactureFournisseur extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'facture_fourn' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** @@ -3225,6 +3233,44 @@ class FactureFournisseur extends CommonInvoice return $isUsed; } + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'socid')) { + $return .= ' | '.$this->socid.''; + } + if (property_exists($this, 'date_echeance') && property_exists($this, 'date')) { + if (!empty($this->date_echeance)) { + $return .= '
'.dol_print_date($this->date_echeance).''; + } else { + $return .= '
'.dol_print_date($this->date).''; + } + } + if (property_exists($this, 'total_ht')) { + $return .= '
'.$langs->trans("AmountHT").' : '.price($this->total_ht).''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } @@ -3692,10 +3738,10 @@ class SupplierInvoiceLine extends CommonObjectLine } // Multicurrency - $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; - $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; - $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; - $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; + $sql .= " , multicurrency_subprice=".price2num($this->multicurrency_subprice); + $sql .= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht); + $sql .= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva); + $sql .= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc); $sql .= " WHERE rowid = ".((int) $this->id); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 1d764cee490..4245afe62b5 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -1003,35 +1003,35 @@ class ProductFournisseur extends Product /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'product_fournisseur_price' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'product_fournisseur_price' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index f559c31a89f..48e74d223e6 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -76,7 +76,6 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'purchaseordercard'; // To manage different context of search - $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); @@ -125,12 +124,7 @@ if ($id > 0 || !empty($ref)) { dol_print_error($db, $object->error); } } elseif (!empty($socid) && $socid > 0) { - $fourn = new Fournisseur($db); - $ret = $fourn->fetch($socid); - if ($ret < 0) { - dol_print_error($db, $object->error); - } - $object->socid = $fourn->id; + $object->socid = $socid; $ret = $object->fetch_thirdparty(); if ($ret < 0) { dol_print_error($db, $object->error); @@ -1391,6 +1385,7 @@ if (empty($reshook)) { $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); $error++; } } else { @@ -1701,16 +1696,16 @@ if ($action == 'create') { print img_picto('', 'company').$form->select_company((empty($socid) ? '' : $socid), 'socid', '(s.fournisseur=1 AND s.status=1)', 'SelectThirdParty', 1, 0, null, 0, 'minwidth175 maxwidth500 widthcentpercentminusxx'); // reload page to retrieve customer informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { - print ''; + '; } print ' '; } @@ -1874,19 +1869,13 @@ if ($action == 'create') { print "\n"; } elseif (!empty($object->id)) { $result = $object->fetch($id, $ref); + $object->fetch_thirdparty(); - $societe = new Fournisseur($db); - $result = $societe->fetch($object->socid); - if ($result < 0) { - dol_print_error($db); - } + $societe = $object->thirdparty; $author = new User($db); $author->fetch($object->user_author_id); - $res = $object->fetch_optionals(); - - $head = ordersupplier_prepare_head($object); $title = $langs->trans("SupplierOrder"); @@ -2061,7 +2050,7 @@ if ($action == 'create') { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2415,7 +2404,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + $object->printObjectLines($action, $object->thirdparty, $mysoc, $lineid, 1); } $num = count($object->lines); @@ -2665,7 +2654,8 @@ if ($action == 'create') { $formorder->selectInputMethod(GETPOST('methodecommande'), "methodecommande", 1); print ''; - print ''; + print ''; + print ''; - print ''; + print ''; print ''; //Remote User - print ''; + print ''; //Remote Password - print ''; + print ''; //Submit button print ''; if (empty($conf->cache['product'][$objp->fk_product])) { @@ -860,7 +861,7 @@ if ($id > 0 || !empty($ref)) { print ''; // Already dispatched - print ''; + print ''; if (isModEnabled('productbatch') && $objp->tobatch > 0) { $type = 'batch'; diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index b3dfb8b9ece..d11c08ec91d 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -140,7 +140,7 @@ if ($object->id > 0) { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index fc3918a32f3..654845f59aa 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -153,7 +153,7 @@ if (isModEnabled('project')) { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -196,7 +196,7 @@ if ($permok) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 3d458247bcf..394660f3866 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -56,6 +56,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'supplierorderlist'; +$mode = GETPOST('mode', 'alpha'); // Search Criteria $search_date_order_startday = GETPOST('search_date_order_startday', 'int'); @@ -576,6 +577,9 @@ if (empty($reshook)) { // Make a redirect to avoid to bill twice if we make a refresh or back $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -998,6 +1002,9 @@ if ($resql) { llxHeader('', $title, $help_url); $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -1184,7 +1191,10 @@ if ($resql) { $url .= '&socid='.((int) $socid); $url .= '&backtopage='.urlencode(DOL_URL_ROOT.'/fourn/commande/list.php?socid='.((int) $socid)); } - $newcardbutton = dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('NewSupplierOrderShort'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); // Lines of title fields print '
'; @@ -1198,17 +1208,18 @@ if ($resql) { print ''; print ''; print ''; + print ''; print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'supplier_order', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "SendOrderRef"; $modelmail = "order_supplier_send"; - $objecttmp = new CommandeFournisseur($db); + $objecttmp = new CommandeFournisseur($db); // in case $object is not the good object $trackid = 'sord'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($massaction == 'prevalidate') { - print $form->formconfirm($_SERVER["PHP_SELF"].$fieldstosearchall, $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassValidation"), $langs->trans("ConfirmMassValidationQuestion"), "validate", null, '', 0, 200, 500, 1); } if ($massaction == 'createbills') { @@ -1469,8 +1480,8 @@ if ($resql) { } // Status billed if (!empty($arrayfields['cf.billed']['checked'])) { - print '
'; } // Date valid @@ -1660,344 +1671,365 @@ if ($resql) { $objectstatic->note_private = $obj->note_private; $objectstatic->statut = $obj->fk_statut; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - // Ref - if (!empty($arrayfields['cf.ref']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Ref Supplier - if (!empty($arrayfields['cf.ref_supplier']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Project - if (!empty($arrayfields['cf.fk_projet']['checked'])) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_title; - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Author - $userstatic->id = $obj->fk_user_author; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->login = $obj->login; - $userstatic->photo = $obj->photo; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_status; - if (!empty($arrayfields['u.login']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Thirdparty - if (!empty($arrayfields['cf.fk_soc']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; + $objectstatic->socid = $thirdpartytmp->getNomUrl('supplier', 0, 0, -1); + // Output Kanban + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - } - //alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''."\n"; - if (!$i) { - $totalarray['nbfield']++; + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } + // Ref + if (!empty($arrayfields['cf.ref']['checked'])) { + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Plannned date of delivery - if (!empty($arrayfields['cf.date_livraison']['checked'])) { - print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; } } - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; - } - $totalarray['val']['cf.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['cf.total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; - } - $totalarray['val']['cf.total_tva'] += $obj->total_tva; - } - // Amount TTC - if (!empty($arrayfields['cf.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; - } - $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; - } - - // Currency - if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Currency rate - if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount HT - if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount VAT - if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Amount TTC - if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { - print '\n"; - 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Date creation - if (!empty($arrayfields['cf.date_creation']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['cf.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['cf.fk_statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Billed - if (!empty($arrayfields['cf.billed']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // valid date - if (!empty($arrayfields['cf.date_valid']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // approve date - if (!empty($arrayfields['cf.date_approve']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Note public - if (!empty($arrayfields['cf.note_public']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Note private - if (!empty($arrayfields['cf.note_private']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Author + $userstatic->id = $obj->fk_user_author; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->login = $obj->login; + $userstatic->photo = $obj->photo; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_status; + if (!empty($arrayfields['u.login']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Thirdparty + if (!empty($arrayfields['cf.fk_soc']['checked'])) { + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + //alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''."\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Order date + if (!empty($arrayfields['cf.date_commande']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Plannned date of delivery + if (!empty($arrayfields['cf.date_livraison']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cf.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ht'; + } + $totalarray['val']['cf.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['cf.total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_tva'; + } + $totalarray['val']['cf.total_tva'] += $obj->total_tva; + } + // Amount TTC + if (!empty($arrayfields['cf.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'cf.total_ttc'; + } + $totalarray['val']['cf.total_ttc'] += $obj->total_ttc; + } - $total += $obj->total_ht; - $subtotal += $obj->total_ht; + // Currency + if (!empty($arrayfields['cf.multicurrency_code']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Currency rate + if (!empty($arrayfields['cf.multicurrency_tx']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount HT + if (!empty($arrayfields['cf.multicurrency_total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount VAT + if (!empty($arrayfields['cf.multicurrency_total_tva']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Amount TTC + if (!empty($arrayfields['cf.multicurrency_total_ttc']['checked'])) { + print '\n"; + 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Date creation + if (!empty($arrayfields['cf.date_creation']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['cf.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['cf.fk_statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Billed + if (!empty($arrayfields['cf.billed']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // valid date + if (!empty($arrayfields['cf.date_valid']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // approve date + if (!empty($arrayfields['cf.date_approve']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Note public + if (!empty($arrayfields['cf.note_public']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Note private + if (!empty($arrayfields['cf.note_private']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + + $total += $obj->total_ht; + $subtotal += $obj->total_ht; + } $i++; } diff --git a/htdocs/fourn/commande/note.php b/htdocs/fourn/commande/note.php index 33648dd9817..d1f21b0a2ee 100644 --- a/htdocs/fourn/commande/note.php +++ b/htdocs/fourn/commande/note.php @@ -122,7 +122,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php index 192a39c9b06..e2e9fb5f899 100644 --- a/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/fourn/commande/tpl/linkedobjectblock.tpl.php @@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { ?> - + '; } // Action column @@ -1430,409 +1412,423 @@ if ($num > 0) { $remaintopay = -$facturestatic->getSumFromThisCreditNotesNotUsed(); } } - - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - print ''; - } - if (!empty($arrayfields['f.ref']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Supplier ref - if (!empty($arrayfields['f.ref_supplier']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Type - if (!empty($arrayfields['f.type']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Label - if (!empty($arrayfields['f.label']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date - if (!empty($arrayfields['f.datef']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Date limit - if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Project - if (!empty($arrayfields['p.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Third party - if (!empty($arrayfields['s.nom']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Alias - if (!empty($arrayfields['s.name_alias']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Town - if (!empty($arrayfields['s.town']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Zip - if (!empty($arrayfields['s.zip']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // State - if (!empty($arrayfields['state.nom']['checked'])) { - print "\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Country - if (!empty($arrayfields['country.code_iso']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Type ent - if (!empty($arrayfields['typent.code']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Payment condition - if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { - $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Payment mode - if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { - $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Amount HT - if (!empty($arrayfields['f.total_ht']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; - } - $totalarray['val']['f.total_ht'] += $obj->total_ht; - } - // Amount VAT - if (!empty($arrayfields['f.total_vat']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; - } - $totalarray['val']['f.total_vat'] += $obj->total_vat; - } - // Amount LocalTax1 - if (!empty($arrayfields['f.total_localtax1']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; - } - $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; - } - // Amount LocalTax2 - if (!empty($arrayfields['f.total_localtax2']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; - } - $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; - } - // Amount TTC - if (!empty($arrayfields['f.total_ttc']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; - } - $totalarray['val']['f.total_ttc'] += $obj->total_ttc; - } - - $userstatic->id = $obj->fk_user_author; - $userstatic->login = $obj->login; - $userstatic->lastname = $obj->lastname; - $userstatic->firstname = $obj->firstname; - $userstatic->email = $obj->user_email; - $userstatic->statut = $obj->user_statut; - $userstatic->entity = $obj->entity; - $userstatic->photo = $obj->photo; - $userstatic->office_phone = $obj->office_phone; - $userstatic->office_fax = $obj->office_fax; - $userstatic->user_mobile = $obj->user_mobile; - $userstatic->job = $obj->job; - $userstatic->gender = $obj->gender; - - // Author - if (!empty($arrayfields['u.login']['checked'])) { - print '\n"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - if (!empty($arrayfields['dynamount_payed']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; - } - $totalarray['val']['totalam'] += $totalpay; - } - - if (!empty($arrayfields['rtp']['checked'])) { - print ''; // TODO Use a denormalized field - if (!$i) { - $totalarray['nbfield']++; - } - if (!$i) { - $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; - } - $totalarray['val']['rtp'] += $remaintopay; - } - - // Currency - if (!empty($arrayfields['f.multicurrency_code']['checked'])) { - print '\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 - $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['f.datec']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date modification - if (!empty($arrayfields['f.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Status - if (!empty($arrayfields['f.fk_statut']['checked'])) { - print '"; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } - print "\n"; + // Supplier ref + if (!empty($arrayfields['f.ref_supplier']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type + if (!empty($arrayfields['f.type']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Label + if (!empty($arrayfields['f.label']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date + if (!empty($arrayfields['f.datef']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Date limit + if (!empty($arrayfields['f.date_lim_reglement']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Project + if (!empty($arrayfields['p.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Third party + if (!empty($arrayfields['s.nom']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Alias + if (!empty($arrayfields['s.name_alias']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Town + if (!empty($arrayfields['s.town']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Zip + if (!empty($arrayfields['s.zip']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // State + if (!empty($arrayfields['state.nom']['checked'])) { + print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Country + if (!empty($arrayfields['country.code_iso']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Type ent + if (!empty($arrayfields['typent.code']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Payment condition + if (!empty($arrayfields['f.fk_cond_reglement']['checked'])) { + $s = $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', 1, '', -1, -1, 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Payment mode + if (!empty($arrayfields['f.fk_mode_reglement']['checked'])) { + $s = $form->form_modes_reglement($_SERVER['PHP_SELF'], $obj->fk_mode_reglement, 'none', '', -1, 0, '', 1); + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Amount HT + if (!empty($arrayfields['f.total_ht']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ht'; + } + $totalarray['val']['f.total_ht'] += $obj->total_ht; + } + // Amount VAT + if (!empty($arrayfields['f.total_vat']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_vat'; + } + $totalarray['val']['f.total_vat'] += $obj->total_vat; + } + // Amount LocalTax1 + if (!empty($arrayfields['f.total_localtax1']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax1'; + } + $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1; + } + // Amount LocalTax2 + if (!empty($arrayfields['f.total_localtax2']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_localtax2'; + } + $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2; + } + // Amount TTC + if (!empty($arrayfields['f.total_ttc']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'f.total_ttc'; + } + $totalarray['val']['f.total_ttc'] += $obj->total_ttc; + } + + $userstatic->id = $obj->fk_user_author; + $userstatic->login = $obj->login; + $userstatic->lastname = $obj->lastname; + $userstatic->firstname = $obj->firstname; + $userstatic->email = $obj->user_email; + $userstatic->statut = $obj->user_statut; + $userstatic->entity = $obj->entity; + $userstatic->photo = $obj->photo; + $userstatic->office_phone = $obj->office_phone; + $userstatic->office_fax = $obj->office_fax; + $userstatic->user_mobile = $obj->user_mobile; + $userstatic->job = $obj->job; + $userstatic->gender = $obj->gender; + + // Author + if (!empty($arrayfields['u.login']['checked'])) { + print '\n"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + if (!empty($arrayfields['dynamount_payed']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalam'; + } + $totalarray['val']['totalam'] += $totalpay; + } + + if (!empty($arrayfields['rtp']['checked'])) { + print ''; // TODO Use a denormalized field + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'rtp'; + } + $totalarray['val']['rtp'] += $remaintopay; + } + + // Currency + if (!empty($arrayfields['f.multicurrency_code']['checked'])) { + print '\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 + $parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['f.datec']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date modification + if (!empty($arrayfields['f.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Status + if (!empty($arrayfields['f.fk_statut']['checked'])) { + print '"; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print "\n"; + } $i++; } diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 1c61fdc8e07..c8178e39d74 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -121,7 +121,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index 6222d3db8bd..e6c1aac1372 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -98,41 +98,6 @@ $mesg = ''; * ACTIONS */ -// Submit file -if (GETPOST("sendit") && !empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $result = $ecmdir->fetch(GETPOST("section", 'int')); - if (!($result > 0)) { - dol_print_error($db, $ecmdir->error); - exit; - } - $relativepath = $ecmdir->getRelativePath(); - $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; - - if (dol_mkdir($upload_dir) >= 0) { - $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir."/".dol_unescapefile($_FILES['userfile']['name']), 0); - if (is_numeric($resupload) && $resupload > 0) { - $result = $ecmdir->changeNbOfFiles('+'); - } else { - $langs->load("errors"); - if ($resupload < 0) { // Unknown error - setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); - } elseif (preg_match('/ErrorFileIsInfectedWithAVirus/', $resupload)) { - // Files infected by a virus - setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); - } else // Known error - { - setEventMessages($langs->trans($resupload), null, 'errors'); - } - } - } else { - // Transfer failure (file exceeding the limit ?) - $langs->load("errors"); - setEventMessages($langs->trans("ErrorFailToCreateDir", $upload_dir), null, 'errors'); - } -} - if ($action == 'uploadfile') { // set up a connection or die if (!$conn_id) { @@ -189,6 +154,7 @@ if ($action == 'addfolder') { // Action ajout d'un rep if ($action == 'add' && $user->rights->ftp->setup) { + $ecmdir = new EcmDirectory($db); $ecmdir->ref = GETPOST("ref"); $ecmdir->label = GETPOST("label"); $ecmdir->description = GETPOST("desc"); @@ -317,7 +283,7 @@ if ($action == 'download') { $newsection = $section; - $result = dol_ftp_get($connect_id, $localfile, $file, $newsection); + $result = dol_ftp_get($conn_id, $localfile, $file, $newsection); if ($result) { @@ -341,9 +307,9 @@ if ($action == 'download') { header('Content-Type: '.$type); } if ($attachment) { - header('Content-Disposition: attachment; filename="'.$filename.'"'); + header('Content-Disposition: attachment; filename="'.$file.'"'); } else { - header('Content-Disposition: inline; filename="'.$filename.'"'); + header('Content-Disposition: inline; filename="'.$file.'"'); } // Ajout directives pour resoudre bug IE @@ -354,7 +320,7 @@ if ($action == 'download') { exit; } else { - setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $remotefile), null, 'errors'); + setEventMessages($langs->transnoentitiesnoconv('FailedToGetFile', $file), null, 'errors'); } } else { dol_print_error('', $mesg); @@ -661,6 +627,7 @@ if (!function_exists('ftp_connect')) { print ''; print ""; + if ($user->hasRight('ftp', 'write')) { print load_fiche_titre($langs->trans("AttachANewFile"), null, null); print ''; @@ -672,6 +639,9 @@ if (!function_exists('ftp_connect')) { print ''; print ''; print ''; + + print '

'; + print load_fiche_titre($langs->trans("AddFolder"), null, null); print ''; print ''; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 0125becd21c..e4a82be6ea7 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1470,7 +1470,7 @@ class Holiday extends CommonObject $sql .= " value = '".$this->db->escape($value)."'"; $sql .= " WHERE name = '".$this->db->escape($name)."'"; - dol_syslog(get_class($this).'::updateConfCP name='.$name.'', LOG_DEBUG); + dol_syslog(get_class($this).'::updateConfCP name='.$name, LOG_DEBUG); $result = $this->db->query($sql); if ($result) { return true; @@ -1580,7 +1580,7 @@ class Holiday extends CommonObject // We add a log for each user $this->addLogCP($user->id, $userCounter['rowid'], $langs->trans('HolidaysMonthlyUpdate'), $newSolde, $userCounter['type']); - $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type'], $langs->trans('HolidaysMonthlyUpdate')); + $result = $this->updateSoldeCP($userCounter['rowid'], $newSolde, $userCounter['type']); if ($result < 0) { $error++; @@ -2419,4 +2419,39 @@ class Holiday extends CommonObject return -1; } } + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Label of holiday type (if known) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.$arraydata['user']->getNomUrl(-1).''; + if (property_exists($this, 'fk_type')) { + $return .= '
'.$langs->trans("Type").' : '; + $return .= ''.arraydata['labeltype'].''; + } + if (property_exists($this, 'date_debut') && property_exists($this, 'date_fin')) { + $return .= '
'.dol_print_date($this->date_debut, 'day').''; + $return .= ' '.$langs->trans("To").' '; + $return .= ''.dol_print_date($this->date_fin, 'day').''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 2d47467319d..2eb69145254 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -188,7 +188,7 @@ if (empty($reshook)) { $db->commit(); if ($nbok > 0) { - setEventMessages('UpdateConfCPOK', '', 'mesgs'); + setEventMessages('UpdateConfCPOK', null, 'mesgs'); } } else { $db->rollback(); diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index 564fb8a2a96..42c64613933 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -52,6 +52,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'holidaylist'; // To manage different context of search +$mode = GETPOST('mode', 'alpha'); // for switch mode view result $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -204,17 +205,17 @@ if (empty($reshook)) { } 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')) { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } - // Mass actions - $objectclass = 'Holiday'; - $objectlabel = 'Holiday'; - $permissiontoread = $user->hasRight('holiday', 'read'); - $permissiontodelete = $user->hasRight('holiday', 'delete'); - $permissiontoapprove = $user->hasRight('holiday', 'approve'); - $uploaddir = $conf->holiday->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Mass actions + $objectclass = 'Holiday'; + $objectlabel = 'Holiday'; + $permissiontoread = $user->hasRight('holiday', 'read'); + $permissiontodelete = $user->hasRight('holiday', 'delete'); + $permissiontoapprove = $user->hasRight('holiday', 'approve'); + $uploaddir = $conf->holiday->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -394,6 +395,9 @@ if ($resql) { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; + if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); + } if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -476,6 +480,8 @@ if ($resql) { print ''; print ''; print ''; + print ''; + if ($id > 0) { print ''; } @@ -519,7 +525,11 @@ if ($resql) { } else { $title = $langs->trans("ListeCP"); - $newcardbutton = dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); + + $newcardbutton = ''; + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('MenuAddCP'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/holiday/card.php?action=create', '', $user->rights->holiday->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_hrm', 0, $newcardbutton, '', $limit, 0, 0, 1); } @@ -597,7 +607,7 @@ if ($resql) { } print ''; } @@ -607,12 +617,12 @@ if ($resql) { print ''; } else { print ''; @@ -632,7 +642,7 @@ if ($resql) { //$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':''); $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1); + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); } print ''; } @@ -787,7 +797,8 @@ if ($resql) { $holidaystatic->id = $obj->rowid; $holidaystatic->ref = ($obj->ref ? $obj->ref : $obj->rowid); $holidaystatic->statut = $obj->status; - $holidaystatic->date_debut = $db->jdate($obj->date_debut); + $holidaystatic->date_debut = $obj->date_debut; + $holidaystatic->date_fin = $obj->date_fin; // User $userstatic->id = $obj->fk_user; @@ -815,145 +826,182 @@ if ($resql) { $starthalfday = ($obj->halfday == -1 || $obj->halfday == 2) ? 'afternoon' : 'morning'; $endhalfday = ($obj->halfday == 1 || $obj->halfday == 2) ? 'morning' : 'afternoon'; - print ''; - // Action column - if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_validator']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.fk_type']['checked'])) { - $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); - $labeltypeleavetoshow = empty($typeleaves[$obj->fk_type]['label']) ? $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type) : $labeltypeleavetoshow; - - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['duration']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - // Date validation - if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval - print ''; - if (!$i) $totalarray['nbfield']++; - } - // Date approval - if (!empty($arrayfields['cp.date_approval']['checked'])) { - print ''; - 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); - $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - // Date creation - if (!empty($arrayfields['cp.date_create']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.tms']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - if (!empty($arrayfields['cp.statut']['checked'])) { - print ''; - if (!$i) { - $totalarray['nbfield']++; - } - } - - // Action column - if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { - print ''; - } - if (!$i) { - $totalarray['nbfield']++; - } + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; + } + } else { + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!empty($arrayfields['cp.ref']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_validator']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.fk_type']['checked'])) { + if (empty($typeleaves[$obj->fk_type])) { + $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); + } else { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); + } - print ''."\n"; + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['duration']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_debut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.date_fin']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + // Date validation + if (!empty($arrayfields['cp.date_valid']['checked'])) { // date_valid is both date_valid but also date_approval + print ''; + if (!$i) $totalarray['nbfield']++; + } + // Date approval + if (!empty($arrayfields['cp.date_approval']['checked'])) { + print ''; + 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, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + + // Date creation + if (!empty($arrayfields['cp.date_create']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.tms']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + if (!empty($arrayfields['cp.statut']['checked'])) { + print ''; + if (!$i) { + $totalarray['nbfield']++; + } + } + + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } + if (!$i) { + $totalarray['nbfield']++; + } + + print ''."\n"; + } $i++; } // Add a line for total if there is a total to show if (!empty($arrayfields['duration']['checked'])) { print ''; + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { if ($key == 'duration') { @@ -964,7 +1012,9 @@ if ($resql) { } } // status - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } print ''; } } diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index a1a23715126..9b611c18852 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -118,16 +118,16 @@ if (empty($reshook)) { } $arrayfields = array( - 'cp.ref'=>array('label' => 'Ref', 'checked'=>1), - 'cp.fk_user'=>array('label' => 'Employee', 'checked'=>1), - 'cp.fk_type'=>array('label' => 'Type', 'checked'=>1), - 'cp.date_debut'=>array('label' => 'DateDebCP', 'checked'=>1), - 'cp.date_fin'=>array('label' => 'DateFinCP', 'checked'=>1), - 'used_days'=>array('label' => 'NbUseDaysCPShort', 'checked'=>1), - 'date_start_month'=>array('label' => 'DateStartInMonth', 'checked'=>1), - 'date_end_month'=>array('label' => 'DateEndInMonth', 'checked'=>1), - 'used_days_month'=>array('label' => 'NbUseDaysCPShortInMonth', 'checked'=>1), - 'cp.description'=>array('label' => 'DescCP', 'checked'=>1), + 'cp.ref'=>array('label' => 'Ref', 'checked'=>1, 'position'=>5), + 'cp.fk_type'=>array('label' => 'Type', 'checked'=>1, 'position'=>10), + 'cp.fk_user'=>array('label' => 'Employee', 'checked'=>1, 'position'=>20), + 'cp.date_debut'=>array('label' => 'DateDebCP', 'checked'=>1, 'position'=>30), + 'cp.date_fin'=>array('label' => 'DateFinCP', 'checked'=>1, 'position'=>32), + 'used_days'=>array('label' => 'NbUseDaysCPShort', 'checked'=>1, 'position'=>34), + 'date_start_month'=>array('label' => 'DateStartInMonth', 'checked'=>1, 'position'=>50), + 'date_end_month'=>array('label' => 'DateEndInMonth', 'checked'=>1, 'position'=>52), + 'used_days_month'=>array('label' => 'NbUseDaysCPShortInMonth', 'checked'=>1, 'position'=>54), + 'cp.description'=>array('label' => 'DescCP', 'checked'=>-1, 'position'=>800), ); @@ -149,7 +149,7 @@ $search_month = GETPOST("remonth", 'int') ?GETPOST("remonth", 'int') : date("m", $search_year = GETPOST("reyear", 'int') ?GETPOST("reyear", 'int') : date("Y", time()); $year_month = sprintf("%04d", $search_year).'-'.sprintf("%02d", $search_month); -$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday"; +$sql = "SELECT cp.rowid, cp.ref, cp.fk_user, cp.date_debut, cp.date_fin, cp.fk_type, cp.description, cp.halfday, cp.statut as status"; $sql .= " FROM ".MAIN_DB_PREFIX."holiday cp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; $sql .= " WHERE cp.rowid > 0"; @@ -227,27 +227,27 @@ print '
'; $moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = ''; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; -print '
'; + print ''; $tmp = $objectstatic->LibStatut(0); // To load $this->statuts_short $liststatus = $objectstatic->statuts_short; if (empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { unset($liststatus[2]); // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 } - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'onrightofpage'); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 1, 0, 0, '', 'search_status width100 onrightofpage'); print '
'; - 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 ''; + //mode kanban + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - print '
"; - print ''; - // Picto + Ref - print ''; - // Warning - $warnornote = ''; - //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); - if (!empty($obj->note_private)) { - $warnornote .= ($warnornote ? ' ' : ''); - $warnornote .= ''; - $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; - $warnornote .= ''; + // Output Kanban + $objectstatic->duration = $obj->duree; + $objectstatic->socid = $companystatic->getNomUrl(1, '', 44); + + + print $objectstatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print ''; + print ''; } - if ($warnornote) { - print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } + if (!empty($arrayfields['f.ref']['checked'])) { + print "
'; - print $objectstatic->getNomUrl(1); - print '
'; - print $warnornote; + } else { + print '
'; + 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 ''; + } print '"; - // Other picto tool - print ''; - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref); - $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - print '
'; + print ''; + // Picto + Ref + print ''; + // Warning + $warnornote = ''; + //if ($obj->fk_statut == 1 && $db->jdate($obj->dfv) < ($now - $conf->fichinter->warning_delay)) $warnornote.=img_warning($langs->trans("Late")); + if (!empty($obj->note_private)) { + $warnornote .= ($warnornote ? ' ' : ''); + $warnornote .= ''; + $warnornote .= ''.img_picto($langs->trans("ViewPrivateNote"), 'object_generic').''; + $warnornote .= ''; + } + if ($warnornote) { + print ''; + } - print "\n"; - if (!$i) { - $totalarray['nbfield']++; + // Other picto tool + print '
'; + print $objectstatic->getNomUrl(1); + print ''; + print $warnornote; + print ''; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($obj->ref); + $urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid; + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + print '
'; + + print "
'; - print dol_escape_htmltag($obj->ref_client); - print ''; + print dol_escape_htmltag($obj->ref_client); + print ''; - print $companystatic->getNomUrl(1, '', 44); - print ''; + print $companystatic->getNomUrl(1, '', 44); + print ''; - $projetstatic->id = $obj->projet_id; - $projetstatic->ref = $obj->projet_ref; - $projetstatic->title = $obj->projet_title; - if ($projetstatic->id > 0) { - print $projetstatic->getNomUrl(1, ''); + if (!empty($arrayfields['pr.ref']['checked'])) { + print ''; + $projetstatic->id = $obj->projet_id; + $projetstatic->ref = $obj->projet_ref; + $projetstatic->title = $obj->projet_title; + if ($projetstatic->id > 0) { + print $projetstatic->getNomUrl(1, ''); + } + print ''; + $contratstatic->id = $obj->contrat_id; + $contratstatic->ref = $obj->contrat_ref; + $contratstatic->ref_customer = $obj->contrat_ref_customer; + $contratstatic->ref_supplier = $obj->contrat_ref_supplier; + if ($contratstatic->id > 0) { + print $contratstatic->getNomUrl(1, ''); + print ''; - $contratstatic->id = $obj->contrat_id; - $contratstatic->ref = $obj->contrat_ref; - $contratstatic->ref_customer = $obj->contrat_ref_customer; - $contratstatic->ref_supplier = $obj->contrat_ref_supplier; - if ($contratstatic->id > 0) { - print $contratstatic->getNomUrl(1, ''); + if (!empty($arrayfields['f.description']['checked'])) { + print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''.$objectstatic->getLibStatut(5).''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).''.dol_print_date($db->jdate($obj->dp), 'dayhour')."'.convertSecondToTime($obj->duree, 'allhourmin').''; + 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 ''; + } print ''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)), 48).''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''.$objectstatic->getLibStatut(5).''.dol_trunc(dolGetFirstLineOfText(dol_string_nohtmltag($obj->descriptiondetail, 1)), 48).''.dol_print_date($db->jdate($obj->dp), 'dayhour')."'.convertSecondToTime($obj->duree, 'allhourmin').''; - 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 ''; - } - print '
'.$langs->trans('VATIntra').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)); + print '
'; + //print $langs->trans('VATIntra').''; + $vattoshow = ($object->tva_intra ? showValueWithClipboardCPButton(dol_escape_htmltag($object->tva_intra)) : ''); + print $form->editfieldkey("VATIntra", 'tva_intra', $object->tva_intra, $object, $user->hasRight('societe', 'creer')); + print ''; + print $form->editfieldval("VATIntra", 'tva_intra', $vattoshow, $object, $user->hasRight('societe', 'creer'), 'string', $object->tva_intra, null, null, '', 1, '', 'id', 'auto', array('valuealreadyhtmlescaped'=>1)); print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print ''; print '     '; @@ -2731,7 +2721,7 @@ if ($action == 'create') { print $form->selectarray("type", $liv); print '
'.$langs->trans("Comment").'
'.$langs->trans("Comment").'
'; print ''; print '     '; @@ -2795,13 +2785,12 @@ if ($action == 'create') { print "
".$langs->trans("ErrorOccurredReviseAndRetry")."
"; print ''; } else { - $textinput_size = "50"; // Webservice url print '
'.$langs->trans("WebServiceURL").''.dol_print_url($ws_url).'
'.$langs->trans("User").'
'.$langs->trans("User").'
'.$langs->trans("Password").'
'.$langs->trans("Password").'
'; print ''; diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 3ca1eca77bf..1dfc47e9451 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 9e3a9ba7808..f5a983ac5bb 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -68,7 +68,7 @@ $hookmanager->initHooks(array('ordersupplierdispatch')); // Recuperation de l'id de projet $projectid = 0; -if ($_GET["projectid"]) { +if (GETPOSTISSET("projectid")) { $projectid = GETPOST("projectid", 'int'); } @@ -554,7 +554,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -782,7 +782,8 @@ if ($id > 0 || !empty($ref)) { if (!$objp->fk_product > 0) { $nbfreeproduct++; } else { - $remaintodispatch = price2num($objp->qty - ((float) $products_dispatched[$objp->rowid]), 5); // Calculation of dispatched + $alreadydispatched = isset($products_dispatched[$objp->rowid])?$products_dispatched[$objp->rowid]:0; + $remaintodispatch = price2num($objp->qty - ((float) $alreadydispatched), 5); // Calculation of dispatched if ($remaintodispatch < 0 && empty($conf->global->SUPPLIER_ORDER_ALLOW_NEGATIVE_QTY_FOR_SUPPLIER_ORDER_RETURN)) { $remaintodispatch = 0; } @@ -799,7 +800,7 @@ if ($id > 0 || !empty($ref)) { print ''."\n"; // hidden fields for js function print ''; - print ''; + print ''; print '
'.$objp->qty.''.$products_dispatched[$objp->rowid].''.$alreadydispatched.''; - print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'maxwidth100 onrightofpage'); + print ''; + print $form->selectyesno('search_billed', $search_billed, 1, false, 1, 1, 'search_status width100 onrightofpage'); print '
'; - 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 ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; } - print '
'; - // Picto + Ref - print $objectstatic->getNomUrl(1, '', 0, -1, 1); - // Other picto tool - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); - - print ''.dol_escape_htmltag($obj->ref_supplier).''; - if ($obj->project_id > 0) { - print $projectstatic->getNomUrl(1); - } - print ''; - if ($userstatic->id) { - print $userstatic->getNomUrl(1); - } - print "'; $thirdpartytmp->id = $obj->socid; $thirdpartytmp->name = $obj->name; $thirdpartytmp->email = $obj->email; $thirdpartytmp->name_alias = $obj->alias; $thirdpartytmp->client = $obj->client; $thirdpartytmp->fournisseur = $obj->fournisseur; - print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print '
'; - print $obj->alias; - print '
'; + 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 ''; + } + print ''; - print $obj->town; - print ''; - print $obj->zip; - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - // Order date - if (!empty($arrayfields['cf.date_commande']['checked'])) { - print ''; - print dol_print_date($db->jdate($obj->date_commande), 'day'); - if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + // Picto + Ref + print $objectstatic->getNomUrl(1, '', 0, -1, 1); + // Other picto tool + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); + + print ''; - print dol_print_date($db->jdate($obj->date_livraison), 'day'); - if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { - if ($objectstatic->hasDelay()) { - print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + // Ref Supplier + if (!empty($arrayfields['cf.ref_supplier']['checked'])) { + print ''.dol_escape_htmltag($obj->ref_supplier).''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$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_tva)."'.price($obj->multicurrency_total_ttc)."'; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''.yn($obj->billed).''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_approve), 'day'); - print ''; - print dol_string_nohtmltag($obj->note_public); - print ''; - print dol_string_nohtmltag($obj->note_private); - print ''; - 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; + // Project + if (!empty($arrayfields['cf.fk_projet']['checked'])) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_title; + print ''; + if ($obj->project_id > 0) { + print $projectstatic->getNomUrl(1); + } + print ''; + if ($userstatic->id) { + print $userstatic->getNomUrl(1); + } + print "'; + $thirdpartytmp->id = $obj->socid; + $thirdpartytmp->name = $obj->name; + $thirdpartytmp->email = $obj->email; + $thirdpartytmp->name_alias = $obj->alias; + $thirdpartytmp->client = $obj->client; + $thirdpartytmp->fournisseur = $obj->fournisseur; + print $thirdpartytmp->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + print $obj->alias; + print ''; + print $obj->town; + print ''; + print $obj->zip; + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print '
'; + print dol_print_date($db->jdate($obj->date_commande), 'day'); + if ($objectstatic->statut != $objectstatic::STATUS_ORDERSENT && $objectstatic->statut != $objectstatic::STATUS_RECEIVED_PARTIALLY) { + if ($objectstatic->hasDelay()) { + print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + } + } + print ''; + print dol_print_date($db->jdate($obj->date_livraison), 'day'); + if ($objectstatic->statut == $objectstatic::STATUS_ORDERSENT || $objectstatic->statut == $objectstatic::STATUS_RECEIVED_PARTIALLY) { + if ($objectstatic->hasDelay()) { + print ' '.img_picto($langs->trans("Late").' : '.$objectstatic->showDelay(), "warning"); + } + } + print ''.price($obj->total_ht)."'.price($obj->total_tva)."'.price($obj->total_ttc)."'.$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_tva)."'.price($obj->multicurrency_total_ttc)."'; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''.$objectstatic->LibStatut($obj->fk_statut, 5, $obj->billed).''.yn($obj->billed).''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_approve), 'day'); + print ''; + print dol_string_nohtmltag($obj->note_public); + print ''; + print dol_string_nohtmltag($obj->note_private); + print ''; + 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 ''; + } + print '
trans("SupplierOrder"); ?>trans("ShowOrder"), "order").' '.$objectlink->ref; ?>getNomUrl(1); ?> ref_supplier; ?> date, 'day'); ?> fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $permissionnote = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer;; // Used by the include of actions_dellink.inc.php -$permissiontoedit = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer;; // Used by the include of actions_lineupdonw.inc.php +$permissiondellink = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_dellink.inc.php +$permissiontoedit = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; // Used by the include of actions_lineupdonw.inc.php $usercanread = $user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire; $usercancreate = $user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer; @@ -1151,7 +1151,7 @@ if ($action == 'create') { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6bc9ae679bb..dfb6327bd3f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1172,7 +1172,28 @@ if (empty($reshook)) { if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA) && $diff != 0) { $object->fetch_lines(); $subprice_diff = $object->lines[0]->subprice - $diff / (1 + $object->lines[0]->tva_tx / 100); - $object->updateline($object->lines[0]->id, $object->lines[0]->desc, $subprice_diff, $object->lines[0]->qty, $object->lines[0]->remise_percent, $object->lines[0]->date_start, $object->lines[0]->date_end, $object->lines[0]->tva_tx, 0, 0, 'HT', $object->lines[0]->info_bits, $object->lines[0]->product_type, 0, 0, 0, $object->lines[0]->pa_ht, $object->lines[0]->label, 0, array(), 100); + $object->updateline( + $object->lines[0]->id, + $object->lines[0]->desc, + $subprice_diff, + $object->lines[0]->tva_tx, + $object->lines[0]->localtax1_tx, + $object->lines[0]->localtax2_tx, + $object->lines[0]->qty, + $object->lines[0]->fk_product, + 'HT', + $object->lines[0]->info_bits, + $object->lines[0]->product_type, + $object->lines[0]->remise_percent, + 0, + $object->lines[0]->date_start, + $object->lines[0]->date_end, + 0, + 0, + 0, + '', + 100 + ); } } elseif ($result > 0) { $lines = $srcobject->lines; @@ -1627,7 +1648,7 @@ if (empty($reshook)) { $productsupplier->fk_unit, 0, $pu_devise, - $ref_supplier, + GETPOST('fourn_ref', 'alpha'), '' ); } @@ -1987,15 +2008,93 @@ if ($action == 'create') { $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : ''); //$ref_client = (!empty($objectsrc->ref_client)?$object->ref_client:''); - $soc = $objectsrc->thirdparty; - $cond_reglement_id = (!empty($objectsrc->cond_reglement_id) ? $objectsrc->cond_reglement_id : (!empty($soc->cond_reglement_supplier_id) ? $soc->cond_reglement_supplier_id : 0)); // TODO maybe add default value option - $mode_reglement_id = (!empty($objectsrc->mode_reglement_id) ? $objectsrc->mode_reglement_id : (!empty($soc->mode_reglement_supplier_id) ? $soc->mode_reglement_supplier_id : 0)); - $fk_account = (!empty($objectsrc->fk_account) ? $objectsrc->fk_account : (!empty($soc->fk_account) ? $soc->fk_account : 0)); - $remise_percent = (!empty($objectsrc->remise_percent) ? $objectsrc->remise_percent : (!empty($soc->remise_supplier_percent) ? $soc->remise_supplier_percent : 0)); - $remise_absolue = (!empty($objectsrc->remise_absolue) ? $objectsrc->remise_absolue : (!empty($soc->remise_absolue) ? $soc->remise_absolue : 0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : ''; - $transport_mode_id = (!empty($objectsrc->transport_mode_id) ? $objectsrc->transport_mode_id : (!empty($soc->transport_mode_id) ? $soc->transport_mode_id : 0)); + + $cond_reglement_id = 0; + $mode_reglement_id = 0; + $fk_account = 0; + $remise_percent = 0; + $remise_absolue = 0; + $transport_mode_id = 0; + + // set from object source + if (!empty($objectsrc->cond_reglement_id)) { + $cond_reglement_id = $objectsrc->cond_reglement_id; + } + if (!empty($objectsrc->mode_reglement_id)) { + $mode_reglement_id = $objectsrc->mode_reglement_id; + } + if (!empty($objectsrc->fk_account)) { + $fk_account = $objectsrc->fk_account; + } + if (!empty($objectsrc->remise_percent)) { + $remise_percent = $objectsrc->remise_percent; + } + if (!empty($objectsrc->remise_absolue)) { + $remise_absolue = $objectsrc->remise_absolue; + } + if (!empty($objectsrc->transport_mode_id)) { + $transport_mode_id = $objectsrc->transport_mode_id; + } + + if (empty($cond_reglement_id) + || empty($mode_reglement_id) + || empty($fk_account) + || empty($remise_percent) + || empty($remise_absolue) + || empty($transport_mode_id) + ) { + if ($origin == 'reception') { + // try to get from source of reception (supplier order) + if (!isset($objectsrc->supplier_order)) { + $objectsrc->fetch_origin(); + } + + if (!empty($objectsrc->commandeFournisseur)) { + $supplierOrder = $objectsrc->commandeFournisseur; + if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) { + $cond_reglement_id = $supplierOrder->cond_reglement_id; + } + if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) { + $mode_reglement_id = $supplierOrder->mode_reglement_id; + } + if (empty($fk_account) && !empty($supplierOrder->fk_account)) { + $fk_account = $supplierOrder->fk_account; + } + if (empty($remise_percent) && !empty($supplierOrder->remise_percent)) { + $remise_percent = $supplierOrder->remise_percent; + } + if (empty($remise_absolue) && !empty($supplierOrder->remise_absolue)) { + $remise_absolue = $supplierOrder->remise_absolue; + } + if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) { + $transport_mode_id = $supplierOrder->transport_mode_id; + } + } + } + + // try to get from third-party of source object + if (!empty($soc)) { + if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) { + $cond_reglement_id = $soc->cond_reglement_supplier_id; + } + if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) { + $mode_reglement_id = $soc->mode_reglement_supplier_id; + } + if (empty($fk_account) && !empty($soc->fk_account)) { + $fk_account = $soc->fk_account; + } + if (empty($remise_percent) && !empty($soc->remise_supplier_percent)) { + $remise_percent = $soc->remise_supplier_percent; + } + if (empty($remise_absolue) && !empty($soc->remise_absolue)) { + $remise_absolue = $soc->remise_absolue; + } + if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) { + $transport_mode_id = $soc->transport_mode_id; + } + } + } if (isModEnabled("multicurrency")) { if (!empty($objectsrc->multicurrency_code)) { @@ -2007,7 +2106,7 @@ if ($action == 'create') { } $datetmp = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); - $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datetmp); + $dateinvoice = ($datetmp == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ? -1 : '') : $datetmp); $datetmp = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); $datedue = ($datetmp == '' ?-1 : $datetmp); @@ -2080,14 +2179,15 @@ if ($action == 'create') { // reload page to retrieve supplier informations if (!empty($conf->global->RELOAD_PAGE_ON_SUPPLIER_CHANGE)) { print ''; + '; } if ($fac_recid <= 0) { print ' '; @@ -2212,7 +2312,7 @@ if ($action == 'create') { jQuery(".checkforselect").prop("disabled", false); jQuery(".checkforselect").prop("checked", true); } - }; + } }); '; @@ -2649,6 +2749,7 @@ if ($action == 'create') { $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency + $multicurrency_resteapayer = 0; if (isModEnabled("multicurrency")) { $multicurrency_totalpaid = $object->getSommePaiement(1); $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); @@ -2694,6 +2795,7 @@ if ($action == 'create') { // Confirmation de la conversion de l'avoir en reduc if ($action == 'converttoreduc') { + $type_fac = ''; if ($object->type == FactureFournisseur::TYPE_STANDARD) { $type_fac = 'ExcessPaid'; } elseif ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { @@ -2912,7 +3014,7 @@ if ($action == 'create') { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -2969,7 +3071,8 @@ if ($action == 'create') { } if (isset($objectidnext) && $objectidnext > 0) { $facthatreplace = new FactureFournisseur($db); - $facthatreplace->fetch($facidnext); + + $facthatreplace->fetch($objectidnext); print ' '.str_replace('{s1}', $facthatreplace->getNomUrl(1), $langs->transnoentities("ReplacedByInvoice", '{s1}')).''; } if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_DEPOSIT) { @@ -3628,7 +3731,7 @@ if ($action == 'create') { // Show object lines if (!empty($object->lines)) { - $ret = $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); + $object->printObjectLines($action, $societe, $mysoc, $lineid, 1); } $num = count($object->lines); diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 542b37db092..9cbf579c144 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -149,7 +149,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 03012acbcaf..cff4a30f442 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -125,7 +125,7 @@ if ($object->id > 0) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 9223d47b791..9369a290c9c 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -91,7 +91,7 @@ if (isModEnabled('project')) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index be215e891eb..9b790050571 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -99,14 +99,8 @@ $search_country = GETPOST("search_country", 'int'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); -$search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver -$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); +$search_date_start = GETPOSTDATE('search_date_start', '', 'tzserver'); +$search_date_end = GETPOSTDATE('search_date_end', '23:59:59', 'tzserver'); $search_datelimit_startday = GETPOST('search_datelimit_startday', 'int'); $search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int'); $search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int'); @@ -277,12 +271,6 @@ if (empty($reshook)) { $search_type = ''; $search_country = ''; $search_type_thirdparty = ''; - $search_date_startday = ''; - $search_date_startmonth = ''; - $search_date_startyear = ''; - $search_date_endday = ''; - $search_date_endmonth = ''; - $search_date_endyear = ''; $search_date_start = ''; $search_date_end = ''; $search_datelimit_startday = ''; @@ -766,6 +754,9 @@ if ($socid) { } $param = '&socid='.$socid; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -775,23 +766,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if ($search_all) { $param .= '&search_all='.urlencode($search_all); } -if ($search_date_startday) { - $param .= '&search_date_startday='.urlencode($search_date_startday); +if ($search_date_start) { + $param .= buildParamDate('search_date_start', null, '', 'tzserver'); } -if ($search_date_startmonth) { - $param .= '&search_date_startmonth='.urlencode($search_date_startmonth); -} -if ($search_date_startyear) { - $param .= '&search_date_startyear='.urlencode($search_date_startyear); -} -if ($search_date_endday) { - $param .= '&search_date_endday='.urlencode($search_date_endday); -} -if ($search_date_endmonth) { - $param .= '&search_date_endmonth='.urlencode($search_date_endmonth); -} -if ($search_date_endyear) { - $param .= '&search_date_endyear='.urlencode($search_date_endyear); +if ($search_date_end) { + $param .= buildParamDate('search_date_end', null, '', 'tzserver'); } if ($search_datelimit_startday) { $param .= '&search_datelimit_startday='.urlencode($search_datelimit_startday); @@ -918,7 +897,10 @@ $url = DOL_URL_ROOT.'/fourn/facture/card.php?action=create'; if (!empty($socid)) { $url .= '&socid='.urlencode($socid); } -$newcardbutton = dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)); +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', $url, '', ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)); $i = 0; print '
'."\n"; @@ -1226,9 +1208,9 @@ if (!empty($arrayfields['f.tms']['checked'])) { } // Status if (!empty($arrayfields['f.fk_statut']['checked'])) { - print '
'; + print ''; $liststatus = array('0'=>$langs->trans("Draft"), '1'=>$langs->trans("Unpaid"), '2'=>$langs->trans("Paid")); - print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'onrightofpage', 1); + print $form->selectarray('search_status', $liststatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print '
'; - 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->facid, $arrayofselected)) { - $selected = 1; + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + // Output Kanban + $facturestatic->socid = $thirdparty->getNomUrl(1, 'supplier', 3); + $facturestatic->total_ht = $obj->total_ht; + $facturestatic->date = $obj->datef; + print $facturestatic->getKanbanView(''); + if ($i == (min($num, $limit) - 1)) { + print '
'; + print '
'; + 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->facid, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print ''; + if (!empty($arrayfields['f.ref']['checked'])) { + print ''; - print ''; - // Picto + Ref - print '
'; - print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); + print ''; + // Picto + Ref + print '
'; + print $facturestatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); - $filename = dol_sanitizeFileName($obj->ref); - $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); - $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); - print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); - print '
'; + $filename = dol_sanitizeFileName($obj->ref); + $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + $subdir = get_exdir($obj->facid, 2, 0, 0, $facturestatic, 'invoice_supplier').dol_sanitizeFileName($obj->ref); + print $formfile->getDocumentsLink('facture_fournisseur', $subdir, $filedir); + print '
'; - print "
'; - print $obj->ref_supplier; - print ''; - print $facturestatic->getLibType(); - print "'; - print $obj->label; - print ''; - print dol_print_date($db->jdate($obj->datef), 'day'); - print ''.dol_print_date($datelimit, 'day'); - if ($facturestatic->hasDelay()) { - print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); - } - print ''; - if ($obj->project_id > 0) { - $projectstatic->id = $obj->project_id; - $projectstatic->ref = $obj->project_ref; - $projectstatic->title = $obj->project_label; - print $projectstatic->getNomUrl(1); - } - print ''; - print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); - print ''; - print $thirdparty->name_alias; - print ''; - print $obj->town; - print ''; - print dol_escape_htmltag($obj->zip); - print '".$obj->state_name."'; - $tmparray = getCountry($obj->fk_pays, 'all'); - print $tmparray['label']; - print ''; - if (empty($typenArray)) { - $typenArray = $formcompany->typent_array(1); - } - print $typenArray[$obj->typent_code]; - print ''; - print dol_escape_htmltag($s); - print ''; - print dol_escape_htmltag($s); - print ''.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; - if ($userstatic->id) { - print $userstatic->getLoginUrl(-1); - } else { - print ' '; - } - print "'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''.$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)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; - print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); - print ''; - print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); - print ''; - print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); - print ''; - print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); - print "'; - 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->facid, $arrayofselected)) { - $selected = 1; + print "
'; + print $obj->ref_supplier; + print ''; + print $facturestatic->getLibType(); + print "'; + print $obj->label; + print ''; + print dol_print_date($db->jdate($obj->datef), 'day'); + print ''.dol_print_date($datelimit, 'day'); + if ($facturestatic->hasDelay()) { + print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); + } + print ''; + if ($obj->project_id > 0) { + $projectstatic->id = $obj->project_id; + $projectstatic->ref = $obj->project_ref; + $projectstatic->title = $obj->project_label; + print $projectstatic->getNomUrl(1); + } + print ''; + print $thirdparty->getNomUrl(1, 'supplier', 0, 0, -1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); + print ''; + print $thirdparty->name_alias; + print ''; + print $obj->town; + print ''; + print dol_escape_htmltag($obj->zip); + print '".$obj->state_name."'; + $tmparray = getCountry($obj->fk_pays, 'all'); + print $tmparray['label']; + print ''; + if (empty($typenArray)) { + $typenArray = $formcompany->typent_array(1); + } + print $typenArray[$obj->typent_code]; + print ''; + print dol_escape_htmltag($s); + print ''; + print dol_escape_htmltag($s); + print ''.price($obj->total_ht)."'.price($obj->total_vat)."'.price($obj->total_localtax1)."'.price($obj->total_localtax2)."'.price($obj->total_ttc)."'; + if ($userstatic->id) { + print $userstatic->getLoginUrl(-1); + } else { + print ' '; + } + print "'.(!empty($totalpay) ?price($totalpay, 0, $langs) : '').''.(!empty($remaintopay) ?price($remaintopay, 0, $langs) : ' ').''.$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)."'.(!empty($multicurrency_totalpay) ?price($multicurrency_totalpay, 0, $langs) : '').''; + print (!empty($multicurrency_remaintopay) ? price($multicurrency_remaintopay, 0, $langs) : ''); + print ''; + print dol_print_date($db->jdate($obj->date_creation), 'dayhour', 'tzuser'); + print ''; + print dol_print_date($db->jdate($obj->date_update), 'dayhour', 'tzuser'); + print ''; + print $facturestatic->LibStatut($obj->paye, $obj->fk_statut, 5, $paiement, $obj->type); + print "'; + 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->facid, $arrayofselected)) { + $selected = 1; + } + print ''; + } + print '
'; - print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150'); + print $form->select_dolusers($search_employee, "search_employee", 1, "", $disabled, $include, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); print ''; $validator = new UserGroup($db); $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; - $valideurobjects = $validator->listUsersForGroup($excludefilter); + $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); $valideurarray = array(); foreach ($valideurobjects as $val) { $valideurarray[$val->id] = $val->id; } - print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth150'); + print $form->select_dolusers($search_valideur, "search_valideur", 1, "", 0, $valideurarray, '', 0, 0, 0, $morefilter, 0, '', 'maxwidth125'); print ' 
'; - if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + + if ($mode == 'kanban') { + if ($i == 0) { + print '
'; + print '
'; + } + + $holidaystatic->fk_type = $typeleaves[$obj->fk_type]['rowid']; + + // Output Kanban + if ($massactionbutton || $massaction) { $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) { + if (in_array($object->id, $arrayofselected)) { $selected = 1; } - print ''; - } - print '
'; - print $holidaystatic->getNomUrl(1, 1); - print ''.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).''; - print $labeltypeleavetoshow; - print ''; - $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates - $totalduration += $nbopenedday; - print $nbopenedday; - //print ' '.$langs->trans('DurationDays'); - print ''; - print dol_print_date($db->jdate($obj->date_debut), 'day'); - print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; - print ''; - print dol_print_date($db->jdate($obj->date_fin), 'day'); - print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; - print ''; - print dol_print_date($db->jdate($obj->date_valid), 'day'); - print ''; - print dol_print_date($db->jdate($obj->date_approval), 'day'); - print ''.dol_print_date($date, 'dayhour').''.dol_print_date($date_modif, 'dayhour').''.$holidaystatic->getLibStatut(5).''; - 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; + if (empty($typeleaves[$obj->fk_type])) { + $labeltypeleavetoshow = $langs->trans("TypeWasDisabledOrRemoved", $obj->fk_type); + } else { + $labeltypeleavetoshow = ($langs->trans($typeleaves[$obj->fk_type]['code']) != $typeleaves[$obj->fk_type]['code'] ? $langs->trans($typeleaves[$obj->fk_type]['code']) : $typeleaves[$obj->fk_type]['label']); } - print ''; + + $arraydata = array('user'=>$userstatic, 'labeltype'=>$labeltypeleavetoshow); + print $holidaystatic->getKanbanView('', $arraydata); } - print '
'; + 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 ''; + } + print ''; + print $holidaystatic->getNomUrl(1, 1); + print ''.$userstatic->getNomUrl(-1, 'leave').''.$approbatorstatic->getNomUrl(-1).'
'; + print $labeltypeleavetoshow; + print ''; + $nbopenedday = num_open_day($db->jdate($obj->date_debut, 1), $db->jdate($obj->date_fin, 1), 0, 1, $obj->halfday); // user jdate(..., 1) because num_open_day need UTC dates + $totalduration += $nbopenedday; + print $nbopenedday; + //print ' '.$langs->trans('DurationDays'); + print ''; + print dol_print_date($db->jdate($obj->date_debut), 'day'); + print ' ('.$langs->trans($listhalfday[$starthalfday]).')'; + print ''; + print dol_print_date($db->jdate($obj->date_fin), 'day'); + print ' ('.$langs->trans($listhalfday[$endhalfday]).')'; + print ''; + print dol_print_date($db->jdate($obj->date_valid), 'day'); + print ''; + print dol_print_date($db->jdate($obj->date_approval), 'day'); + print ''.dol_print_date($date, 'dayhour').''.dol_print_date($date_modif, 'dayhour').''.$holidaystatic->getLibStatut(5).''; + 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 ''; + } + print '
'; +print '
'; -print ''; +print ''; + +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} // Filter: Ref if (!empty($arrayfields['cp.ref']['checked'])) { - print ''; + print ''; } // Filter: Type @@ -259,54 +259,66 @@ if (!empty($arrayfields['cp.fk_type']['checked'])) { $arraytypeleaves[$val['rowid']] = $labeltoshow; } - print ''; + print ''; +} + +// Filter: Employee +if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; } if (!empty($arrayfields['cp.date_debut']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['cp.date_fin']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['used_days']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['date_start_month']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['date_end_month']['checked'])) { - print ''; + print ''; } if (!empty($arrayfields['used_days_month']['checked'])) { - print ''; + print ''; } // Filter: Description if (!empty($arrayfields['cp.description']['checked'])) { - print ''; } - // Action column -print ''; +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; +} print ''; print ''; +// Action column +if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} if (!empty($arrayfields['cp.ref']['checked'])) { print_liste_field_titre($arrayfields['cp.ref']['label'], $_SERVER["PHP_SELF"], 'cp.ref', '', '', '', $sortfield, $sortorder); } -if (!empty($arrayfields['cp.fk_user']['checked'])) { - print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); -} if (!empty($arrayfields['cp.fk_type']['checked'])) { print_liste_field_titre($arrayfields['cp.fk_type']['label'], $_SERVER["PHP_SELF"], 'cp.fk_type', '', '', '', $sortfield, $sortorder); } +if (!empty($arrayfields['cp.fk_user']['checked'])) { + print_liste_field_titre($arrayfields['cp.fk_user']['label'], $_SERVER["PHP_SELF"], 'cp.fk_user', '', '', '', $sortfield, $sortorder); +} if (!empty($arrayfields['ct.label']['checked'])) { print_liste_field_titre($arrayfields['ct.label']['label'], $_SERVER["PHP_SELF"], 'ct.label', '', '', '', $sortfield, $sortorder); } @@ -331,11 +343,14 @@ if (!empty($arrayfields['used_days_month']['checked'])) { if (!empty($arrayfields['cp.description']['checked'])) { print_liste_field_titre($arrayfields['cp.description']['label'], $_SERVER["PHP_SELF"], 'cp.description', '', '', '', $sortfield, $sortorder); } -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +// Action column +if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} print ''; if ($num == 0) { - print ''; + print ''; } else { while ($obj = $db->fetch_object($resql)) { $user = new User($db); @@ -383,18 +398,31 @@ if ($num == 0) { // Leave request $holidaystatic->id = $obj->rowid; $holidaystatic->ref = $obj->ref; + $holidaystatic->statut = $obj->status; + $holidaystatic->status = $obj->status; + $holidaystatic->fk_user = $obj->fk_user; + $holidaystatic->fk_type = $obj->fk_type; + $holidaystatic->description = $obj->description; + $holidaystatic->halfday = $obj->halfday; + $holidaystatic->date_debut = $db->jdate($obj->date_debut); + $holidaystatic->date_fin = $db->jdate($obj->date_fin); + print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + } if (!empty($arrayfields['cp.ref']['checked'])) { print ''; } - if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; - } if (!empty($arrayfields['cp.fk_type']['checked'])) { print ''; } + if (!empty($arrayfields['cp.fk_user']['checked'])) { + print ''; + } if (!empty($arrayfields['cp.date_debut']['checked'])) { print ''; } if (!empty($arrayfields['cp.description']['checked'])) { - print ''; + print ''; + } + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; } - - print ''; print ''; } } diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 9bd55252a43..4235b7261eb 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -333,9 +333,8 @@ if (!empty($arrayfields['cpl.date_action']['checked'])) { if (!empty($arrayfields['cpl.fk_user_action']['checked'])) { $validator = new UserGroup($db); $excludefilter = $user->admin ? '' : 'u.rowid <> '.$user->id; - $valideurobjects = $validator->listUsersForGroup($excludefilter); + $valideurobjects = $validator->listUsersForGroup($excludefilter, 1); $valideurarray = array(); - foreach ($valideurobjects as $val) { $valideurarray[$val->id] = $val->id; } diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php index 99212988488..59192bc5ca5 100644 --- a/htdocs/hrm/admin/admin_establishment.php +++ b/htdocs/hrm/admin/admin_establishment.php @@ -145,13 +145,12 @@ if ($result) { $establishmentstatic->label = $obj->label; $establishmentstatic->status = $obj->status; - print ''; print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; print ''; @@ -160,7 +159,7 @@ if ($result) { $i++; } } else { - print ''; + print ''; } print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; + print ''; print ''; - print ''; -} - -// Filter: Employee -if (!empty($arrayfields['cp.fk_user']['checked'])) { - print ''; - print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth100'); - print ''; - print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', '', 1); - print ''; + print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100', 1); + print ''; + print $form->select_dolusers($search_employee, "search_employee", 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth100'); + print ''; + print ''; print ''; - print ''; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$langs->trans('None').'
'.$langs->trans('None').'
'.$holidaystatic->getNomUrl(1, 1).''.$user->getFullName($langs).''.$arraytypeleaves[$obj->fk_type].''.$user->getFullName($langs).''.dol_print_date($db->jdate($obj->date_debut), 'day'); @@ -428,10 +456,16 @@ if ($num == 0) { print ''.num_open_day($date_start_inmonth, $date_end_inmonth, 0, 1, $halfdayinmonth).''.dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)).''; + print '
'; + print dolGetFirstLineOfText(dol_string_nohtmltag($obj->description, 1)); + print '
'; + print '
'.$establishmentstatic->getNomUrl(1).''.$obj->label.''.$obj->address.''.$obj->zip.''.$obj->town.''.dol_escape_htmltag($obj->label).''.dol_escape_htmltag($obj->address).''.dol_escape_htmltag($obj->zip).''.dol_escape_htmltag($obj->town).''; print $establishmentstatic->getLibStatut(5); print '
'.$langs->trans("None").'
'.$langs->trans("None").'
'; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index 6a37ba1e929..05bd8d47cf8 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -285,7 +285,7 @@ class Establishment extends CommonObject * Load an object from database * * @param int $id Id of record to load - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >=0 if OK */ public function fetch($id) { @@ -299,21 +299,24 @@ class Establishment extends CommonObject $result = $this->db->query($sql); if ($result) { $obj = $this->db->fetch_object($result); + if ($obj) { + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->label = $obj->label; + $this->address = $obj->address; + $this->zip = $obj->zip; + $this->town = $obj->town; + $this->status = $obj->status; + $this->entity = $obj->entity; - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->label = $obj->label; - $this->address = $obj->address; - $this->zip = $obj->zip; - $this->town = $obj->town; - $this->status = $obj->status; - $this->entity = $obj->entity; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; - $this->country_id = $obj->country_id; - $this->country_code = $obj->country_code; - $this->country = $obj->country; - - return 1; + return 1; + } else { + return 0; + } } else { $this->error = $this->db->lasterror(); return -1; diff --git a/htdocs/hrm/class/evaluation.class.php b/htdocs/hrm/class/evaluation.class.php index b35a23a6389..48cb8cdd0c3 100644 --- a/htdocs/hrm/class/evaluation.class.php +++ b/htdocs/hrm/class/evaluation.class.php @@ -118,7 +118,7 @@ class Evaluation extends CommonObject 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'default'=>0, 'visible'=>5, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '6' => 'Closed'),), 'date_eval' => array('type'=>'date', 'label'=>'DateEval', 'enabled'=>'1', 'position'=>502, 'notnull'=>1, 'visible'=>1,), - 'fk_user' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'User', 'enabled'=>'1', 'position'=>504, 'notnull'=>1, 'visible'=>1,), + 'fk_user' => array('type'=>'integer:User:user/class/user.class.php:0', 'label'=>'User', 'enabled'=>'1', 'position'=>504, 'notnull'=>1, 'visible'=>1,), 'fk_job' => array('type'=>'integer:Job:/hrm/class/job.class.php', 'label'=>'JobPosition', 'enabled'=>'1', 'position'=>505, 'notnull'=>1, 'visible'=>1,), ); public $rowid; @@ -182,7 +182,7 @@ class Evaluation extends CommonObject */ public function __construct(DoliDB $db) { - global $conf, $langs; + global $conf, $langs, $user; $this->db = $db; @@ -193,6 +193,10 @@ class Evaluation extends CommonObject $this->fields['entity']['enabled'] = 0; } + if (empty($user->rights->hrm->evaluation->readall)) { + $this->fields['fk_user']['type'].= ':rowid IN('.$this->db->sanitize(implode(", ", $user->getAllChildIds(1))).')'; + } + $this->date_eval = dol_now(); // Unset fields that are disabled @@ -400,7 +404,7 @@ class Evaluation extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -849,7 +853,7 @@ class Evaluation extends CommonObject $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatus[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); + $this->labelStatusShort[self::STATUS_CLOSED] = $langs->transnoentitiesnoconv('Closed'); } $statusType = 'status'.$status; @@ -919,8 +923,8 @@ class Evaluation extends CommonObject $result = $objectline->fetchAll('ASC', '', 0, 0, array('customsql'=>'fk_evaluation = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1051,4 +1055,40 @@ class Evaluation extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; + if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { + $return .= '
'.$langs->trans("Employee").' : '; + $return .= ''.$this->fk_user.''; + } + if (property_exists($this, 'fk_job') && !(empty($this->fk_job))) { + $return .= '
'.$langs->trans("Job").' : '; + $return .= ''.$this->fk_job.''; + } + + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= ''; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/class/evaluationdet.class.php b/htdocs/hrm/class/evaluationdet.class.php index f9bbde51912..50d2fac8821 100644 --- a/htdocs/hrm/class/evaluationdet.class.php +++ b/htdocs/hrm/class/evaluationdet.class.php @@ -373,7 +373,7 @@ class Evaluationline extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -561,7 +561,8 @@ class Evaluationline extends CommonObject $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'evaluationline/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; $resql = $this->db->query($sql); if (!$resql) { - $error++; $this->error = $this->db->lasterror(); + $error++; + $this->error = $this->db->lasterror(); } // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments @@ -891,8 +892,8 @@ class Evaluationline extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_evaluationdet = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/class/job.class.php b/htdocs/hrm/class/job.class.php index 117878c10c9..b0a1d263b65 100644 --- a/htdocs/hrm/class/job.class.php +++ b/htdocs/hrm/class/job.class.php @@ -374,7 +374,7 @@ class Job extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -600,30 +600,27 @@ class Job extends CommonObject } /** - * Get last job for user + * Get the last occupied position for a user * - * @param int $fk_user id of user we need to get last job - * @return mixed|string|null + * @param int $fk_user Id of user we need to get last job + * @return Position|string Last occupied position */ public function getLastJobForUser($fk_user) { - global $db; - - $j = new Job($db); - $Tab = $j->getForUser($fk_user); + $Tab = $this->getForUser($fk_user); if (empty($Tab)) return ''; - $job = array_shift($Tab); + $lastpos = array_shift($Tab); - return $job; + return $lastpos; } /** - * Get jobs for user + * Get array of occupied positions for a user * - * @param int $userid id of user we need to get job list - * @return array of jobs + * @param int $userid Id of user we need to get job list + * @return Position[] Array of occupied positions */ public function getForUser($userid) { @@ -925,8 +922,8 @@ class Job extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_job = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1057,6 +1054,39 @@ class Job extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $selected, $langs; + + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(0) : $this->ref).''; + $return .= ''; + /*if (property_exists($this, 'deplacement')) { + $return .= '
'.$langs->trans("Type").''; + $return .= ' : '.$this->fields['deplacement']['arrayofkeyval'][$this->deplacement].''; + }*/ + if (property_exists($this, 'description') && !(empty($this->description))) { + //$return .= '
'.$langs->trans("Description").' : '; + $return .= '
'.(strlen($this->description) > 30 ? dol_substr($this->description, 0, 25).'...' : $this->description).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/class/position.class.php b/htdocs/hrm/class/position.class.php index 5d0c04a4f47..fe394ea5e8a 100644 --- a/htdocs/hrm/class/position.class.php +++ b/htdocs/hrm/class/position.class.php @@ -385,7 +385,7 @@ class Position extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN (' . getEntity($this->table_element) . ')'; + $sql .= ' WHERE t.entity IN (' . getEntity($this->element) . ')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -395,10 +395,10 @@ class Position extends CommonObject foreach ($filter as $key => $value) { if ($key == 't.rowid') { $sqlwhere[] = $key . '=' . $value; - } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { - $sqlwhere[] = $key . ' = \'' . $this->db->idate($value) . '\''; } elseif ($key == 'customsql') { $sqlwhere[] = $value; + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key . ' = \'' . $this->db->idate($value) . '\''; } elseif (strpos($value, '%') === false) { $sqlwhere[] = $key . ' IN (' . $this->db->sanitize($this->db->escape($value)) . ')'; } else { @@ -971,8 +971,8 @@ class Position extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql' => 'fk_position = ' . $this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1036,6 +1036,8 @@ class Position extends CommonObject } /** + * getForUser + * * @param int $userid id of user we need to get position list * @return array|int of positions of user with for each of them the job fetched into that array */ @@ -1049,7 +1051,7 @@ class Position extends CommonObject } /** - * Create a document onto disk according to template module. + * Create a document onto disk according to template module. * * @param string $modele Force template to use ('' to not force) * @param Translate $outputlangs objet lang a utiliser pour traduction @@ -1116,6 +1118,41 @@ class Position extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '') + { + global $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + $return .= ''; + if (property_exists($this, 'fk_user') && !(empty($this->fk_user))) { + $return .= '
'.$langs->trans("Employee").' : '; + $return .= ''.$this->fk_user.''; + } + if (property_exists($this, 'fk_job') && !(empty($this->fk_job))) { + $return .= '
'.$langs->trans("Job").' : '; + $return .= ''.$this->fk_job.''; + } + if (property_exists($this, 'date_start') && property_exists($this, 'date_end')) { + $return .= '
'.dol_print_date($this->db->jdate($this->date_start), 'day').''; + $return .= ' - '.dol_print_date($this->db->jdate($this->date_end), 'day').'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/class/skill.class.php b/htdocs/hrm/class/skill.class.php index 2c86c5dca56..8b7b6910f2b 100644 --- a/htdocs/hrm/class/skill.class.php +++ b/htdocs/hrm/class/skill.class.php @@ -443,7 +443,7 @@ class Skill extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -521,7 +521,7 @@ class Skill extends CommonObject */ public function delete(User $user, $notrigger = false) { - return $this->deleteCommon($user, $notrigger);; + return $this->deleteCommon($user, $notrigger); } /** @@ -965,8 +965,8 @@ class Skill extends CommonObject $result = $objectline->fetchAll('ASC', 'rankorder', 0, 0, array('customsql'=>'fk_skill = '.$this->id)); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1113,4 +1113,36 @@ class Skill extends CommonObject } return $result; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $selected, $langs; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).''; + $return .= ''; + if (property_exists($this, 'skill_type')) { + $return .= '
'.$langs->trans("Type").''; + $return .= ' : '.$this->fields['skill_type']['arrayofkeyval'][$this->skill_type].''; + } + if (property_exists($this, 'description')) { + $return .= '
'.$langs->trans("Description").' : '; + $return .= '
'.(strlen($this->description) > 30 ? dol_substr($this->description, 0, 25).'...' : $this->description).''; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/hrm/class/skilldet.class.php b/htdocs/hrm/class/skilldet.class.php index 4dface42230..3db74d26da1 100644 --- a/htdocs/hrm/class/skilldet.class.php +++ b/htdocs/hrm/class/skilldet.class.php @@ -366,7 +366,7 @@ class Skilldet extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } diff --git a/htdocs/hrm/class/skillrank.class.php b/htdocs/hrm/class/skillrank.class.php index 6db80642bab..a08a647ca03 100644 --- a/htdocs/hrm/class/skillrank.class.php +++ b/htdocs/hrm/class/skillrank.class.php @@ -405,7 +405,7 @@ class SkillRank extends CommonObject $sql .= $this->getFieldList('t'); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -919,8 +919,8 @@ class SkillRank extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_skillrank = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; diff --git a/htdocs/hrm/compare.php b/htdocs/hrm/compare.php index 686d5820695..6365dd51d25 100644 --- a/htdocs/hrm/compare.php +++ b/htdocs/hrm/compare.php @@ -28,9 +28,6 @@ * 2- the central part displays the skills. display of the maximum score for this group and the number of occurrences. * * 3- the right part displays the members of group 2 or the job to be compared - * - * - * */ @@ -48,6 +45,7 @@ require_once DOL_DOCUMENT_ROOT . '/hrm/lib/hrm.lib.php'; // Load translation files required by the page $langs->load('hrm'); +$job = new Job($db); // Permissions $permissiontoread = $user->rights->hrm->evaluation->read || $user->rights->hrm->compare_advance->read; @@ -61,8 +59,8 @@ if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) accessfor * View */ -$css = array(); -$css[] = '/hrm/css/style.css'; +$css = array('/hrm/css/style.css'); + llxHeader('', $langs->trans('SkillComparison'), '', '', 0, 0, '', $css); $head = array(); @@ -74,8 +72,6 @@ $head[$h][2] = 'compare'; print dol_get_fiche_head($head, 'compare', '', 1); -//$PDOdb = new TPDOdb; -$form = new Form($db); ?> '; print '
'; @@ -989,7 +994,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide task fields "+jQuery("#usage_task").prop("checked")); jQuery(".classusetask").hide(); } - }; + } });'; print ''; print '
'; @@ -1015,7 +1020,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide bill time fields "+jQuery("#usage_bill_time").prop("checked")); jQuery(".classusebilltime").hide(); } - }; + } });'; print ''; print '
'; @@ -1041,7 +1046,7 @@ if ($action == 'create' && $user->rights->projet->creer) { console.log("Hide organize event fields "+jQuery("#usage_organize_event").prop("checked")); jQuery(".classuseorganizeevent").hide(); } - }; + } });'; print ''; } @@ -1299,7 +1304,7 @@ if ($action == 'create' && $user->rights->projet->creer) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -1443,9 +1448,11 @@ if ($action == 'create' && $user->rights->projet->creer) { '; } + /* * Actions Buttons */ + print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 6a522346210..fc10f49d38d 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -29,7 +29,6 @@ */ class Projects extends DolibarrApi { - /** * @var array $FIELDS Mandatory fields, checked when create and update object */ @@ -123,6 +122,7 @@ class Projects extends DolibarrApi $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."projet as t"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."projet_extrafields AS ef ON ef.fk_object = t.rowid"; // So we will be able to filter on extrafields if ($category > 0) { $sql .= ", ".MAIN_DB_PREFIX."categorie_project as c"; } @@ -267,10 +267,9 @@ class Projects extends DolibarrApi * * @param int $id Id of project * @param int $userid Id of user (0 = connected user) + * @return array * * @url GET {id}/roles - * - * @return int */ public function getRoles($id, $userid = 0) { @@ -296,11 +295,12 @@ class Projects extends DolibarrApi $userp = new User($this->db); $userp->fetch($userid); } - $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, 0, $id, 0); + $this->project->roles = $taskstatic->getUserRolesForProjectsOrTasks($userp, null, $id, 0); $result = array(); foreach ($this->project->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); } + return $result; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index cd232061bc4..eb7e1579261 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -296,7 +296,7 @@ class Tasks extends DolibarrApi $usert = new User($this->db); $usert->fetch($userid); } - $this->task->roles = $this->task->getUserRolesForProjectsOrTasks(0, $usert, 0, $id); + $this->task->roles = $this->task->getUserRolesForProjectsOrTasks(null, $usert, 0, $id); $result = array(); foreach ($this->task->roles as $line) { array_push($result, $this->_cleanObjectDatas($line)); diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 9213fc1470d..79ea13dcd40 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1480,7 +1480,7 @@ class Project extends CommonObject * @param int $list 0=Return array, 1=Return string list * @param int $socid 0=No filter on third party, id of third party * @param string $filter additionnal filter on project (statut, ref, ...) - * @return array or string Array of projects id, or string with projects id separated with "," if list is 1 + * @return array|string Array of projects id, or string with projects id separated with "," if list is 1 */ public function getProjectsAuthorizedForUser($user, $mode = 0, $list = 0, $socid = 0, $filter = '') { @@ -2167,18 +2167,18 @@ class Project extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id + * @param DoliDB $dbs Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'projet' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } @@ -2265,7 +2265,7 @@ class Project extends CommonObject $this->user_creation = $cuser; } - if ($obj->fk_user_cloture) { + if (!empty($obj->fk_user_cloture)) { $cluser = new User($this->db); $cluser->fetch($obj->fk_user_cloture); $this->user_cloture = $cluser; @@ -2289,8 +2289,8 @@ class Project extends CommonObject * Adds it to non existing supplied categories. * Existing categories are left untouch. * - * @param int[]|int $categories Category or categories IDs - * @return void + * @param int[]|int $categories Category or categories IDs + * @return int <0 if KO, >0 if OK */ public function setCategories($categories) { diff --git a/htdocs/projet/class/projectstats.class.php b/htdocs/projet/class/projectstats.class.php index 322277187f7..e2b6c5129ff 100644 --- a/htdocs/projet/class/projectstats.class.php +++ b/htdocs/projet/class/projectstats.class.php @@ -98,7 +98,7 @@ class ProjectStats extends Stats $result = array(); - dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -298,7 +298,7 @@ class ProjectStats extends Stats * @param int $startyear End year * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @param int $wonlostfilter Add a filter on status won/lost - * @return array Array of values + * @return array|int Array of values or <0 if error */ public function getWeightedAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $wonlostfilter = 1) { @@ -411,10 +411,10 @@ class ProjectStats extends Stats /** * Return amount of elements by month for several years * - * @param int $endyear End year - * @param int $startyear Start year - * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) - * @return array of values + * @param int $endyear End year + * @param int $startyear Start year + * @param int $cachedelay accept for cache file (0=No read, no save of cache, -1=No read but save) + * @return array|int Array of values or <0 if error */ public function getTransformRateByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0) { @@ -549,7 +549,7 @@ class ProjectStats extends Stats /** * Return average of entity by month * @param int $year year number - * @return int value + * @return array */ protected function getAverageByMonth($year) { diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index ff1bdbc07f9..597e680f8f0 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -812,7 +812,7 @@ class Task extends CommonObjectLine * @param array $search_array_options Array of search * @param int $loadextras Fetch all Extrafields on each task * @param int $loadRoleMode 1= will test Roles on task; 0 used in delete project action - * @return array Array of tasks + * @return array|string Array of tasks */ public function getTasksArray($usert = null, $userp = null, $projectid = 0, $socid = 0, $mode = 0, $filteronproj = '', $filteronprojstatus = '-1', $morewherefilter = '', $filteronprojuser = 0, $filterontaskuser = 0, $extrafields = array(), $includebilltime = 0, $search_array_options = array(), $loadextras = 0, $loadRoleMode = 1) { @@ -971,12 +971,12 @@ class Task extends CommonObjectLine if ($loadRoleMode) { if ((!$obj->public) && (is_object($userp))) { // If not public project and we ask a filter on project owned by a user - if (!$this->getUserRolesForProjectsOrTasks($userp, 0, $obj->projectid, 0)) { + if (!$this->getUserRolesForProjectsOrTasks($userp, null, $obj->projectid, 0)) { $error++; } } if (is_object($usert)) { // If we ask a filter on a user affected to a task - if (!$this->getUserRolesForProjectsOrTasks(0, $usert, $obj->projectid, $obj->taskid)) { + if (!$this->getUserRolesForProjectsOrTasks(null, $usert, $obj->projectid, $obj->taskid)) { $error++; } } @@ -1025,7 +1025,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet']['label'])) { foreach ($extrafields->attributes['projet']['label'] as $key => $val) { if ($extrafields->attributes['projet']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1033,7 +1034,8 @@ class Task extends CommonObjectLine if (!empty($extrafields->attributes['projet_task']['label'])) { foreach ($extrafields->attributes['projet_task']['label'] as $key => $val) { if ($extrafields->attributes['projet_task']['type'][$key] != 'separate') { - $tasks[$i]->{'options_'.$key} = $obj->{'options_'.$key}; + $tmpvar = 'options_'.$key; + $tasks[$i]->{'options_'.$key} = $obj->$tmpvar; } } } @@ -1056,12 +1058,12 @@ class Task extends CommonObjectLine /** * Return list of roles for a user for each projects or each tasks (or a particular project or a particular task). * - * @param User $userp Return roles on project for this internal user. If set, usert and taskid must not be defined. - * @param User $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. - * @param int $projectid Project id list separated with , to filter on project - * @param int $taskid Task id to filter on a task - * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. - * @return array Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') + * @param User|null $userp Return roles on project for this internal user. If set, usert and taskid must not be defined. + * @param User|null $usert Return roles on task for this internal user. If set userp must NOT be defined. -1 means no filter. + * @param int $projectid Project id list separated with , to filter on project + * @param int $taskid Task id to filter on a task + * @param integer $filteronprojstatus Filter on project status if userp is set. Not used if userp not defined. + * @return array|int Array (projectid => 'list of roles for project' or taskid => 'list of roles for task') */ public function getUserRolesForProjectsOrTasks($userp, $usert, $projectid = '', $taskid = 0, $filteronprojstatus = -1) { @@ -1396,12 +1398,10 @@ class Task extends CommonObjectLine * * @param User|int $userobj Filter on user. null or 0=No filter * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return array Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') + * @return array|int Array of info for task array('min_date', 'max_date', 'total_duration', 'total_amount', 'nblines', 'nblinesnull') */ public function getSummaryOfTimeSpent($userobj = null, $morewherefilter = '') { - global $langs; - if (is_object($userobj)) { $userid = $userobj->id; } else { @@ -1565,14 +1565,12 @@ class Task extends CommonObjectLine /** * Load all records of time spent * - * @param User $userobj User object - * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') - * @return int <0 if KO, array of time spent if OK + * @param User $userobj User object + * @param string $morewherefilter Add more filter into where SQL request (must start with ' AND ...') + * @return array|int <0 if KO, array of time spent if OK */ public function fetchAllTimeSpent(User $userobj, $morewherefilter = '') { - global $langs; - $arrayres = array(); $sql = "SELECT"; @@ -2327,4 +2325,40 @@ class Task extends CommonObjectLine return ($datetouse > 0 && ($datetouse < ($now - $conf->project->task->warning_delay))); } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs, $conf; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + //$return .= ''; // Can be image + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (property_exists($this, 'fk_project') ) { + $return .= '
'.$this->fk_project.''; + } + if (property_exists($this, 'budget_amount')) { + $return .= '
'.$langs->trans("Budget").' : '.price($this->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; + } + if (property_exists($this, 'fk_statut')) { + $return .= '
'.$this->fk_statut.''; + } + if (property_exists($this, 'duration_effective')) { + $return .= '
'.getTaskProgressView($this, false, false).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/projet/class/taskstats.class.php b/htdocs/projet/class/taskstats.class.php index 5794d585101..6ff56fd8132 100644 --- a/htdocs/projet/class/taskstats.class.php +++ b/htdocs/projet/class/taskstats.class.php @@ -15,6 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -69,7 +70,7 @@ class TaskStats extends Stats $result = array(); $res = array(); - dol_syslog(get_class($this).'::'.__METHOD__."", LOG_DEBUG); + dol_syslog(get_class($this).'::'.__METHOD__, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); @@ -195,7 +196,7 @@ class TaskStats extends Stats } - /** + /** * Return the Task amount by month for a year * * @param int $year Year to scan @@ -208,10 +209,10 @@ class TaskStats extends Stats return array(); } - /** + /** * Return average of entity by month * @param int $year year number - * @return int value + * @return array array of values */ protected function getAverageByMonth($year) { diff --git a/htdocs/projet/comment.php b/htdocs/projet/comment.php index 024dce3abc9..7103916cdb4 100644 --- a/htdocs/projet/comment.php +++ b/htdocs/projet/comment.php @@ -136,7 +136,7 @@ print ''; // Budget print ''.$langs->trans("Budget").''; -if (strcmp($object->budget_amount, '')) { +if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); } print ''; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index f6827fc19b3..2174a02c347 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -387,7 +387,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 0, 0, 0, $conf->currency).''; } print ''; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index f96f5737cf4..8f548685631 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -291,14 +291,14 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Opportunity percent print ''.$langs->trans("OpportunityProbability").''; - if (strcmp($object->opp_percent, '')) { + if (!is_null($object->opp_percent) && strcmp($object->opp_percent, '')) { print price($object->opp_percent, '', $langs, 1, 0).' %'; } print ''; // Opportunity Amount print ''.$langs->trans("OpportunityAmount").''; - if (strcmp($object->opp_amount, '')) { + if (!is_null($object->opp_amount) && strcmp($object->opp_amount, '')) { print ''.price($object->opp_amount, '', $langs, 1, 0, 0, $conf->currency).''; if (strcmp($object->opp_percent, '')) { print '       '.$langs->trans("Weighted").': '.price($object->opp_amount * $object->opp_percent / 100, 0, $langs, 1, 0, -1, $conf->currency).''; @@ -309,7 +309,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { // Budget print ''.$langs->trans("Budget").''; -if (strcmp($object->budget_amount, '')) { +if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -376,8 +376,8 @@ $listofreferent = array( 'lang'=>'entrepot', 'buttonnew'=>'AddWarehouse', 'project_field'=>'fk_project', - 'testnew'=>$user->rights->stock->creer, - 'test'=>$conf->stock->enabled && $user->rights->stock->lire && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)), + 'testnew'=>$user->hasRight('stock', 'creer'), + 'test'=>!empty($conf->stock->enabled) && $user->hasRight('stock', 'lire') && !empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_PROJECT)), 'propal'=>array( 'name'=>"Proposals", 'title'=>"ListProposalsAssociatedProject", @@ -387,8 +387,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/comm/propal/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'propal', 'buttonnew'=>'AddProp', - 'testnew'=>$user->rights->propal->creer, - 'test'=>$conf->propal->enabled && $user->rights->propal->lire), + 'testnew'=>$user->hasRight('propal', 'creer'), + 'test'=>!empty($conf->propal->enabled) && $user->hasRight('propal', 'lire')), 'order'=>array( 'name'=>"CustomersOrders", 'title'=>"ListOrdersAssociatedProject", @@ -398,8 +398,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/commande/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'orders', 'buttonnew'=>'CreateOrder', - 'testnew'=>$user->rights->commande->creer, - 'test'=>$conf->commande->enabled && $user->rights->commande->lire), + 'testnew'=>$user->hasRight('commande', 'creer'), + 'test'=>!empty($conf->commande->enabled) && $user->hasRight('commande', 'lire')), 'invoice'=>array( 'name'=>"CustomersInvoices", 'title'=>"ListInvoicesAssociatedProject", @@ -410,8 +410,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'testnew'=>$user->hasRight('facture', 'creer'), + 'test'=>!empty($conf->facture->enabled) && $user->hasRight('facture', 'lire')), 'invoice_predefined'=>array( 'name'=>"PredefinedInvoices", 'title'=>"ListPredefinedInvoicesAssociatedProject", @@ -421,8 +421,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/facture/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'bills', 'buttonnew'=>'CreateBill', - 'testnew'=>$user->rights->facture->creer, - 'test'=>$conf->facture->enabled && $user->rights->facture->lire), + 'testnew'=>$user->hasRight('facture', 'creer'), + 'test'=>!empty($conf->facture->enabled) && $user->hasRight('facture', 'lire')), 'proposal_supplier'=>array( 'name'=>"SuppliersProposals", 'title'=>"ListSupplierProposalsAssociatedProject", @@ -432,8 +432,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/supplier_proposal/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'supplier_proposal', 'buttonnew'=>'AddSupplierProposal', - 'testnew'=>$user->rights->supplier_proposal->creer, - 'test'=>$conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire), + 'testnew'=>$user->hasRight('supplier_proposal', 'creer'), + 'test'=>!empty($conf->supplier_proposal->enabled) && $user->hasRight('supplier_proposal', 'lire')), 'order_supplier'=>array( 'name'=>"SuppliersOrders", 'title'=>"ListSupplierOrdersAssociatedProject", @@ -443,8 +443,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fourn/commande/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierOrder', - 'testnew'=>($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer), - 'test'=>$conf->supplier_order->enabled && ($user->rights->fournisseur->commande->lire || $user->rights->supplier_order->lire)), + 'testnew'=>$user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer'), + 'test'=>!empty($conf->supplier_order->enabled) && $user->hasRight('fournisseur', 'commande', 'lire') || $user->hasRight('supplier_order', 'lire')), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", 'title'=>"ListSupplierInvoicesAssociatedProject", @@ -455,8 +455,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fourn/facture/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), // No socid parameter here, the socid is often the customer and we create a supplier object 'lang'=>'suppliers', 'buttonnew'=>'AddSupplierInvoice', - 'testnew'=>($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer), - 'test'=>$conf->supplier_invoice->enabled && ($user->rights->fournisseur->facture->lire || $user->rights->supplier_invoice->lire)), + 'testnew'=>$user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight('supplier_invoice', 'creer'), + 'test'=>!empty($conf->supplier_invoice->enabled) && $user->hasRight('fournisseur', 'facture', 'lire') || $user->hasRight('supplier_invoice', 'lire')), 'contract'=>array( 'name'=>"Contracts", 'title'=>"ListContractAssociatedProject", @@ -466,8 +466,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/contrat/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'contracts', 'buttonnew'=>'AddContract', - 'testnew'=>$user->rights->contrat->creer, - 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire), + 'testnew'=>$user->hasRight('contrat', 'creer'), + 'test'=>!empty($conf->contrat->enabled) && $user->hasRight('contrat', 'lire')), 'intervention'=>array( 'name'=>"Interventions", 'title'=>"ListFichinterAssociatedProject", @@ -479,8 +479,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/fichinter/card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'interventions', 'buttonnew'=>'AddIntervention', - 'testnew'=>$user->rights->ficheinter->creer, - 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire), + 'testnew'=>$user->hasRight('ficheinter', 'creer'), + 'test'=>!empty($conf->ficheinter->enabled) && $user->hasRight('ficheinter', 'lire')), 'shipping'=>array( 'name'=>"Shippings", 'title'=>"ListShippingAssociatedProject", @@ -501,9 +501,9 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/mrp/mo_card.php?action=create&origin=project&originid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'mrp', 'buttonnew'=>'CreateMO', - 'testnew'=>'$user->rights->mrp->write', + 'testnew'=>$user->hasRight('mrp', 'write'), 'project_field'=>'fk_project', - 'test'=>$conf->mrp->enabled && $user->rights->mrp->read), + 'test'=>!empty($conf->mrp->enabled) && $user->hasRight('mrp', 'read')), 'trip'=>array( 'name'=>"TripsAndExpenses", 'title'=>"ListExpenseReportsAssociatedProject", @@ -515,8 +515,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->deplacement->creer, - 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire), + 'testnew'=>$user->hasRight('deplacement', 'creer'), + 'test'=>!empty($conf->deplacement->enabled) && $user->hasRight('deplacement', 'lire')), 'expensereport'=>array( 'name'=>"ExpenseReports", 'title'=>"ListExpenseReportsAssociatedProject", @@ -528,8 +528,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/expensereport/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'trips', 'buttonnew'=>'AddTrip', - 'testnew'=>$user->rights->expensereport->creer, - 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire), + 'testnew'=>$user->hasRight('expensereport', 'creer'), + 'test'=>!empty($conf->expensereport->enabled) && $user->hasRight('expensereport', 'lire')), 'donation'=>array( 'name'=>"Donation", 'title'=>"ListDonationsAssociatedProject", @@ -541,8 +541,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/don/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'donations', 'buttonnew'=>'AddDonation', - 'testnew'=>$user->rights->don->creer, - 'test'=>$conf->don->enabled && $user->rights->don->lire), + 'testnew'=>$user->hasRight('don', 'creer'), + 'test'=>!empty($conf->don->enabled) && $user->hasRight('don', 'lire')), 'loan'=>array( 'name'=>"Loan", 'title'=>"ListLoanAssociatedProject", @@ -554,8 +554,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/loan/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'loan', 'buttonnew'=>'AddLoan', - 'testnew'=>$user->rights->loan->write, - 'test'=>$conf->loan->enabled && $user->rights->loan->read), + 'testnew'=>$user->hasRight('loan', 'write'), + 'test'=>!empty($conf->loan->enabled) && $user->hasRight('loan', 'read')), 'chargesociales'=>array( 'name'=>"SocialContribution", 'title'=>"ListSocialContributionAssociatedProject", @@ -567,8 +567,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'compta', 'buttonnew'=>'AddSocialContribution', - 'testnew'=>$user->rights->tax->charges->lire, - 'test'=>$conf->tax->enabled && $user->rights->tax->charges->lire), + 'testnew'=>$user->hasRight('tax', 'charges', 'lire'), + 'test'=>!empty($conf->tax->enabled) && $user->hasRight('tax', 'charges', 'lire')), 'project_task'=>array( 'name'=>"TaskTimeSpent", 'title'=>"ListTaskTimeUserProject", @@ -579,8 +579,8 @@ $listofreferent = array( 'disableamount'=>0, 'urlnew'=>DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&action=createtime&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'buttonnew'=>'AddTimeSpent', - 'testnew'=>$user->rights->projet->creer, - 'test'=>($conf->project->enabled && $user->rights->projet->lire && empty($conf->global->PROJECT_HIDE_TASKS))), + 'testnew'=>$user->hasRight('project', 'creer'), + 'test'=>!empty($conf->project->enabled) && $user->hasRight('projet', 'lire') && !empty($conf->global->PROJECT_HIDE_TASKS)), 'stock_mouvement'=>array( 'name'=>"MouvementStockAssociated", 'title'=>"ListMouvementStockProject", @@ -589,7 +589,7 @@ $listofreferent = array( 'table'=>'stock_mouvement', 'datefieldname'=>'datem', 'disableamount'=>0, - 'test'=>($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))), + 'test'=>!empty($conf->stock->enabled) && $user->hasRight('stock', 'mouvement', 'lire') && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)), 'salaries'=>array( 'name'=>"Salaries", 'title'=>"ListSalariesAssociatedProject", @@ -601,8 +601,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/salaries/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'salaries', 'buttonnew'=>'AddSalary', - 'testnew'=>$user->rights->salaries->write, - 'test'=>$conf->salaries->enabled && $user->rights->salaries->read), + 'testnew'=>$user->hasRight('salaries', 'write'), + 'test'=>!empty($conf->salaries->enabled) && $user->hasRight('salaries', 'read')), 'variouspayment'=>array( 'name'=>"VariousPayments", 'title'=>"ListVariousPaymentsAssociatedProject", @@ -614,8 +614,8 @@ $listofreferent = array( 'urlnew'=>DOL_URL_ROOT.'/compta/bank/various_payment/card.php?action=create&projectid='.$id.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id), 'lang'=>'banks', 'buttonnew'=>'AddVariousPayment', - 'testnew'=>$user->rights->banque->modifier, - 'test'=>$conf->banque->enabled && $user->rights->banque->lire && empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), + 'testnew'=>$user->hasRight('banque', 'modifier'), + 'test'=>!empty($conf->banque->enabled) && $user->hasRight('banque', 'lire') && !empty($conf->global->BANK_USE_OLD_VARIOUS_PAYMENT)), /* No need for this, available on dedicated tab "Agenda/Events" 'agenda'=>array( 'name'=>"Agenda", @@ -657,7 +657,6 @@ if (!empty($conf->global->PROJECT_ELEMENTS_FOR_MINUS_MARGIN)) { } - $parameters = array('listofreferent'=>$listofreferent); $resHook = $hookmanager->executeHooks('completeListOfReferent', $parameters, $object, $action); @@ -693,7 +692,7 @@ if (!$showdatefilter) { print '
'; print ''; print ''; - print ''; + print ''; print ''; print '
'; print $form->selectDate($dates, 'dates', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); @@ -730,7 +729,7 @@ $tooltiponprofitplus = $tooltiponprofitminus = ''; foreach ($listofreferent as $key => $value) { $name = $langs->trans($value['name']); $qualified = $value['test']; - $margin = $value['margin']; + $margin = empty($value['margin']) ? 0 : $value['margin']; if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') if ($margin == 'add') { $tooltiponprofitplus .= ' > '.$name." (+)
\n"; @@ -777,8 +776,8 @@ foreach ($listofreferent as $key => $value) { $tablename = $value['table']; $datefieldname = $value['datefieldname']; $qualified = $value['test']; - $margin = $value['margin']; - $project_field = $value['project_field']; + $margin = empty($value['margin']) ? 0 : $value['margin']; + $project_field = empty($value['project_field']) ? '' : $value['project_field']; if ($qualified && isset($margin)) { // If this element must be included into profit calculation ($margin is 'minus' or 'add') $element = new $classname($db); @@ -990,11 +989,11 @@ foreach ($listofreferent as $key => $value) { $tablename = $value['table']; $datefieldname = $value['datefieldname']; $qualified = $value['test']; - $langtoload = $value['lang']; - $urlnew = $value['urlnew']; - $buttonnew = $value['buttonnew']; - $testnew = $value['testnew']; - $project_field = $value['project_field']; + $langtoload = empty($value['lang']) ? '' : $value['lang']; + $urlnew = empty($value['urlnew']) ? '' : $value['urlnew']; + $buttonnew = empty($value['buttonnew']) ? '' : $value['buttonnew']; + $testnew = empty($value['testnew']) ? '' : $value['testnew']; + $project_field = empty($value['project_field']) ? '' : $value['project_field']; $exclude_select_element = array('payment_various'); if (!empty($value['exclude_select_element'])) { diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index f2889d7c469..47f7cb0a9ef 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -181,7 +181,7 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency); } print ''; @@ -259,7 +259,7 @@ print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'proje // can have a parent that is not affected to him). $tasksarray = $task->getTasksArray(0, 0, ($object->id ? $object->id : $id), $socid, 0); // We load also tasks limited to a particular user -//$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(0,$user,$object->id,0) : ''); +//$tasksrole=($_REQUEST["mode"]=='mine' ? $task->getUserRolesForProjectsOrTasks(null, $user, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 2698a4b1a21..044728227cf 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -310,7 +310,7 @@ if ($resql) { $companystatic = new Societe($db); // We need a clean new object for next loop because current one has some properties set. - +// List of open projects per thirdparty $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; $sql .= ", s.rowid as socid, s.nom as name, s.name_alias"; $sql .= ", s.code_client, s.code_compta, s.client"; diff --git a/htdocs/projet/jsgantt_language.js.php b/htdocs/projet/jsgantt_language.js.php index 35ab1132ae7..93b9ee5505f 100644 --- a/htdocs/projet/jsgantt_language.js.php +++ b/htdocs/projet/jsgantt_language.js.php @@ -67,7 +67,7 @@ var vLangs={'getDefaultLang(1); ?>': 'sunday':'transnoentities('Sunday'); ?>','monday':'transnoentities('Monday'); ?>','tuesday':'transnoentities('Tuesday'); ?>','wednesday':'transnoentities('Wednesday'); ?>','thursday':'transnoentities('Thursday'); ?>','friday':'transnoentities('Friday'); ?>','saturday':'transnoentities('Saturday'); ?>', 'sun':'transnoentities('SundayMin'); ?>','mon':'transnoentities('MondayMin'); ?>','tue':'transnoentities('TuesdayMin'); ?>','wed':'transnoentities('WednesdayMin'); ?>','thu':'transnoentities('ThursdayMin'); ?>','fri':'transnoentities('FridayMin'); ?>','sat':'transnoentities('SaturdayMin'); ?>' } -}; +} var vLang='getDefaultLang(1); ?>'; $langs->trans("ThirdParty"), 'checked'=>1, 'position'=>21, 'enabled'=>(!isModEnabled('societe') ? 0 : 1)); $arrayfields['s.name_alias'] = array('label'=>"AliasNameShort", 'checked'=>0, 'position'=>22); $arrayfields['commercial'] = array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>0, 'position'=>23); -$arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>-1, 'position'=>120); -$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'position'=> 116, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); -$arrayfields['u.login'] = array('label'=>"Author", 'checked'=>1, 'position'=>165); +$arrayfields['c.assigned'] = array('label'=>$langs->trans("AssignedTo"), 'checked'=>1, 'position'=>120); +$arrayfields['opp_weighted_amount'] = array('label'=>$langs->trans('OpportunityWeightedAmountShort'), 'checked'=>0, 'enabled'=>(empty($conf->global->PROJECT_USE_OPPORTUNITIES) ? 0 : 1), 'position'=>106); +$arrayfields['u.login'] = array('label'=>"Author", 'checked'=>-1, 'position'=>165); // Force some fields according to search_usage filter... if (GETPOST('search_usage_opportunity')) { //$arrayfields['p.usage_opportunity']['visible'] = 1; // Not require, filter on search_opp_status is enough @@ -1187,13 +1187,13 @@ if (!empty($arrayfields['p.import_key']['checked'])) { print ''; } if (!empty($arrayfields['p.fk_statut']['checked'])) { - print ''; + print ''; $arrayofstatus = array(); foreach ($object->statuts_short as $key => $val) { $arrayofstatus[$key] = $langs->trans($val); } $arrayofstatus['99'] = $langs->trans("NotClosed").' ('.$langs->trans('Draft').' + '.$langs->trans('Opened').')'; - print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth125 onrightofpage', 1); + print $form->selectarray('search_status', $arrayofstatus, $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage', 1); print ''; } // Action column diff --git a/htdocs/projet/messaging.php b/htdocs/projet/messaging.php index 7fe5b4a0b9d..b266b87700d 100644 --- a/htdocs/projet/messaging.php +++ b/htdocs/projet/messaging.php @@ -59,7 +59,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -196,7 +196,7 @@ if (!empty($object->id)) { // Show link to add event if (isModEnabled('agenda')) { - $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); + $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create'); $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&socid='.$object->socid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index 3322b63b171..ec10af0f884 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -183,6 +183,14 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; * Actions */ +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + $parameters = array('id'=>$id); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { @@ -357,7 +365,7 @@ if ($action == 'createtask' && $user->rights->projet->creer) { } else { if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("projects"); - setEventMessages($langs->trans('NewTaskRefSuggested'), '', 'warnings'); + setEventMessages($langs->trans('NewTaskRefSuggested'), null, 'warnings'); $duplicate_code_error = true; } else { setEventMessages($task->error, $task->errors, 'errors'); @@ -413,6 +421,7 @@ $help_url = "EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("", $title, $help_url); +$arrayofselected = is_array($toselect) ? $toselect : array(); if ($id > 0 || !empty($ref)) { $result = $object->fetch($id, $ref); @@ -544,6 +553,18 @@ if ($id > 0 || !empty($ref)) { // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; + $arrayofmassactions = array(); + if ($user->rights->projet->creer) { + $arrayofmassactions['preclonetasks'] = img_picto('', 'rightarrow', 'class="pictofixedwidth"').$langs->trans("Clone"); + } + if ($permissiontodelete) { + $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); + } + if (in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); + } + $massactionbutton = $form->selectMassAction('', $arrayofmassactions); + // Project card $linkback = ''.$langs->trans("BackToList").''; @@ -616,7 +637,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print ''; @@ -849,7 +870,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $linktotasks .= dolGetButtonTitle($langs->trans('ViewGantt'), '', 'fa fa-stream imgforviewmode', DOL_URL_ROOT.'/projet/ganttview.php?id='.$object->id.'&withproject=1', '', 1, array('morecss'=>'reposition marginleftonly')); //print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $linktotasks, $num, $totalnboflines, 'generic', 0, '', '', 0, 1); - print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask'); + print load_fiche_titre($title, $linktotasks.'   '.$linktocreatetask, 'projecttask', '', '', '', $massactionbutton); + + $objecttmp = new Task($db); + $trackid = 'task'.$taskstatic->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; // Get list of tasks in tasksarray and taskarrayfiltered // We need all tasks (even not limited to a user because a task to user can have a parent that is not affected to him). @@ -862,7 +887,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $tmpuser->fetch($search_user_id); } - $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(0, $tmpuser, $object->id, 0) : ''); + $tasksrole = ($tmpuser->id > 0 ? $taskstatic->getUserRolesForProjectsOrTasks(null, $tmpuser, $object->id, 0) : ''); //var_dump($tasksarray); //var_dump($tasksrole); @@ -884,6 +909,11 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third print '
'; } + // Show the massaction checkboxes only when this page is not opend from the Extended POS + if ($massactionbutton && $contextpage != 'poslist') { + $selectedfields = $form->showCheckAddButtons('checkforselect', 1); + } + print '
'; print ''; @@ -994,6 +1024,8 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; + print ''; + // Action column print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print "\n"; @@ -1069,7 +1102,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (count($tasksarray) > 0) { // Show all lines in taskarray (recursive function to go down on tree) $j = 0; $level = 0; - $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields); + $nboftaskshown = projectLinesa($j, 0, $tasksarray, $level, true, 0, $tasksrole, $object->id, 1, $object->id, $filterprogresscalc, ($object->usage_bill_time ? 1 : 0), $arrayfields, $arrayofselected); } else { $colspan = 10; if ($object->usage_bill_time) { diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index 72c5eb25874..bc4c8770f0f 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -580,6 +580,9 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -697,7 +700,11 @@ if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'pr } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); -$newcardbutton = dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $user->rights->projet->creer); +$newcardbutton = ''; + +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('NewTask'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/tasks.php?action=create', '', $user->rights->projet->creer); print ''."\n"; if ($optioncss != '') { @@ -712,6 +719,8 @@ if (!empty($type)) { print ''; } print ''; +print ''; + // Show description of content $texthelp = ''; @@ -1121,6 +1130,8 @@ while ($i < $imaxinloop) { print '
'; } // Output Kanban + $object->fk_statut = $projectstatic->getLibStatut(1); + $object->fk_project = $projectstatic->getNomUrl(1, 'task'); print $object->getKanbanView(''); if ($i == ($imaxinloop - 1)) { print '
'; diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 8b19c8c0519..dfa26202a2d 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -467,7 +467,7 @@ if ($id > 0 || !empty($ref)) { // Task parent print ''; // Date start @@ -632,7 +632,7 @@ if ($id > 0 || !empty($ref)) { // Budget print ''; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index ceddeedfd33..df2dd77175f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -88,6 +88,10 @@ $search_company = GETPOST('$search_company', 'alpha'); $search_company_alias = GETPOST('$search_company_alias', 'alpha'); $search_project_ref = GETPOST('$search_project_ref', 'alpha'); $search_project_label = GETPOST('$search_project_label', 'alpha'); +$search_timespent_starthour = GETPOSTINT("search_timespent_duration_starthour"); +$search_timespent_startmin = GETPOSTINT("search_timespent_duration_startmin"); +$search_timespent_endhour = GETPOSTINT("search_timespent_duration_endhour"); +$search_timespent_endmin = GETPOSTINT("search_timespent_duration_endmin"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -191,11 +195,15 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_project_ref = ''; $search_project_label = ''; $search_task_label = ''; - $search_user = 0; + $search_user = -1; $search_valuebilled = ''; $search_product_ref = ''; $toselect = array(); $search_array_options = array(); + $search_timespent_starthour = ''; + $search_timespent_startmin = ''; + $search_timespent_endhour = ''; + $search_timespent_endmin = ''; $action = ''; } @@ -1004,7 +1012,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser // Budget print ''; @@ -1337,6 +1345,18 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if ($search_date_endyear) { $param .= '&search_date_endyear='.urlencode($search_date_endyear); } + if ($search_timespent_starthour) { + $param .= '&search_timespent_duration_starthour='.urlencode($search_timespent_starthour); + } + if ($search_timespent_startmin) { + $param .= '&search_timespent_duration_startmin='.urlencode($search_timespent_startmin); + } + if ($search_timespent_endhour) { + $param .= '&search_timespent_duration_endhour='.urlencode($search_timespent_endhour); + } + if ($search_timespent_endmin) { + $param .= '&search_timespent_duration_endmin='.urlencode($search_timespent_endmin); + } /* // Add $param from extra fields @@ -1446,7 +1466,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print $langs->trans('InvoiceToUse'); print ''; print ''; print ''; /*print ''; @@ -1561,7 +1581,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (empty($search_user)) { $search_user = $user->id; } - $sql .= " AND t.fk_user = ".((int) $search_user); + if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user); } if ($search_note) { @@ -1609,6 +1629,20 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser $sql .= " AND t.task_date <= '".$db->idate($search_date_end)."'"; } + if (!empty($arrayfields['t.task_duration']['checked'])) { + if ($search_timespent_starthour || $search_timespent_startmin) { + $timespent_duration_start = $search_timespent_starthour * 60 * 60; // We store duration in seconds + $timespent_duration_start += ($search_timespent_startmin ? $search_timespent_startmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration >= " . $timespent_duration_start; + } + + if ($search_timespent_endhour || $search_timespent_endmin) { + $timespent_duration_end = $search_timespent_endhour * 60 * 60; // We store duration in seconds + $timespent_duration_end += ($search_timespent_endmin ? $search_timespent_endmin : 0) * 60; // We store duration in seconds + $sql .= " AND t.task_duration <= " . $timespent_duration_end; + } + } + $sql .= dolSqlDateFilter('t.task_datehour', $search_day, $search_month, $search_year); // Add where from hooks @@ -1877,7 +1911,26 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser } // Duration if (!empty($arrayfields['t.task_duration']['checked'])) { - print ''; + // Duration - Time spent + print ''; } // Product if (!empty($arrayfields['t.fk_product']['checked'])) { @@ -2616,7 +2669,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser if (!count($tasks)) { $totalnboffields = 1; foreach ($arrayfields as $value) { - if ($value['checked']) { + if (!empty($value['checked'])) { $totalnboffields++; } } diff --git a/htdocs/public/emailing/mailing-read.php b/htdocs/public/emailing/mailing-read.php index 1c2bd6cea98..5829c62dbd7 100644 --- a/htdocs/public/emailing/mailing-read.php +++ b/htdocs/public/emailing/mailing-read.php @@ -46,8 +46,8 @@ if (!defined('NOREQUIREMENU')) { if (!defined('NOIPCHECK')) { define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip } -if (!defined("NOSESSION")) { - define("NOSESSION", '1'); +if (!defined('NOSESSION')) { + define('NOSESSION', '1'); } /** @@ -58,6 +58,8 @@ if (!defined("NOSESSION")) { function llxHeader() { } + + /** * Footer empty * @@ -121,19 +123,19 @@ if (!empty($tag)) { } */ - //Update status of target + // Update status of target $statut = '2'; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".((int) $statut)." WHERE rowid = ".((int) $obj->rowid); $resql = $db->query($sql); if (!$resql) dol_print_error($db); - //Update status communication of thirdparty prospect + // Update status communication of thirdparty prospect if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) { $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid = '.((int) $obj->source_id); $resql = $db->query($sql); } - //Update status communication of contact prospect + // Update status communication of contact prospect if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) { $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.((int) $obj->entity).' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.((int) $obj->source_id).')'; $resql = $db->query($sql); diff --git a/htdocs/public/error-401.php b/htdocs/public/error-401.php index 3d453cd30e5..a160535ff10 100644 --- a/htdocs/public/error-401.php +++ b/htdocs/public/error-401.php @@ -20,6 +20,11 @@
Sorry. You are not allowed to access this resource. +
+
+ + No esta autorizado para acceder a este recurso. +
diff --git a/htdocs/public/error-404.php b/htdocs/public/error-404.php index c964e49cd85..84832100026 100644 --- a/htdocs/public/error-404.php +++ b/htdocs/public/error-404.php @@ -20,6 +20,10 @@
You requested a website or a page that does not exists. +
+
+ la pagina o el recurso solicitado no existe. +
diff --git a/htdocs/public/eventorganization/attendee_new.php b/htdocs/public/eventorganization/attendee_new.php index cb4ba38e628..7e02fda5e13 100644 --- a/htdocs/public/eventorganization/attendee_new.php +++ b/htdocs/public/eventorganization/attendee_new.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 5f5e560c87d..943280d6e2d 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -46,15 +46,10 @@ if (!defined('NOLOGIN')) { if (!defined('NOCSRFCHECK')) { define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -404,7 +399,7 @@ if (empty($reshook) && $action == 'add') { } $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); - $from = $conf->global->ADHERENT_MAIL_FROM; + $from = getDolGlobalString('ADHERENT_MAIL_FROM'); $mailfile = new CMailFile( '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, $to, @@ -563,7 +558,7 @@ if (!empty($conf->global->MEMBER_SKIP_TABLE) || !empty($conf->global->MEMBER_NEW if (jQuery("#morphy").val() == \'mor\') { jQuery("#trcompany").show(); } - }; + } initmorphy(); jQuery("#morphy").change(function() { initmorphy(); diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php index de6b27cba90..cd793a91bfc 100644 --- a/htdocs/public/onlinesign/newonlinesign.php +++ b/htdocs/public/onlinesign/newonlinesign.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2002 Rodolphe Quiedeville * Copyright (C) 2006-2017 Laurent Destailleur * Copyright (C) 2009-2012 Regis Houssin + * Copyright (C) 2023 anthony Berton * * 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 @@ -156,6 +157,8 @@ if ($source == 'proposal') { httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source", 400, 1); } +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('onlinesign')); /* * Actions @@ -346,10 +349,21 @@ if ($source == 'proposal') { print ''."\n"; // Amount - print ''."\n"; + $amount = ''."\n"; + + // Call Hook amountPropalSign + $parameters = array('source' => $source); + $reshook = $hookmanager->executeHooks('amountPropalSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + if (empty($reshook)) { + $amount .= $hookmanager->resPrint; + } elseif ($reshook > 0) { + $amount = $hookmanager->resPrint; + } + + print $amount; // Object $text = ''.$langs->trans("SignatureProposalRef", $object->ref).''; @@ -457,6 +471,7 @@ if ($source == 'proposal') { $langs->load("fichinter"); $result = $object->fetch_thirdparty($object->socid); + // Proposer print ''."\n"; } +// Call Hook addFormSign +$parameters = array('source' => $source); +$reshook = $hookmanager->executeHooks('addFormSign', $parameters, $object, $action); // Note that $action and $object may have been modified by hook if (!$found && !$mesg) { $mesg = $langs->transnoentitiesnoconv("ErrorBadParameters"); @@ -549,6 +565,8 @@ if ($action == "dosign" && empty($cancel)) { $("#signbutton").attr("disabled",false); if(!$._data($("#signbutton")[0], "events")){ $("#signbutton").on("click",function(){ + console.log("We click on button sign"); + $("#signbutton").val(\''.dol_escape_js($langs->transnoentities('PleaseBePatient')).'\'); var signature = $("#signature").jSignature("getData", "image"); $.ajax({ type: "POST", diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index b6444753eb7..af2583abece 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -40,9 +40,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 79104817e77..7b2251138d3 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -281,15 +281,9 @@ if ((empty($paymentmethod) || $paymentmethod == 'stripe') && isModEnabled('strip } // Initialize $validpaymentmethod +// The list can be complete by the hook 'doValidatePayment' executed inside getValidOnlinePaymentMethods() $validpaymentmethod = getValidOnlinePaymentMethods($paymentmethod); -// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...) -$parameters = [ - 'paymentmethod' => $paymentmethod, - 'validpaymentmethod' => &$validpaymentmethod -]; -$reshook = $hookmanager->executeHooks('doValidatePayment', $parameters, $object, $action); - // Check security token $tmpsource = $source; if ($tmpsource == 'membersubscription') { @@ -818,6 +812,19 @@ if ($action == 'charge' && isModEnabled('stripe')) { } } +// This hook is used to push to $validpaymentmethod by external payment modules (ie Payzen, ...) +$parameters = array( + 'paymentmethod' => $paymentmethod, + 'validpaymentmethod' => &$validpaymentmethod +); +$reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} elseif ($reshook > 0) { + print $hookmanager->resPrint; +} + + /* * View @@ -1039,6 +1046,7 @@ if ($source == 'order') { $amount = price2num($amount); } + $tag = ''; if (GETPOST('fulltag', 'alpha')) { $fulltag = GETPOST('fulltag', 'alpha'); } else { @@ -2027,6 +2035,12 @@ if ($action != 'dopayment') { 'object' => $object ]; $reshook = $hookmanager->executeHooks('doCheckStatus', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif ($reshook > 0) { + print $hookmanager->resPrint; + } + if ($source == 'order' && $object->billed) { print '

'.$langs->trans("OrderBilled").''; } elseif ($source == 'invoice' && $object->paye) { @@ -2048,6 +2062,12 @@ if ($action != 'dopayment') { 'paymentmethod' => $paymentmethod ]; $reshook = $hookmanager->executeHooks('doAddButton', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif ($reshook > 0) { + print $hookmanager->resPrint; + } + if ((empty($paymentmethod) || $paymentmethod == 'paybox') && isModEnabled('paybox')) { print '
'; print '
'; @@ -2395,7 +2415,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } var cardElement = elements.create('card', {style: style}); @@ -2435,7 +2455,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme ?> var cardButton = document.getElementById('buttontopay'); var clientSecret = cardButton.dataset.secret; - var options = { clientSecret: clientSecret,}; + var options = { clientSecret: clientSecret }; // Create an instance of Elements var elements = stripe.elements(options); @@ -2465,7 +2485,7 @@ if (preg_match('/^dopayment/', $action)) { // If we choosed/click on the payme color: '#fa755a', iconColor: '#fa755a' } - }; + } GETPOST('dopayment', 'alpha') ]; $reshook = $hookmanager->executeHooks('doPayment', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } elseif ($reshook > 0) { + print $hookmanager->resPrint; + } } - htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object); llxFooter('', 'public'); diff --git a/htdocs/public/payment/paymentko.php b/htdocs/public/payment/paymentko.php index 2504260cbc5..4174267a769 100644 --- a/htdocs/public/payment/paymentko.php +++ b/htdocs/public/payment/paymentko.php @@ -174,7 +174,7 @@ if (!empty($_SESSION['ipaddress'])) { // To avoid to make action twice $companylangs->setDefaultLang($mysoc->default_lang); $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); $sendto = $sendemail; $urlback = $_SERVER["REQUEST_URI"]; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 6d50d1c8c76..4a13de1ef7f 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -54,13 +54,14 @@ if (is_numeric($entity)) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; -require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; - if (isModEnabled('paypal')) { require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypal.lib.php'; require_once DOL_DOCUMENT_ROOT.'/paypal/lib/paypalfunctions.lib.php'; } +// Hook to be used by external payment modules (ie Payzen, ...) +include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; +$hookmanager = new HookManager($db); +$hookmanager->initHooks(array('newpayment')); $langs->loadLangs(array("main", "other", "dict", "bills", "companies", "paybox", "paypal")); @@ -337,6 +338,16 @@ if (isModEnabled('stripe')) { } } +// Check status of the object to verify if it is paid by external payment modules +$action = ''; +$parameters = [ + 'paymentmethod' => $paymentmethod, +]; +$reshook = $hookmanager->executeHooks('isPaymentOK', $parameters, $object, $action); +if ($reshook >= 0) { + $ispaymentok = $hookmanager->resArray['ispaymentok']; +} + // If data not provided from back url, search them into the session env if (empty($ipaddress)) { @@ -1142,6 +1153,8 @@ if ($ispaymentok) { // (we need first that the donation module is able to generate a pdf document for the cerfa with pre filled content) } elseif (array_key_exists('ATT', $tmptag) && $tmptag['ATT'] > 0) { // Record payment for registration to an event for an attendee + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1314,7 +1327,9 @@ if ($ispaymentok) { if ($attendeetovalidate->email_company && $attendeetovalidate->email_company != $thirdparty->email) { $cc = ($cc ? ', ' : '').$attendeetovalidate->email_company; } - $from = $conf->global->MAILING_EMAIL_FROM; + + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); + $urlback = $_SERVER["REQUEST_URI"]; $ishtml = dol_textishtml($texttosend); // May contain urls @@ -1355,6 +1370,8 @@ if ($ispaymentok) { } } elseif (array_key_exists('BOO', $tmptag) && $tmptag['BOO'] > 0) { // Record payment for booth or conference + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($db); $result = $object->fetch($ref); @@ -1461,6 +1478,8 @@ if ($ispaymentok) { if (!$error) { // Putting the booth to "suggested" state + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorboothattendee.class.php'; + require_once DOL_DOCUMENT_ROOT.'/eventorganization/class/conferenceorbooth.class.php'; $booth = new ConferenceOrBooth($db); $resultbooth = $booth->fetch((int) $tmptag['BOO']); if ($resultbooth < 0) { @@ -1611,7 +1630,7 @@ if ($ispaymentok) { $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); $sendto = $sendemail; - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file @@ -1739,7 +1758,7 @@ if ($ispaymentok) { $companylangs->loadLangs(array('main', 'members', 'bills', 'paypal', 'paybox')); $sendto = $sendemail; - $from = $conf->global->MAILING_EMAIL_FROM; + $from = !empty($conf->global->MAILING_EMAIL_FROM) ? $conf->global->MAILING_EMAIL_FROM : getDolGlobalString("MAIN_MAIL_EMAIL_FROM"); // Define $urlwithroot $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php index 7603c046006..c44002340d6 100644 --- a/htdocs/public/project/new.php +++ b/htdocs/public/project/new.php @@ -39,9 +39,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php @@ -289,7 +287,6 @@ if (empty($reshook) && $action == 'add') { $proj->ref = $defaultref; $proj->statut = $proj::STATUS_DRAFT; $proj->status = $proj::STATUS_DRAFT; - $proj->email = GETPOST("email"); $proj->public = 1; $proj->usage_opportunity = 1; $proj->title = $langs->trans("LeadFromPublicForm"); diff --git a/htdocs/public/project/suggestbooth.php b/htdocs/public/project/suggestbooth.php index 68e469b6a00..7005265053e 100644 --- a/htdocs/public/project/suggestbooth.php +++ b/htdocs/public/project/suggestbooth.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/project/suggestconference.php b/htdocs/public/project/suggestconference.php index 5590b0bf94c..9f0dd6638db 100644 --- a/htdocs/public/project/suggestconference.php +++ b/htdocs/public/project/suggestconference.php @@ -33,9 +33,7 @@ if (!defined('NOIPCHECK')) { if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', '1'); } -if (!defined('NOIPCHECK')) { - define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -} + // For MultiCompany module. // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php diff --git a/htdocs/public/recruitment/index.php b/htdocs/public/recruitment/index.php index 23a180b9a7b..4f82139656c 100644 --- a/htdocs/public/recruitment/index.php +++ b/htdocs/public/recruitment/index.php @@ -252,7 +252,7 @@ if (is_array($results)) { } } print ''; - print $tmpuser->getFullName(-1); + print $tmpuser->getFullName($langs); print '   '.dol_print_email($emailforcontact, 0, 0, 1, 0, 0, 'envelope'); print ''; print '
'; diff --git a/htdocs/public/recruitment/view.php b/htdocs/public/recruitment/view.php index 57cb82d9b08..3626693ce89 100644 --- a/htdocs/public/recruitment/view.php +++ b/htdocs/public/recruitment/view.php @@ -159,6 +159,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; * View */ +$now = dol_now(); + $head = ''; if (!empty($conf->global->MAIN_RECRUITMENT_CSS_URL)) { $head = ''."\n"; @@ -201,7 +203,7 @@ $paramlogo = 'ONLINE_RECRUITMENT_LOGO_'.$suffix; if (!empty($conf->global->$paramlogo)) { $logosmall = $conf->global->$paramlogo; } elseif (!empty($conf->global->ONLINE_RECRUITMENT_LOGO)) { - $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO_; + $logosmall = $conf->global->ONLINE_RECRUITMENT_LOGO; } //print ''."\n"; // Define urllogo @@ -221,7 +223,7 @@ if ($urllogo) { if (!empty($mysoc->url)) { print ''; } - print ''; + print ''; if (!empty($mysoc->url)) { print ''; } @@ -234,7 +236,7 @@ if ($urllogo) { if (!empty($conf->global->RECRUITMENT_IMAGE_PUBLIC_INTERFACE)) { print '
'; - print ''; + print ''; print '
'; } diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index c929c2486bd..aafea0365e0 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -229,9 +229,10 @@ if ($action == "view_ticketlist") { $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $filter = array(); + $param = '&action=view_ticketlist'; if (!empty($entity) && isModEnabled('multicompany')) { - $param .= '&entity='.$entity; + $param .= '&entity='.((int) $entity); } // Definition of fields for list @@ -407,7 +408,8 @@ if ($action == "view_ticketlist") { $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); - print_barre_liste($langs->trans('TicketList'), $page, '/public/ticket/list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); + + print_barre_liste($langs->trans('TicketList'), $page, 'list.php', $param, $sortfield, $sortorder, '', $num, $num_total, 'ticket'); // Search bar print ''."\n"; diff --git a/htdocs/public/users/view.php b/htdocs/public/users/view.php new file mode 100644 index 00000000000..b0b4b3ae32f --- /dev/null +++ b/htdocs/public/users/view.php @@ -0,0 +1,470 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/public/users/view.php + * \ingroup user + * \brief Public file to user profile + */ + +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); // This means this output page does not require to be logged. +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +// Load Dolibarr environment +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/vcard.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array("companies", "other", "recruitment")); + +// Get parameters +$action = GETPOST('action', 'aZ09'); +$mode = GETPOST('mode', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$backtopage = ''; + +$id = GETPOST('id', 'int'); +$securekey = GETPOST('securekey', 'alpha'); +$suffix = GETPOST('suffix'); + +$object = new User($db); +$object->fetch($id, '', '', 1); + +// Define $urlwithroot +//$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root)); +//$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file +$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current. For Paypal payment, we can use internal URL like localhost. + +// Security check +global $dolibarr_main_instance_unique_id; +$encodedsecurekey = dol_hash($dolibarr_main_instance_unique_id.'uservirtualcard'.$object->id.'-'.$object->login, 'md5'); +if ($encodedsecurekey != $securekey) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + httponly_accessforbidden('Bad value for securitykey or public profile not enabled'); +} + + +/* + * Actions + */ + +if ($cancel) { + if (!empty($backtopage)) { + header("Location: ".$backtopage); + exit; + } + $action = 'view'; +} + + +/* + * View + */ + +$form = new Form($db); +$v = new vCard(); + +$company = $mysoc; + +$modulepart = 'userphotopublic'; +$dir = $conf->user->dir_output; + +// Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) +// Define logo and logosmall +$logo = ''; +$logosmall = ''; +if (!empty($object->photo)) { + if (dolIsAllowedForPreview($object->photo)) { + $logosmall = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.getImageFileNameForSize($object->photo, '_small'); + $logo = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + //$originalfile = get_exdir(0, 0, 0, 0, $object, 'user').'photos/'.$object->photo; + } +} +//print ''."\n"; +// Define urllogo +$urllogo = ''; +$urllogofull = ''; +if (!empty($logosmall) && is_readable($dir.'/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logosmall); +} elseif (!empty($logo) && is_readable($dir.'/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart='.$modulepart.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&securekey='.urlencode($securekey).'&file='.urlencode($logo); +} + +// Clean data we don't want on public page +if (getDolUserInt('USER_PUBLIC_HIDE_PHOTO', 0, $object)) { + $logo = ''; + $logosmall = ''; + $urllogo = ''; + $urllogofull = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) { + $object->job = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $object->email = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $object->job = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) { + $object->office_phone = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) { + $object->office_fax = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) { + $object->user_mobile = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_BIRTH', 0, $object)) { + $object->birth = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { + $object->socialnetworks = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_ADDRESS', 0, $object)) { + $object->address = ''; + $object->town = ''; + $object->zip = ''; + $object->state = ''; + $object->country = ''; +} +if (getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + $company = null; +} + + +// Output vcard +if ($mode == 'vcard') { + // We create VCard + $output = $v->buildVCardString($object, $company, $langs, $urllogofull); + + $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" + $filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); + //$filename = dol_sanitizeFileName($filename); + + top_httphead('text/vcard; name="'.$filename.'"'); + + header("Content-Disposition: attachment; filename=\"".$filename."\""); + header("Content-Length: ".dol_strlen($output)); + header("Connection: close"); + + print $output; + + $db->close(); + + exit; +} + +$head = ''; +if (!empty($conf->global->MAIN_USER_PROFILE_CSS_URL)) { + $head = ''."\n"; +} + +$conf->dol_hide_topmenu = 1; +$conf->dol_hide_leftmenu = 1; + +if (!getDolUserInt('USER_ENABLE_PUBLIC', 0, $object)) { + $langs->load("errors"); + print '
'.$langs->trans('ErrorPublicInterfaceNotEnabled').'
'; + $db->close(); + exit(); +} + +$arrayofjs = array(); +$arrayofcss = array(); + +$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; +llxHeader($head, $langs->trans("UserProfile").' '.$object->getFullName($langs), '', '', 0, 0, '', '', '', 'onlinepaymentbody', $replacemainarea, 1, 1); + +print ''."\n"; +print '
'."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''; +print "\n"; +print ''."\n"; + +// Output html code for logo +print '
'; +print '
'; + +// Name +print '
'.$object->getFullName($langs).'
'; +// User position +if ($object->job && !getDolUserInt('USER_PUBLIC_HIDE_JOBPOSITION', 0, $object)) { + print '
'; + print dol_escape_htmltag($object->job); + print '
'; +} +if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + print '
'; + print dol_escape_htmltag($mysoc->name); + print '
'; +} + + + +print '
'; +/*if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { + print ''; +}*/ +print '
'; + + +if (!empty($conf->global->USER_IMAGE_PUBLIC_INTERFACE)) { + print '
'; + print ''; + print '
'; +} + +$urlforqrcode = $object->getOnlineVirtualCardUrl('vcard'); + +$socialnetworksdict = getArrayOfSocialNetworks(); + + + +// Show barcode +$showbarcode = GETPOST('nobarcode') ? 0 : 1; +if ($showbarcode) { + $qrcodecontent = $output = $v->buildVCardString($object, $company, $langs); + + print '
'; + print '
'; + print ''; + print '
'; + print '
'; +} + + +// Me +// Show photo +if ($urllogo) { + print ''; +} + + +$usersection = ''; + +// User email +if ($object->email && !getDolUserInt('USER_PUBLIC_HIDE_EMAIL', 0, $object)) { + $usersection .= '
'; + $usersection .= dol_print_email($object->email, 0, 0, 1, 0, 1, 1); + $usersection .= '
'; +} + +// User url +if ($object->url && !getDolUserInt('USER_PUBLIC_HIDE_URL', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $usersection .= dol_print_url($object->url, '_blank', 0, 0, ''); + $usersection .= '
'; +} + +// User phone +if ($object->office_phone && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_PHONE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_phone, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->office_fax && !getDolUserInt('USER_PUBLIC_HIDE_OFFICE_FAX', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->office_fax, $object->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $usersection .= '
'; +} +if ($object->user_mobile && !getDolUserInt('USER_PUBLIC_HIDE_USER_MOBILE', 0, $object)) { + $usersection .= '
'; + $usersection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $usersection .= dol_print_phone($object->user_mobile, $object->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $usersection .= '
'; +} + +// Social networks +if (!empty($object->socialnetworks) && is_array($object->socialnetworks) && count($object->socialnetworks) > 0) { + if (!getDolUserInt('USER_PUBLIC_HIDE_SOCIALNETWORKS', 0, $object)) { + foreach ($object->socialnetworks as $key => $value) { + if ($value) { + $usersection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } +} + +if ($usersection) { + print '
 '; $searchpicto = $form->showFilterButtons(); @@ -1062,6 +1094,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print '
'.$langs->trans("ChildOfProjectTask").''; - print $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); + $formother->selectProjectTasks($object->fk_task_parent, $projectstatic->id, 'task_parent', ($user->admin ? 0 : 1), 0, 0, 0, $object->id); print '
'.$langs->trans("Budget").''; - if (strcmp($object->budget_amount, '')) { + if (!is_null($object->budget_amount) && strcmp($object->budget_amount, '')) { print ''.price($object->budget_amount, 0, $langs, 1, 0, 0, $conf->currency).''; } print '
'.$langs->trans("Budget").''; - if (strcmp($projectstatic->budget_amount, '')) { + if (!is_null($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, '')) { print ''.price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency).''; } print '
'; - $form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); + $form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all'); print '
'; + + $durationtouse_start = 0; + if ($search_timespent_starthour || $search_timespent_startmin) { + $durationtouse_start = ($search_timespent_starthour * 3600 + $search_timespent_startmin * 60); + } + print '
'.$langs->trans('from').' '; + $form->select_duration('search_timespent_duration_start', $durationtouse_start, 0, 'text'); + print '
'; + + $durationtouse_end = 0; + if ($search_timespent_endhour || $search_timespent_endmin) { + $durationtouse_end = ($search_timespent_endhour * 3600 + $search_timespent_endmin * 60); + } + print '
'.$langs->trans('at').' '; + $form->select_duration('search_timespent_duration_end', $durationtouse_end, 0, 'text'); + print '
'; + + print '
'.$langs->trans("Amount"); - print ''; - print ''.price($object->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).''; - print '
'.$langs->trans("Amount"); + $amount .= ''; + $amount .= ''.price($object->total_ttc, 0, $langs, 1, -1, -1, $conf->currency).''; + $amount .= '
'.$langs->trans("Proposer"); print ''; @@ -496,13 +511,14 @@ if ($source == 'proposal') { print $langs->trans("DownloadDocument").''; } } - - print ''; print ''; print '
'."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + print $usersection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +if (!getDolUserInt('USER_PUBLIC_HIDE_COMPANY', 0, $object)) { + $companysection = ''; + + if ($mysoc->email) { + $companysection .= '
'; + $companysection .= img_picto('', 'email', 'class="pictofixedwidth"'); + $companysection .= dol_print_email($mysoc->email, 0, 0, 1); + $companysection .= '
'; + } + + if ($mysoc->url) { + $companysection .= '
'; + $companysection .= img_picto('', 'globe', 'class="pictofixedwidth"'); + $companysection .= dol_print_url($mysoc->url, '_blank', 0, 0, ''); + $companysection .= '
'; + } + + if ($mysoc->phone) { + $companysection .= '
'; + $companysection .= img_picto('', 'phone', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->phone, $mysoc->country_code, 0, $mysoc->id, 'tel', ' ', 0, ''); + $companysection .= '
'; + } + if ($mysoc->fax) { + $companysection .= '
'; + $companysection .= img_picto('', 'phoning_fax', 'class="pictofixedwidth"'); + $companysection .= dol_print_phone($mysoc->fax, $mysoc->country_code, 0, $mysoc->id, 'fax', ' ', 0, ''); + $companysection .= '
'; + } + + // Social networks + if (!empty($mysoc->socialnetworks) && is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) { + foreach ($mysoc->socialnetworks as $key => $value) { + if ($value) { + $companysection .= '
'.dol_print_socialnetworks($value, 0, $mysoc->id, $key, $socialnetworksdict).'
'; + } + } + } + + // Show logo (search order: logo defined by ONLINE_SIGN_LOGO_suffix, then ONLINE_SIGN_LOGO_, then small company logo, large company logo, theme logo, common logo) + // Define logo and logosmall + $logosmall = $mysoc->logo_squarred_small ? $mysoc->logo_squarred_small : $mysoc->logo_small; + $logo = $mysoc->logo_squarred ? $mysoc->logo_squarred : $mysoc->logo; + $paramlogo = 'ONLINE_USER_LOGO_'.$suffix; + if (!empty($conf->global->$paramlogo)) { + $logosmall = $conf->global->$paramlogo; + } elseif (!empty($conf->global->ONLINE_USER_LOGO)) { + $logosmall = $conf->global->ONLINE_USER_LOGO; + } + //print ''."\n"; + // Define urllogo + $urllogo = ''; + $urllogofull = ''; + if (!empty($logosmall) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$logosmall)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/thumbs/'.$logosmall); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/thumbs/'.$logosmall); + } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { + $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/'.$logo); + $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany'.($conf->entity > 1 ? '&entity='.$conf->entity : '').'&file='.urlencode('logos/'.$logo); + } + // Output html code for logo + if ($urllogo) { + print '
'; + if (!empty($mysoc->url)) { + print ''; + } + print ''; + if (!empty($mysoc->url)) { + print ''; + } + print '
'; + } + print ''."\n"; + + // Output payment summary form + print ''."\n"; + + print '
'; + + print '
'; + + // Add company info + if ($mysoc->name) { + print '
'; + print dol_escape_htmltag($mysoc->name); + print '
'; + print '
'; + } + + print $companysection; + + print '
'."\n"; + print "\n"; + + print '
'."\n"; +} + + +// Description +$text = getDolUserString('USER_PUBLIC_MORE', '', $object); +print $text; + + +print ''."\n"; +print '
'."\n"; +print '
'; + + +//htmlPrintOnlinePaymentFooter($mysoc, $langs); + +print ''; + +llxFooter('', 'public'); + +$db->close(); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 3e99bc1194c..4c911d64560 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1394,7 +1394,7 @@ if ($action == 'create') { if ($action != 'classify' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); @@ -1951,23 +1951,27 @@ if ($action == 'create') { if (isModEnabled('productbatch')) { if (isset($lines[$i]->batch)) { print ''; - print ''; - $detail = ''; - if ($lines[$i]->product->status_batch) { - $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + print ''; + $detail = $langs->trans("NA"); + if ($lines[$i]->product->status_batch && $lines[$i]->fk_product > 0) { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; + $productlot = new Productlot($db); + $reslot = $productlot->fetch(0, $lines[$i]->fk_product, $lines[$i]->batch); + if ($reslot > 0) { + $detail = $productlot->getNomUrl(1); + } else { + // lot is not created and info is only in reception lines + $batchinfo = $langs->trans("Batch").': '.$lines[$i]->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $batchinfo .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $batchinfo .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); + } + $detail = $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $batchinfo); } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); - } - $detail .= '
'; - - print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); - } else { - print $langs->trans("NA"); } - print ''; + print $detail . ''; } else { print ''; } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 68da64fcc36..5e4c68fe468 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -59,7 +59,7 @@ class Receptions extends DolibarrApi * Return an array with reception informations * * @param int $id ID of reception - * @return array|mixed data without useless information + * @return Object Object with cleaned properties * * @throws RestException */ @@ -497,8 +497,8 @@ class Receptions extends DolibarrApi * This may record stock movements if module stock is enabled and option to * decrease stock on reception is on. * - * @param int $id Reception ID - * @param int $notrigger 1=Does not execute triggers, 0= execute triggers + * @param int $id Reception ID + * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * * @url POST {id}/validate * @@ -625,8 +625,8 @@ class Receptions extends DolibarrApi /** * Close a reception (Classify it as "Delivered") * - * @param int $id Reception ID - * @param int $notrigger Disabled triggers + * @param int $id Reception ID + * @param int $notrigger Disabled triggers * * @url POST {id}/close * diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 8ae9744a8dd..e9a89691c88 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -140,27 +140,6 @@ class Reception extends CommonObject public function __construct($db) { $this->db = $db; - - // List of long language codes for status - $this->statuts = array(); - $this->statuts[-1] = 'StatusReceptionCanceled'; - $this->statuts[0] = 'StatusReceptionDraft'; - // product to receive if stock increase is on close or already received if stock increase is on validation - $this->statuts[1] = 'StatusReceptionValidated'; - if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) { - $this->statuts[1] = 'StatusReceptionValidatedReceived'; - } - if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) { - $this->statuts[1] = 'StatusReceptionValidatedToReceive'; - } - $this->statuts[2] = 'StatusReceptionProcessed'; - - // List of short language codes for status - $this->statuts_short = array(); - $this->statuts_short[-1] = 'StatusReceptionCanceledShort'; - $this->statuts_short[0] = 'StatusReceptionDraftShort'; - $this->statuts_short[1] = 'StatusReceptionValidatedShort'; - $this->statuts_short[2] = 'StatusReceptionProcessedShort'; } /** @@ -1317,8 +1296,27 @@ class Reception extends CommonObject // phpcs:enable global $langs; - $labelStatus = $langs->transnoentitiesnoconv($this->statuts[$status]); - $labelStatusShort = $langs->transnoentitiesnoconv($this->statuts_short[$status]); + // List of long language codes for status + $this->labelStatus[-1] = 'StatusReceptionCanceled'; + $this->labelStatus[0] = 'StatusReceptionDraft'; + // product to receive if stock increase is on close or already received if stock increase is on validation + $this->labelStatus[1] = 'StatusReceptionValidated'; + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) { + $this->labelStatus[1] = 'StatusReceptionValidatedReceived'; + } + if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) { + $this->labelStatus[1] = 'StatusReceptionValidatedToReceive'; + } + $this->labelStatus[2] = 'StatusReceptionProcessed'; + + // List of short language codes for status + $this->labelStatusShort[-1] = 'StatusReceptionCanceledShort'; + $this->labelStatusShort[0] = 'StatusReceptionDraftShort'; + $this->labelStatusShort[1] = 'StatusReceptionValidatedShort'; + $this->labelStatusShort[2] = 'StatusReceptionProcessedShort'; + + $labelStatus = $langs->transnoentitiesnoconv($this->labelStatus[$status]); + $labelStatusShort = $langs->transnoentitiesnoconv($this->labelStatusShort[$status]); $statusType = 'status'.$status; if ($status == self::STATUS_VALIDATED) { @@ -1348,25 +1346,6 @@ class Reception extends CommonObject dol_syslog(get_class($this)."::initAsSpecimen"); - // Load array of products prodids - $num_prods = 0; - $prodids = array(); - $sql = "SELECT rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."product"; - $sql .= " WHERE entity IN (".getEntity('product').")"; - $sql .= $this->db->plimit(100); - - $resql = $this->db->query($sql); - if ($resql) { - $num_prods = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_prods) { - $i++; - $row = $this->db->fetch_row($resql); - $prodids[$i] = $row[0]; - } - } - $order = new CommandeFournisseur($this->db); $order->initAsSpecimen(); @@ -2006,32 +1985,32 @@ class Reception extends CommonObject /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { $tables = array('reception'); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id - * @return bool + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande_fournisseur_dispatch' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } } diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index a03460b1e49..97d6d19a4f9 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -72,7 +72,7 @@ if ($origin == 'reception') { } else { if ($origin == 'supplierorder' || $origin == 'order_supplier') { $result = restrictedArea($user, 'fournisseur', $origin_id, 'commande_fournisseur', 'commande'); - } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) { + } elseif (!$user->hasRight($origin, "lire") && !$user->hasRight($origin, "read")) { accessforbidden(); } } @@ -172,7 +172,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index 980b5e50a33..dbb435b15dd 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -163,7 +163,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index d6e39e64eeb..8653953371a 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -252,15 +252,98 @@ if (empty($reshook)) { } } } else { + $cond_reglement_id = 0; + $mode_reglement_id = 0; + $fk_account = 0; + $remise_percent = 0; + $remise_absolue = 0; + $transport_mode_id = 0; + if (!empty($rcp->cond_reglement_id)) { + $cond_reglement_id = $rcp->cond_reglement_id; + } + if (!empty($rcp->mode_reglement_id)) { + $mode_reglement_id = $rcp->mode_reglement_id; + } + if (!empty($rcp->fk_account)) { + $fk_account = $rcp->fk_account; + } + if (!empty($rcp->remise_percent)) { + $remise_percent = $rcp->remise_percent; + } + if (!empty($rcp->remise_absolue)) { + $remise_absolue = $rcp->remise_absolue; + } + if (!empty($rcp->transport_mode_id)) { + $transport_mode_id = $rcp->transport_mode_id; + } + + if (empty($cond_reglement_id) + || empty($mode_reglement_id) + || empty($fk_account) + || empty($remise_percent) + || empty($remise_absolue) + || empty($transport_mode_id) + ) { + if (!isset($rcp->supplier_order)) { + $rcp->fetch_origin(); + } + + // try to get from source of reception (supplier order) + if (!empty($rcp->commandeFournisseur)) { + $supplierOrder = $rcp->commandeFournisseur; + if (empty($cond_reglement_id) && !empty($supplierOrder->cond_reglement_id)) { + $cond_reglement_id = $supplierOrder->cond_reglement_id; + } + if (empty($mode_reglement_id) && !empty($supplierOrder->mode_reglement_id)) { + $mode_reglement_id = $supplierOrder->mode_reglement_id; + } + if (empty($fk_account) && !empty($supplierOrder->fk_account)) { + $fk_account = $supplierOrder->fk_account; + } + if (empty($remise_percent) && !empty($supplierOrder->remise_percent)) { + $remise_percent = $supplierOrder->remise_percent; + } + if (empty($remise_absolue) && !empty($supplierOrder->remise_absolue)) { + $remise_absolue = $supplierOrder->remise_absolue; + } + if (empty($transport_mode_id) && !empty($supplierOrder->transport_mode_id)) { + $transport_mode_id = $supplierOrder->transport_mode_id; + } + } + + // try get from third-party of reception + if (!empty($rcp->thirdparty)) { + $soc = $rcp->thirdparty; + if (empty($cond_reglement_id) && !empty($soc->cond_reglement_supplier_id)) { + $cond_reglement_id = $soc->cond_reglement_supplier_id; + } + if (empty($mode_reglement_id) && !empty($soc->mode_reglement_supplier_id)) { + $mode_reglement_id = $soc->mode_reglement_supplier_id; + } + if (empty($fk_account) && !empty($soc->fk_account)) { + $fk_account = $soc->fk_account; + } + if (empty($remise_percent) && !empty($soc->remise_supplier_percent)) { + $remise_percent = $soc->remise_supplier_percent; + } + if (empty($remise_absolue) && !empty($soc->remise_absolue)) { + $remise_absolue = $soc->remise_absolue; + } + if (empty($transport_mode_id) && !empty($soc->transport_mode_id)) { + $transport_mode_id = $soc->transport_mode_id; + } + } + } + // If we want one invoice per reception or if there is no first invoice yet for this thirdparty. $objecttmp->socid = $rcp->socid; $objecttmp->type = $objecttmp::TYPE_STANDARD; - $objecttmp->cond_reglement_id = $rcp->cond_reglement_id || $rcp->thirdparty->cond_reglement_supplier_id; - $objecttmp->mode_reglement_id = $rcp->mode_reglement_id || $rcp->thirdparty->mode_reglement_supplier_id; - - $objecttmp->fk_account = !empty($rcp->thirdparty->fk_account) ? $rcp->thirdparty->fk_account : 0; - $objecttmp->remise_percent = !empty($rcp->thirdparty->remise_percent) ? $rcp->thirdparty->remise_percent : 0; - $objecttmp->remise_absolue = !empty($rcp->thirdparty->remise_absolue) ? $rcp->thirdparty->remise_absolue : 0; + $objecttmp->cond_reglement_id = $cond_reglement_id; + $objecttmp->mode_reglement_id = $mode_reglement_id; + $objecttmp->fk_account = $fk_account; + $objecttmp->remise_percent = $remise_percent; + $objecttmp->remise_absolue = $remise_absolue; + $objecttmp->transport_mode_id = $transport_mode_id; $objecttmp->fk_project = $rcp->fk_project; //$objecttmp->multicurrency_code = $rcp->multicurrency_code; @@ -280,6 +363,11 @@ if (empty($reshook)) { $objecttmp->origin = 'reception'; $objecttmp->origin_id = $id_reception; + // Auto calculation of date due if not filled by user + if (empty($objecttmp->date_echeance)) { + $objecttmp->date_echeance = $objecttmp->calculate_date_lim_reglement(); + } + $objecttmp->array_options = $rcp->array_options; // Copy extrafields // Set $objecttmp->linked_objects with all links order_supplier existing on reception, so same links will be added to the generated supplier invoice @@ -959,8 +1047,8 @@ if (!empty($arrayfields['e.tms']['checked'])) { } // Status if (!empty($arrayfields['e.fk_statut']['checked'])) { - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status onrightofpage'); + print ''; + print $form->selectarray('search_status', array('0'=>$langs->trans('StatusReceptionDraftShort'), '1'=>$langs->trans('StatusReceptionValidatedShort'), '2'=>$langs->trans('StatusReceptionProcessedShort')), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'search_status width100 onrightofpage'); print ''; } // Status billed diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index d916099b872..6546e839d03 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -143,7 +143,7 @@ if ($id > 0 || !empty($ref)) { if ($action != 'classify' && $permissiontoadd) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $object->socid : -1), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($objectsrc) && !empty($objectsrc->fk_project)) { $proj = new Project($db); diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php index 009534b91b5..341e30e3784 100644 --- a/htdocs/reception/tpl/linkedobjectblock.tpl.php +++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php @@ -50,12 +50,12 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } ?> - trans("Reception"); ?> + trans("Reception"); ?> global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { print ' - getNomUrl(1); ?> + getNomUrl(1); ?> ref_supplier); ?> date_delivery, 'day'); ?> - * Copyright (C) 2020 Adminson Alicealalalamdskfldmjgdfgdfhfghgfh +/* Copyright (C) 2004-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 @@ -88,16 +87,14 @@ $setupnotempty = 0; * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstjob = GETPOST('maskconstjob', 'alpha'); - $maskjob = GETPOST('maskjob', 'alpha'); + $maskconst = GETPOST('maskconstjob', 'alpha'); + $maskvalue = GETPOST('maskjob', 'alpha'); - if ($maskconstjob) { - $res = dolibarr_set_const($db, $maskconstjob, $maskjob, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/admin/setup_candidatures.php b/htdocs/recruitment/admin/setup_candidatures.php index adc12a656f4..1da5d698645 100644 --- a/htdocs/recruitment/admin/setup_candidatures.php +++ b/htdocs/recruitment/admin/setup_candidatures.php @@ -1,6 +1,5 @@ - * Copyright (C) 2020 Adminson Alicealalalamdskfldmjgdfgdfhfghgfh +/* Copyright (C) 2004-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 @@ -88,16 +87,14 @@ $setupnotempty = 0; * Actions */ -if ((float) DOL_VERSION >= 6) { - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; if ($action == 'updateMask') { - $maskconstcand = GETPOST('maskconstcand', 'alpha'); - $maskcand = GETPOST('maskcand', 'alpha'); + $maskconst = GETPOST('maskconstcand', 'aZ09'); + $maskvalue = GETPOST('maskcand', 'alpha'); - if ($maskconstcand) { - $res = dolibarr_set_const($db, $maskconstcand, $maskcand, 'chaine', 0, '', $conf->entity); + if ($maskconst && preg_match('/_MASK$/', $maskconst)) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); } if (!($res > 0)) { diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index cf4fa7a143e..9162a6250f3 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -66,8 +66,8 @@ class Recruitment extends DolibarrApi * * Return an array with jobposition informations * - * @param int $id ID of jobposition - * @return array|mixed data without useless information + * @param int $id ID of jobposition + * @return Object Object with cleaned properties * * @url GET jobposition/{id} * @@ -97,8 +97,8 @@ class Recruitment extends DolibarrApi * * Return an array with candidature informations * - * @param int $id ID of candidature - * @return array|mixed data without useless information + * @param int $id ID of candidature + * @return Object Object with cleaned properties * * @url GET candidature/{id} * diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 2ece5dbe217..e3dfd4bd135 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -374,7 +374,7 @@ class RecruitmentCandidature extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -894,8 +894,8 @@ class RecruitmentCandidature extends CommonObject $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_recruitmentcandidature = '.((int) $this->id))); if (is_numeric($result)) { - $this->error = $this->error; - $this->errors = $this->errors; + $this->error = $objectline->error; + $this->errors = $objectline->errors; return $result; } else { $this->lines = $result; @@ -1024,6 +1024,42 @@ class RecruitmentCandidature extends CommonObject return $error; } + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs, $selected,$arrayofselected; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (in_array($this->id, $arrayofselected)) { + $selected = 1; + } + $return .= ''; + if (property_exists($this, 'fk_recruitmentjobposition')) { + $return .= '
'.$langs->trans('Job').' : '.$this->fk_recruitmentjobposition.''; + } + if (property_exists($this, 'phone')) { + $return .= '
'.$langs->trans("phone").' : '.$this->phone.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 7a9d077f910..a63e6b012b2 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -124,7 +124,7 @@ class RecruitmentJobPosition extends CommonObject 'email_recruiter' => array('type'=>'varchar(255)', 'label'=>'EmailRecruiter', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>-1, 'help'=>'ToUseAGenericEmail', 'picto'=>'email'), 'fk_user_supervisor' => array('type'=>'integer:User:user/class/user.class.php:t.statut = 1', 'label'=>'FutureManager', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'user.rowid', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150', 'picto'=>'user'), 'fk_establishment' => array('type'=>'integer:Establishment:hrm/class/establishment.class.php', 'label'=>'Establishment', 'enabled'=>'$conf->hrm->enabled', 'position'=>56, 'notnull'=>0, 'visible'=>-1, 'foreignkey'=>'establishment.rowid',), - 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'WorkPlace', 'enabled'=>'$conf->societe->enabled', 'position'=>57, 'notnull'=>-1, 'visible'=>-1, 'css'=>'maxwidth500', 'index'=>1, 'help'=>"IfJobIsLocatedAtAPartner", 'picto'=>'company'), + 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'WorkPlace', 'enabled'=>'isModEnabled("societe")', 'position'=>57, 'notnull'=>-1, 'visible'=>-1, 'css'=>'maxwidth500', 'index'=>1, 'help'=>"IfJobIsLocatedAtAPartner", 'picto'=>'company'), 'date_planned' => array('type'=>'date', 'label'=>'DateExpected', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>1,), 'remuneration_suggested' => array('type'=>'varchar(255)', 'label'=>'Remuneration', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>1,), 'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>3,), @@ -391,7 +391,7 @@ class RecruitmentJobPosition extends CommonObject $sql .= $this->getFieldList(); $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { - $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')'; + $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')'; } else { $sql .= ' WHERE 1 = 1'; } @@ -1107,4 +1107,44 @@ class RecruitmentJobPosition extends CommonObject return $error; } + + + /** + * Return clicable link of object (with eventually picto) + * + * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) + * @param array $arraydata Array of data + * @return string HTML Code for Kanban thumb. + */ + public function getKanbanView($option = '', $arraydata = null) + { + global $langs, $selected,$arrayofselected,$obj; + $return = '
'; + $return .= '
'; + $return .= ''; + $return .= img_picto('', $this->picto); + $return .= ''; + $return .= '
'; + $return .= ''.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).''; + if (in_array($this->id, $arrayofselected)) { + $selected = 1; + } + $return .= ''; + if (property_exists($this, 'date_planned')) { + $return .= '
'.$langs->trans("Date").' : '.dol_print_date($this->db->jdate($this->date_planned), 'day').''; + } + if (property_exists($this, 'qty')) { + $return .= '
'.$langs->trans("NbOfEmployeesExpected", '', '', '', '', 2).' : '.$this->qty.''; + } + if (property_exists($this, 'remuneration_suggested')) { + $return .= ' | '.$langs->trans("Remuneration").' : '.$this->remuneration_suggested.''; + } + if (method_exists($this, 'getLibStatut')) { + $return .= '
'.$this->getLibStatut(5).' | '.$langs->trans("RecruitmentCandidatures", '', '', '', '', 5).' : '.$obj->nbapplications.'
'; + } + $return .= '
'; + $return .= '
'; + $return .= '
'; + return $return; + } } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index cfbf91463e8..147e8ec3519 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -264,7 +264,7 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi if (file_exists($dir)) { //print "srctemplatepath=".$srctemplatepath; // Src filename $newfile = basename($srctemplatepath); - $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); + $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); $newfiletmp = $objectref.'_'.$newfiletmp; diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 94e93c87baa..61c2eb3ff20 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -798,7 +798,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio /** * Show top header of page. * - * @param Tcpdf $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output @@ -832,13 +832,13 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $pdf->SetXY($this->marge_gauche, $posy); // Logo - if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { + if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) { if ($this->emetteur->logo) { $logodir = $conf->mycompany->dir_output; if (!empty($conf->mycompany->multidir_output[$object->entity])) { $logodir = $conf->mycompany->multidir_output[$object->entity]; } - if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) { + if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; } else { $logo = $logodir.'/logos/'.$this->emetteur->logo; diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php index 9635eba3e58..415ac3357eb 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php @@ -54,7 +54,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -69,7 +69,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= ''; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentCandidature"), $langs->transnoentities("RecruitmentCandidature")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index 4f781a18214..be565486c3a 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -54,7 +54,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi /** * Returns the description of the numbering model * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { @@ -69,7 +69,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= '
'; + $texte .= '
'; $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("RecruitmentJobPosition"), $langs->transnoentities("RecruitmentJobPosition")); $tooltip .= $langs->trans("GenericMaskCodes2"); diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php index 089aa720fa7..362e890c6ef 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php @@ -86,7 +86,7 @@ abstract class ModeleNumRefRecruitmentCandidature /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php index 9efabac2d37..aaf8bed6c53 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentjobposition.php @@ -122,7 +122,7 @@ abstract class ModeleNumRefRecruitmentJobPosition /** * Returns the default description of the numbering template * - * @return string Texte descripif + * @return string Descriptive text */ public function info() { diff --git a/htdocs/recruitment/lib/recruitment.lib.php b/htdocs/recruitment/lib/recruitment.lib.php index 6fa58cc64f5..911c6abdb03 100644 --- a/htdocs/recruitment/lib/recruitment.lib.php +++ b/htdocs/recruitment/lib/recruitment.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2022 Frédéric France +/* Copyright (C) 2019 Laurent Destailleur + * Copyright (C) 2022 Frédéric France * * 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 diff --git a/htdocs/recruitment/recruitmentcandidature_agenda.php b/htdocs/recruitment/recruitmentcandidature_agenda.php index 04118f55572..e5e28f9a662 100644 --- a/htdocs/recruitment/recruitmentcandidature_agenda.php +++ b/htdocs/recruitment/recruitmentcandidature_agenda.php @@ -41,6 +41,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $socid = GETPOST('socid', 'int'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -48,7 +49,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -143,6 +144,7 @@ if ($object->id > 0) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -169,7 +171,7 @@ if ($object->id > 0) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -211,7 +213,7 @@ if ($object->id > 0) { $out .= '&socid='.$objthirdparty->id; } $backtopageurl = urlencode($_SERVER['PHP_SELF'].'?id='.$objthirdparty->id); - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl.'&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$backtopageurl; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -221,7 +223,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; diff --git a/htdocs/recruitment/recruitmentcandidature_card.php b/htdocs/recruitment/recruitmentcandidature_card.php index 2452c9e530b..62f7ed5cc9b 100644 --- a/htdocs/recruitment/recruitmentcandidature_card.php +++ b/htdocs/recruitment/recruitmentcandidature_card.php @@ -426,6 +426,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -442,7 +443,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //if ($action != 'classify') $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' '; $morehtmlref .= ' : '; if ($action == 'classify') { - //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + //$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 0, 1, '', 'maxwidth300'); $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; @@ -450,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentcandidature_document.php b/htdocs/recruitment/recruitmentcandidature_document.php index 3f08c770111..8b4b7fbdcd2 100644 --- a/htdocs/recruitment/recruitmentcandidature_document.php +++ b/htdocs/recruitment/recruitmentcandidature_document.php @@ -121,6 +121,7 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -147,7 +148,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 9b860ac54d5..95b6ac6203d 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -438,7 +438,7 @@ if ($jobposition->id > 0 && (empty($action) || ($action != 'edit' && $action != $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -571,7 +571,7 @@ if ($search_all) { $fieldstosearchall[$key] = $langs->trans($val); $setupstring .= $key."=".$val.";"; } - print ''."\n"; + print ''."\n"; print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } @@ -735,8 +735,18 @@ while ($i < $imaxinloop) { print '
'; diff --git a/htdocs/recruitment/recruitmentcandidature_note.php b/htdocs/recruitment/recruitmentcandidature_note.php index 1649ab5ee5e..b26d4310688 100644 --- a/htdocs/recruitment/recruitmentcandidature_note.php +++ b/htdocs/recruitment/recruitmentcandidature_note.php @@ -96,6 +96,7 @@ if ($id > 0 || !empty($ref)) { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; + $morehtmlref.= $object->getFullName('', 1); /* // Ref customer $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); @@ -122,7 +123,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentjobposition_agenda.php b/htdocs/recruitment/recruitmentjobposition_agenda.php index f2f4d37484b..d935a4a588a 100644 --- a/htdocs/recruitment/recruitmentjobposition_agenda.php +++ b/htdocs/recruitment/recruitmentjobposition_agenda.php @@ -40,6 +40,7 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : str_replace('_', '', basename(dirname(__FILE__)).basename(__FILE__, '.php')); // To manage different context of search if (GETPOST('actioncode', 'array')) { $actioncode = GETPOST('actioncode', 'array', 3); @@ -47,7 +48,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -79,7 +80,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals if ($id > 0 || !empty($ref)) { - $upload_dir = $conf->recruitment->multidir_output[$object->entity]."/".$object->id; + $upload_dir = $conf->recruitment->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } $permissiontoadd = $user->rights->recruitment->recruitmentjobposition->write; // Used by the include of actions_addupdatedelete.inc.php @@ -163,11 +164,11 @@ if ($object->id > 0) { $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); $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -208,7 +209,7 @@ if ($object->id > 0) { if (get_class($objthirdparty) == 'Societe') { $out .= '&socid='.$objthirdparty->id; } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1&percentage=-1'; + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage=1'; //$out.=$langs->trans("AddAnAction").' '; //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); //$out.=""; @@ -218,7 +219,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda')) { - if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { + if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; @@ -228,7 +229,7 @@ if ($object->id > 0) { print '
'; if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } diff --git a/htdocs/recruitment/recruitmentjobposition_applications.php b/htdocs/recruitment/recruitmentjobposition_applications.php index 3cdca44c93e..0447ace7979 100644 --- a/htdocs/recruitment/recruitmentjobposition_applications.php +++ b/htdocs/recruitment/recruitmentjobposition_applications.php @@ -239,7 +239,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentjobposition_card.php b/htdocs/recruitment/recruitmentjobposition_card.php index d1ca4ef2db1..3555a75d030 100644 --- a/htdocs/recruitment/recruitmentjobposition_card.php +++ b/htdocs/recruitment/recruitmentjobposition_card.php @@ -108,7 +108,7 @@ if (empty($reshook)) { if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) { $backtopage = $backurlforlist; } else { - $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); + $backtopage = dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?id='.((!empty($id) && $id > 0) ? $id : '__ID__'); } } } @@ -130,7 +130,7 @@ if (empty($reshook)) { include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'set_thirdparty' && $permissiontoadd) { - $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'RECRUITMENTJOBPOSITION_MODIFY'); + $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, $triggermodname); } if ($action == 'classin' && $permissiontoadd) { $object->setProject(GETPOST('projectid', 'int')); @@ -257,8 +257,6 @@ if (($id || $ref) && $action == 'edit') { // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals(); - $head = recruitmentjobpositionPrepareHead($object); print dol_get_fiche_head($head, 'card', $langs->trans("RecruitmentJobPosition"), -1, $object->picto); @@ -341,7 +339,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { @@ -395,31 +393,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send if (empty($user->socid)) { - print ''.$langs->trans('SendMail').''."\n"; + print dolGetButtonAction('', $langs->trans('SendMail'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init&token='.newToken().'#formmailbeforetitle'); } // Back to draft if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { - print ''.$langs->trans("SetToDraft").''; + print dolGetButtonAction('', $langs->trans('SetToDraft'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes&token='.newToken(), '', $permissiontoadd); } } // Modify - if ($permissiontoadd) { - print ''.$langs->trans("Modify").''."\n"; - } else { - print ''.$langs->trans('Modify').''."\n"; - } + print dolGetButtonAction('', $langs->trans('Modify'), 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit&token='.newToken(), '', $permissiontoadd); // Validate if ($object->status == $object::STATUS_DRAFT) { if ($permissiontoadd) { if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { - print ''.$langs->trans("Validate").''; + print dolGetButtonAction('', $langs->trans('Validate'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_validate&confirm=yes&token='.newToken(), '', $permissiontoadd); } else { $langs->load("errors"); - print ''.$langs->trans("Validate").''; + print dolGetButtonAction($langs->trans("ErrorAddAtLeastOneLineFirst"), $langs->trans("Validate"), 'default', '#', '', 0); } } } @@ -442,9 +436,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea /* if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { - print ''.$langs->trans("Disable").''."\n"; + print dolGetButtonAction('', $langs->trans('Disable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=disable&token='.newToken(), '', $permissiontoadd); } else { - print ''.$langs->trans("Enable").''."\n"; + print dolGetButtonAction('', $langs->trans('Enable'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=enable&token='.newToken(), '', $permissiontoadd); + } } }*/ if ($permissiontoadd) { @@ -454,7 +449,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Delete - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); + $params = array(); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params); } print '
'."\n"; } diff --git a/htdocs/recruitment/recruitmentjobposition_document.php b/htdocs/recruitment/recruitmentjobposition_document.php index a162f4c3af7..55c8785073a 100644 --- a/htdocs/recruitment/recruitmentjobposition_document.php +++ b/htdocs/recruitment/recruitmentjobposition_document.php @@ -148,7 +148,7 @@ if ($object->id) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index e6b538b5167..670eca08040 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -585,14 +585,21 @@ while ($i < $imaxinloop) { // Store properties in $object $object->setVarsFromFetchObj($obj); + $object->date_planned = $obj->date_planned; + if ($mode == 'kanban') { if ($i == 0) { print ''; diff --git a/htdocs/recruitment/recruitmentjobposition_note.php b/htdocs/recruitment/recruitmentjobposition_note.php index 5dc4004a361..d4eb1f05615 100644 --- a/htdocs/recruitment/recruitmentjobposition_note.php +++ b/htdocs/recruitment/recruitmentjobposition_note.php @@ -125,7 +125,7 @@ if ($id > 0 || !empty($ref)) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, !empty($object->socid) ? $object->socid : 0, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { diff --git a/htdocs/resource/agenda.php b/htdocs/resource/agenda.php index 8fddadcce11..b5a0c099cff 100644 --- a/htdocs/resource/agenda.php +++ b/htdocs/resource/agenda.php @@ -51,7 +51,7 @@ if (GETPOST('actioncode', 'array')) { $actioncode = '0'; } } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT')); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -166,7 +166,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); if (isModEnabled('agenda') && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { - $param = '&id='.$object->id.'&socid='.$socid; + $param = '&id='.$object->id; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -174,7 +174,7 @@ if ($object->id > 0) { $param .= '&limit='.urlencode($limit); } - print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlcenter, '', 0, 1, 1); + print_barre_liste($langs->trans("ActionsOnResource"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', '', '', 0, 1, 1); // List of all actions $filters = array(); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 5c588b59c6b..3ee118d06c7 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -225,7 +225,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { // Type print ''; print ''; // Description diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 515a766263b..99cc586cbb9 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -292,7 +292,7 @@ class Dolresource extends CommonObject $sql .= " description=".(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").","; $sql .= " fk_country=".($this->country_id > 0 ? $this->country_id : "null").","; $sql .= " fk_code_type_resource=".(isset($this->fk_code_type_resource) ? "'".$this->db->escape($this->fk_code_type_resource)."'" : "null").","; - $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); $this->db->begin(); @@ -619,7 +619,7 @@ class Dolresource extends CommonObject $sql .= " element_type=".(isset($this->element_type) ? "'".$this->db->escape($this->element_type)."'" : "null").","; $sql .= " busy=".(isset($this->busy) ? $this->busy : "null").","; $sql .= " mandatory=".(isset($this->mandatory) ? $this->mandatory : "null").","; - $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null'); $sql .= " WHERE rowid=".((int) $this->id); diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index eedfcc06245..f69b82727f0 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -372,7 +372,7 @@ if (!$ret) { if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, ($action == 'classify' ? 1 : 0), 0, 1, ''); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -555,7 +555,7 @@ if (!$ret) { $morehtmlref .= ''; $morehtmlref .= ''; } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$fichinter->id, $fichinter->socid, $fichinter->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($fichinter->fk_project)) { diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index 0b961648115..42fecf28b37 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -308,7 +308,7 @@ if ($action == 'add' && empty($cancel)) { $db->commit(); if (GETPOST('saveandnew', 'alpha')) { - setEventMessages($langs->trans("RecordSaved"), '', 'mesgs'); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); header("Location: card.php?action=create&fk_project=" . urlencode($projectid) . "&accountid=" . urlencode($accountid) . '&paymenttype=' . urlencode(GETPOST('paymenttype', 'az09')) . '&datepday=' . GETPOST("datepday", 'int') . '&datepmonth=' . GETPOST("datepmonth", 'int') . '&datepyear=' . GETPOST("datepyear", 'int')); exit; } else { @@ -381,6 +381,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->salaries- $object->paye = 0; $object->id = $object->ref = null; + if (GETPOST('amount', 'alphanohtml')) { + $object->amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT', 2); + } + if (GETPOST('clone_label', 'alphanohtml')) { $object->label = GETPOST('clone_label', 'alphanohtml'); } else { @@ -658,18 +662,25 @@ if ($action == 'create' && $permissiontoadd) { print ''; print "Transaction status registered, you can close this"; diff --git a/htdocs/theme/eldy/badges.inc.php b/htdocs/theme/eldy/badges.inc.php index 1e6dfb54dbc..aae4e50fb29 100644 --- a/htdocs/theme/eldy/badges.inc.php +++ b/htdocs/theme/eldy/badges.inc.php @@ -246,7 +246,7 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL if (in_array((string) $statusName, $TBadgeBorderOnly)) { $thisBadgeTextColor = '#212529'; - $thisBadgeBackgroundColor = "#fff"; + $thisBadgeBackgroundColor = ""; } if (in_array((string) $statusName, array('0', '5', '9'))) { diff --git a/htdocs/theme/eldy/btn.inc.php b/htdocs/theme/eldy/btn.inc.php index b29c55bd02d..28ae22e9696 100644 --- a/htdocs/theme/eldy/btn.inc.php +++ b/htdocs/theme/eldy/btn.inc.php @@ -18,7 +18,9 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { if (!empty($conf->global->THEME_DARKMODEENABLED)) { print "/* For dark mode */\n"; if ($conf->global->THEME_DARKMODEENABLED != 2) { - print "@media (prefers-color-scheme: dark) {"; + print "@media (prefers-color-scheme: dark) {"; // To test, click on the 3 dots menu, then Other options then Display then emulate prefer-color-schemes + } else { + print "@media not print {"; } print " :root { @@ -32,9 +34,7 @@ if (!empty($conf->global->THEME_DARKMODEENABLED)) { --textbutaction: rgb(255,255,255); }\n"; - if ($conf->global->THEME_DARKMODEENABLED != 2) { - print "}"; - } + print "}"; } ?> diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 687bc6bf2a7..027305965ed 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1,6 +1,9 @@ - +} + +?> /*
'; print '
'; } + $recuitment = new RecruitmentJobPosition($db); + $recuitment->fetch($obj->fk_recruitmentjobposition); + $object->fk_recruitmentjobposition = $recuitment->getNomUrl(); + $object->phone = $obj->phone; // Output Kanban - print $object->getKanbanView(''); + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + if ($massactionbutton || $massaction) { + $selected = 0; + } + // Output Kanban + print $object->getKanbanView(''); + } if ($i == ($imaxinloop - 1)) { print '
'; print '
'; print '
'; } - // Output Kanban - print $object->getKanbanView(''); + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + if ($massactionbutton || $massaction) { + $selected = 0; + } + // Output Kanban + print $object->getKanbanView(''); + } if ($i == ($imaxinloop - 1)) { print '
'; print '
'.$langs->trans("ResourceType").''; - $ret = $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); + $formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2); print '