merge from develop

This commit is contained in:
Florian HENRY 2020-11-19 13:53:34 +01:00
commit 46326d7659
2195 changed files with 126810 additions and 117262 deletions

View File

@ -13,5 +13,5 @@ jobs:
- name: Exakat - name: Exakat
uses: docker://exakat/exakat-ga uses: docker://exakat/exakat-ga
with: with:
ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/WrongNumberOfArguments,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/UselessParenthesis,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UseConstant' ignore_rules: 'Classes/UseInstanceof,Performances/PrePostIncrement,Functions/UndefinedFunctions,Functions/WrongNumberOfArguments,Functions/WrongTypeWithCall,Variables/UndefinedVariable,Classes/DontUnsetProperties,Classes/NonPpp,Classes/StaticMethodsCalledFromObject,Classes/UseClassOperator,Functions/UsesDefaultArguments,Php/NoClassInGlobal,Php/ShouldUseCoalesce,Php/WrongTypeForNativeFunction,Structures/MergeIfThen,Structures/ElseIfElseif,Structures/RepeatedPrint,Structures/SameConditions,Structures/SwitchWithoutDefault,Structures/ShouldMakeTernary,Structures/UselessParenthesis,Structures/UseConstant'
ignore_dirs: '/htdocs/includes,/htdocs/build,/htdocs/dev,/htdocs/doc,/htdocs/scripts,/htdocs/test' ignore_dirs: '/htdocs/includes,/build,/dev,/doc,/scripts,/test'

View File

@ -17,8 +17,10 @@ filter:
- build/* - build/*
- dev/* - dev/*
- doc/* - doc/*
- test/* - documents/*
- htdocs/includes/* - htdocs/includes/*
- node_modules/*
- test/*
paths: paths:
- htdocs/* - htdocs/*
- scripts/* - scripts/*

View File

@ -35,10 +35,6 @@ addons:
php: php:
- '5.6' - '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'
- '7.4' - '7.4'
- nightly - nightly
@ -112,33 +108,48 @@ install:
echo "Updating Composer" echo "Updating Composer"
rm $TRAVIS_BUILD_DIR/composer.json rm $TRAVIS_BUILD_DIR/composer.json
rm $TRAVIS_BUILD_DIR/composer.lock rm $TRAVIS_BUILD_DIR/composer.lock
composer -V
composer self-update composer self-update
# To have composer making parallel downloads
composer global require hirak/prestissimo
composer -n init composer -n init
composer -n config vendor-dir htdocs/includes composer -n config vendor-dir htdocs/includes
composer -n config -g vendor-dir htdocs/includes
echo echo
- | - |
echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION"
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ if [ "$TRAVIS_PHP_VERSION" = '5.6' ]; then
[ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
composer -n require phpunit/phpunit ^5 \ composer -n require phpunit/phpunit ^5 \
php-parallel-lint/php-parallel-lint ^1 \ php-parallel-lint/php-parallel-lint ^1 \
php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
if [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] || [ "$TRAVIS_PHP_VERSION" = '7.2' ]; then
composer -n require phpunit/phpunit ^6 \
php-parallel-lint/php-parallel-lint ^1 \
php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3
fi
if [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
composer -n require phpunit/phpunit ^7 \
php-parallel-lint/php-parallel-lint ^1.2 \
php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3
fi
# phpunit 9 is required for php 8
if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then
composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ composer -n require --ignore-platform-reqs phpunit/phpunit ^7 \
php-parallel-lint/php-parallel-lint ^1.2 \ php-parallel-lint/php-parallel-lint ^1.2 \
php-parallel-lint/php-console-highlighter ^0 \ php-parallel-lint/php-console-highlighter ^0 \
squizlabs/php_codesniffer ^3 squizlabs/php_codesniffer ^3
fi fi
echo echo
- | - |
echo "Adding path of binaries tools installed by composer to the PATH" echo "Adding path of binaries tools installed by composer to the PATH"
export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$TRAVIS_BUILD_DIR/vendor/bin:$TRAVIS_BUILD_DIR/htdocs/includes:$PATH"
echo $PATH
ls $TRAVIS_BUILD_DIR/vendor
ls $TRAVIS_BUILD_DIR/htdocs/includes/bin
echo echo
@ -165,15 +176,20 @@ before_script:
- | - |
echo "Versions information" echo "Versions information"
echo
# Check PHP # Check PHP
echo "PHP version" echo "PHP version"
php -i | head - php -i | head -
# Check PHP CodeSniffer installation # Check Parallel-lint version
echo "Parallel-lint version"
which parallel-lint
parallel-lint -V
# Check PHP CodeSniffer version
echo "PHPCS version" echo "PHPCS version"
which phpcs which phpcs
phpcs --version | head - phpcs --version | head -
phpcs -i | head - phpcs -i | head -
# Check PHPUnit installation # Check PHPUnit version
echo "PHPUnit version" echo "PHPUnit version"
which phpunit which phpunit
phpunit --version | head - phpunit --version | head -
@ -287,12 +303,13 @@ script:
echo echo
- | - |
echo "Checking coding style (excluding Pull Requests builds)" echo "Checking coding style (excluding Pull Requests builds to not overload travis, excluding also some jobs to avoid duplicate tests)"
# Ensure we catch errors # Ensure we catch errors
set -e set -e
# Exclusions are defined in the ruleset.xml file # Exclusions are defined in the ruleset.xml file
#phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ] && [ "$DB" = "mysql" ]; then
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .;
fi
set +e set +e
echo echo
@ -409,7 +426,7 @@ script:
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
# Enable modules not enabled into original dump # Enable modules not enabled into original dump
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
echo $? echo $?
cd - cd -
set +e set +e

View File

@ -21,6 +21,7 @@ Mobiledetect 2.8.34 MIT License Yes
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package) NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
ParseDown 1.6 MIT License Yes Markdown parser ParseDown 1.6 MIT License Yes Markdown parser
PCLZip 2.8.4 LGPL-3+ Yes Library to zip/unzip files
PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers PHPDebugBar 1.15.1 MIT License Yes Used only by the module "debugbar" for developers
PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPExcel 1.8.1 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files

267
ChangeLog
View File

@ -4,152 +4,155 @@ English Dolibarr ChangeLog
***** ChangeLog for 13.0.0 compared to 12.0.0 ***** ***** ChangeLog for 13.0.0 compared to 12.0.0 *****
For users: For users:
----------
NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files. NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files.
NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable. NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable.
NEW: Several security issues after a private bug bounty campaign. NEW: Several security issues after a private bug bounty campaign.
NEW: #15065 Fix formatting
NEW: #15065 Put the product label in bold in the PDF templates if configured NEW: #15065 Put the product label in bold in the PDF templates if configured
NEW: Accountancy - Add chart of sub accounts NEW: Accountancy - add chart of sub accounts
NEW: Accountancy - Add options to disable binding on sales, purchases & expense reports independently of the modules NEW: Accountancy - add options to disable binding on sales, purchases & expense reports independently of the modules
NEW: Accountancy balance - Add a input to show subtotal by group NEW: Accountancy balance - add a menu entry to show subtotal by group
NEW: Accountancy - Move to real ledger, real journals, menu disposition NEW: Accountancy - move to real ledger, real journals, menu disposition
NEW: Accountancy - On transfers, select the periodicity by default NEW: Accountancy - on transfers, select the periodicity by default
NEW: Add 2 rules for emailcollector: Message send/not sent from Dolibarr NEW: new currency rate editor
NEW: Add a counter of number of words of pages in website module NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr
NEW: add alert before change thirdparty in takepos NEW: add a counter of number of words for pages in website module
NEW: Add a page to list Stock at a given date. NEW: add alert before changing thirdparty in TakePOS
NEW: Add a start date to begin binding in accountancy NEW: add a page to list Stock at a given date in the past
NEW: Add a stat page to list popularity of products on invoices NEW: add a start date to begin binding in accountancy
NEW: Add calendar selection for agenda view NEW: add a statistics page to list popularity of products on invoices
NEW: add class for ticket edition (pdf or odt) NEW: add calendar selection for agenda view
NEW: Add column payment term into list of supplier invoices. NEW: Support documents generation for ticket edition (PDF or ODT)
NEW: Add column quantity in product margin page NEW: add column payment term into list of supplier invoices
NEW: Add column vat rate in page to define accounting account on product/service NEW: add column quantity in product margin page
NEW: Add common list function for available app/module page NEW: add column vat rate in page to define accounting account on product/service
NEW: add common list function for available app/module page
NEW: add costprice in fields of products list NEW: add costprice in fields of products list
NEW: ADDED IMPORT TOOL FOR CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE NEW: added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
NEW: Added incoterms to substitution array NEW: added incoterms data into the substitution array
NEW: Add employee in expense report binding page NEW: add employee link in expense report binding page
NEW: Add export for various payment NEW: add export for various payment
NEW: add extra fields labels and values in mail on create ticket NEW: add Extrafields labels and values in mail on create ticket
NEW: Add extrafields support on ECM module NEW: add Extrafields support on ECM module
NEW: Add filter rules "is answer" and "is not answer" in email collector NEW: add filter rules "is answer" and "is not answer" in email collector
NEW: Add focus when editing on product/stock/product.php Close #14548 NEW: add focus when editing on product/stock/product.php Close #14548
NEW: add formConfirm hook on product page NEW: add formConfirm hook on product page
NEW: add free text on each terminal of cash desk NEW: add free text on each terminal of cash desk
NEW: Add function dolButtonToOpenUrlInDialogPopup() to be able to open NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open
NEW: Add global search for customer payments and vendor payments NEW: add global search for customer payments and vendor payments
NEW: Add global search for miscellaneous payments NEW: add global search for miscellaneous payments
NEW: Add helper function for table headers with numbers NEW: add helper function for table headers with numbers
NEW: add hooks on stats pages NEW: add hooks on stats pages
NEW: Add link to edit property from search result of website pages NEW: add link to edit property from search result of website pages
NEW: Add link to reset qty on supplier dispatch page NEW: add link to reset qty on supplier dispatch page
NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header in email collector NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector
NEW: Add Manufacturing Orders into the automatic ECM NEW: add Manufacturing Orders attached files into the automatic ECM view
NEW: add margin info in invoice list NEW: add margin info in invoice list
NEW: Add mass action to set category on a list of website pages. NEW: add mass action to set category on a list of website pages
NEW: Add mass deletion for events NEW: add mass deletion for events
NEW: Add __MEMBER_TYPE__ substitution key NEW: add mass deletion for draft invoices
NEW: Add message in error_log after detection of SQL or script injection NEW: add __MEMBER_TYPE__ substitution key
NEW: Add module Credit transfer SEPA to manage payment of supplier using NEW: add a message in error_log after detection of SQL or script injection
NEW: Add more filters on monthly statement list NEW: add module Credit transfer SEPA to manage payment of supplier using
NEW: Add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT NEW: add more filters on monthly statement list
NEW: Add option to define a default warehouse at user level NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT
NEW: Add option to include products without alert in replenish NEW: add option to define a default warehouse at user level
NEW: add option to include products without alert in replenish
NEW: add order by lastname and firstname by default in get sales representatives NEW: add order by lastname and firstname by default in get sales representatives
NEW: Add param to not show links when output tags NEW: add param to not show links when output tags
NEW: Add PDF document templates for warehouses (list of stock) NEW: add PDF document templates for warehouses (list of stock)
NEW: Add property cssview when declaring fields of an object NEW: add property cssview when declaring fields of an object
NEW: Add prospect status managment for the contact with managment of custom icon NEW: add prospect status managment for the contact with managment of custom icon
NEW: Add public note on products. This also partially fix the #14342 NEW: add public note on products ; this also partially fix the #14342
NEW: Add quick dropdown menu in top right menu (MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN) NEW: add quick dropdown menu in top right menu (MAIN_USE_TOP_MENU_QUICKADD_DROPDOWN)
NEW: add region in export companies and contacts NEW: add region in export companies and contacts
NEW: add rights on margin info on invoice list NEW: add rights on margin info on invoice list
NEW: Add search param for close date on order list NEW: add search param for close date on order list
NEW: add send context for ticket NEW: add send context for ticket
NEW: Add show preview for mail attachement on form mail NEW: add show preview for mail attachement on form mail
NEW: add state origin for product NEW: add state origin for product
NEW: add State/Province origin for products NEW: add State/Province origin for products
NEW: Add the workflow interaction close intervention on closing ticket NEW: add the workflow interaction close intervention on closing ticket
NEW: Add third order printer to TakePOS NEW: add third order printer to TakePOS
NEW: add tracking number in list and search_all items NEW: add tracking number in list and search_all items
NEW: add two hooks printFieldListFrom and printFieldSearchParam NEW: add two hooks printFieldListFrom and printFieldSearchParam
NEW: Add __TYPE__ substitution key NEW: add __TYPE__ substitution key
NEW: Add validation of MX domain for emails NEW: add validation of MX domain for emails
NEW: add vcard for aderent and user NEW: add vcard for aderent and user
NEW: add week number for month view in agenda NEW: add week number for month view in agenda
NEW: Algeria data (tva and forme_juridique) NEW: Algeria data (tva and forme_juridique)
NEW: Allow click on all header numbers on commerce area NEW: allow click on all header numbers on commerce area
NEW: Allow to reopen interventions (green button) NEW: allow to reopen interventions (green button)
NEW: Allow zero quality on supplier/vendor order line NEW: allow zero quality on supplier/vendor order line
NEW: Appearance tab in TakePOS with more visual parameters NEW: appearance tab in TakePOS with more visual parameters
NEW: Better currency rate editor NEW: better currency rate editor
NEW: Calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') )
NEW: Can add event to log into blockedlog module with a constant. NEW: can add event to log into blockedlog module with a constant
NEW: Can build vendor invoice from vendor orders NEW: can build vendor invoice from vendor orders
NEW: Can change a product in line of recurring invoice or contract NEW: can change a product in line of recurring invoice or contract
NEW: Can change size of logo on PDF documents NEW: can change size of logo on PDF documents
NEW: Can change VAT rate of all lines of a draft object in one step. NEW: can change VAT rate of all lines of a draft object in one step
NEW: Can define date range of validity of a login during creation NEW: can define date range of validity of a login during creation
NEW: Can disable, from edit page, the whole web site NEW: can disable, from edit page, the whole web site
NEW: can edit and set sales representatives directly on thirdparty card NEW: can edit and set sales representatives directly on thirdparty card
NEW: Can edit the list of sending email profiles. NEW: Can edit the list of sending email profiles.
NEW: Can enable/disable users in bulk actions NEW: can enable/disable users in bulk actions
NEW: Can filter on accounting system ref in export of chart of account NEW: can filter on accounting system ref in export of chart of account
NEW: Can filter on container type, language and tags in the list of pages NEW: can filter on container type, language and tags in the list of pages
NEW: Can force the antivirus from conf file or autoprepend ini setup. NEW: can force the antivirus from conf file or autoprepend ini setup
NEW: Can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY NEW: can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY
NEW: Can import proposals, sales orders, supplier invoices NEW: can import proposals, sales orders, supplier invoices
NEW: can set a dedicated SMTP config for sending email from public ticket interface NEW: can set a dedicated SMTP config for sending email from public ticket interface
NEW: Can set tags/categories to website pages. NEW: can set tags/categories to website pages
NEW: Can set type of price without tax per default for new sale price creation NEW: can set type of price without tax per default for new sale price creation
NEW: Can use desired stock of a given warehouse for replenishment NEW: can use desired stock of a given warehouse for replenishment
NEW: Can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
NEW: change thirdparty with barcode scan in takepos NEW: change thirdparty with barcode scan in TakePOS
NEW: Common behavior for monthly leave list view NEW: common behavior for monthly leave list view
NEW: conf to allow show full arbo in warehouse getnomurl NEW: conf to allow show full arbo in warehouse getnomurl
NEW: convert all subscription in datetime NEW: convert all subscription in datetime
NEW: create thirdparty customer from TAKEPOS NEW: create thirdparty customer from TakePOS
NEW: Date shipment from order accepts hours NEW: date shipment from order accepts hours
NEW: Declinaison price level compatibility NEW: declinaison price level compatibility
NEW: Delayed payment in TakePOS NEW: delayed payment in TakePOS
NEW: Development of module Recruitment NEW: development of module Recruitment
NEW: display date range if exist in takepos NEW: display date range if exist in TakePOS
NEW: display resiliate status in takepos for member NEW: display resiliate status in TakePOS for member
NEW: display stat for BOM on "object referent"/linked Object product tab NEW: display stat for BOM on "object referent"/linked Object product tab
NEW: edit and update a ticket NEW: edit and update a ticket
NEW: edit or delete dispatched lines NEW: edit or delete dispatched lines
NEW: Email configuration - Allow auto signed certificat when smtp ssl activated NEW: Email configuration - allow auto signed certificat when smtp ssl activated
NEW: enable free emails input with select2 NEW: enable free emails input with select2
NEW: endpoint getContacts and Clean results NEW: endpoint getContacts and Clean results
NEW: Events in agenda for contact NEW: Events in agenda for contact
NEW: Field to link website page to an other object NEW: Field to link website page to an other object
NEW: Fill ECM src object fields in dol_add_file_process NEW: fill ECM src object fields in dol_add_file_process
NEW: filter on progress column in task list NEW: filter on progress column in task list
NEW: filter product list by country and/or state/province NEW: filter product list by country and/or state/province
NEW: format tickets sent by mail in public interface NEW: format tickets sent by mail in public interface
NEW: add juridical status for Algeria NEW: add juridical status for Algeria
NEW: form to add customer/supplier into categories NEW: form to add customer/supplier into categories
NEW: Framework is ready for CSRF token protection on explicit GET URLs. NEW: Framework is ready for CSRF token protection on explicit GET URLs
NEW: get all child recursively NEW: get all child recursively
NEW: Get contacts list of a given order NEW: get contacts list of a given order
NEW: helper functions for export with phpspreadsheet NEW: helper functions for export with phpspreadsheet
NEW: hide closed contract lines NEW: hide closed contract lines
NEW: hide label in pdf for variants NEW: hide label in PDF for variants
NEW: Hook on propal card NEW: Hook on propal card
NEW: If specific help page is available, we change color of icon NEW: if specific help page is available, we change color of icon
NEW: Include the tag editor of page as a popup into website editor NEW: include the tag editor of page as a popup into website editor
NEW: Introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM NEW: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM
NEW: Introducing new modal boxes in TakePOS NEW: introducing new modal boxes in TakePOS
NEW: Keep takepos terminal when login/logout NEW: keep TakePOS terminal when login/logout
NEW: Link on balance to the ledger NEW: link on balance to the ledger
NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector
NEW: manage errors on update extra fields in ticket card NEW: manage errors on update extra fields in ticket card
NEW: mass-actions for the event list view NEW: mass-actions for the event list view
NEW: Module Intracomm report NEW: Module Intracomm report
NEW: More filter for "View change logs" NEW: more filter for "View change logs"
NEW: multicurrency total in takepos NEW: multicurrency total in TakePOS
NEW: multiselect type and date to date filter NEW: multiselect type and date to date filter
NEW: Nature of product is now a dictionay NEW: Nature of product is now a dictionay
NEW: new line template: hidden conf to fill service dates from the last service line NEW: new line template: hidden conf to fill service dates from the last service line
@ -158,38 +161,38 @@ NEW: possibilty to group payments by mode and show their subtotal
NEW: Print payment method and change in TakePOS NEW: Print payment method and change in TakePOS
NEW: Priority and transparency from external calendar events NEW: Priority and transparency from external calendar events
NEW: Products Import/Export 'default warehouse' and 'use batch number' fields NEW: Products Import/Export 'default warehouse' and 'use batch number' fields
NEW: Purchase price table: Added filterable table columns NEW: Purchase price table: added filterable table columns
NEW: rate editor for multicurrency NEW: rate editor for multicurrency
NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines NEW: ref_ext field for Commande lines, order lines, Attributes and Combinations, Invoice lines, payments, order lines
NEW: remove new lines in mail on add ticket message NEW: remove new lines in mail on add ticket message
NEW: restrict thirdparty to customer in takepos NEW: restrict thirdparty to customer in TakePOS
NEW: Allow to edit "demand reason" field though API NEW: allow to edit "demand reason" field though API
NEW: Rule "email to" accept wildcard * NEW: Rule "email to" accept wildcard *
NEW: Save filter of the project homepage NEW: Save filter of the project homepage
NEW: Select-able columns on customer invoice paymnet list NEW: select-able columns on customer invoice paymnet list
NEW: Select-able columns on miscellaneous payments + more data columns NEW: select-able columns on miscellaneous payments + more data columns
NEW: Select-able columns on social taxes list NEW: select-able columns on social taxes list
NEW: Select-able columns on supplier invoice payment list NEW: select-able columns on supplier invoice payment list
NEW: send context and remove new lines on create ticket NEW: send context and remove new lines on create ticket
NEW: set entity when creating invoice on takepos NEW: set entity when creating invoice on takepos
NEW: Show available stock in TakePOS NEW: show available stock in TakePOS
NEW: Show category filter on lists only when user have rights to read categories NEW: show category filter on lists only when user have rights to read categories
NEW: Show header number and make it clickable in warehouse arean, payment area, shipment area NEW: show header number and make it clickable in warehouse arean, payment area, shipment area
NEW: Show image of user in the combo select of users NEW: show image of user in the combo select of users
NEW: Show label on batch card NEW: show label on batch card
NEW: Show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
NEW: show links for select and multi-select in category extra field NEW: show links for select and multi-select in category extra field
NEW: Show module and permission ids on user/group rights (only admin) NEW: show module and permission ids on user/group rights (only admin)
NEW: Show place from events on import calender NEW: show place from events on import calender
NEW: Show references in contract form on interventions NEW: show references in contract form on interventions
NEW: Show tags and status in search list of website pages NEW: show tags and status in search list of website pages
NEW: Show user on external calender events (when found) NEW: show user on external calender events (when found)
NEW: subject title with company name instead of application title in ticket message NEW: subject title with company name instead of application title in ticket message
NEW: Support for Samba4 AD NEW: Support for Samba4 AD
NEW: TakePOS connector compatibility with RECEIPT PRINTERS module NEW: TakePOS connector compatibility with RECEIPT PRINTERS module
NEW: TakePOS Gift Receipt NEW: TakePOS Gift Receipt
NEW: TakePOS Multicurrency compatibility NEW: TakePOS Multicurrency compatibility
NEW: The global header of a website can also have dynamic content NEW: the global header of a website can also have dynamic content
NEW: Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms NEW: Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms
NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late
NEW: ticket classification on create from email collector NEW: ticket classification on create from email collector
@ -198,16 +201,18 @@ NEW: translate classification labels in ticket
NEW: triggers create, modify, delete NEW: triggers create, modify, delete
NEW: VAT for Algeria NEW: VAT for Algeria
NEW: Use preselect third-party from list on new card NEW: Use preselect third-party from list on new card
NEW: Vat report - Invert constant to show by default zero vat in reports NEW: VAT report - Invert constant to show by default zero vat in reports
NEW: website page fields selection NEW: website page fields selection
NEW: Weighing Scale compatibility with TakePOS connector NEW: Weighing Scale compatibility with TakePOS connector
NEW: When creating a user from a member linked to a thirdparty, you can choose to create if as external or internal user NEW: when creating a user from a member linked to a thirdparty, you can choose to create if as external or internal user
NEW: Add clone functionality on miscellaneous payment NEW: add clone functionality on miscellaneous payment
For developers: For developers:
---------------
NEW: Can use dynamic code into the 'enabled' property of DAO fields NEW: Can use dynamic code into the 'enabled' property of DAO fields
NEW: API Can update a payment NEW: API can update a payment
NEW: api get member by thirdparty NEW: API get member by thirdparty
NEW: API get thirdparty by barcode NEW: API get thirdparty by barcode
NEW: API get users by email / login NEW: API get users by email / login
NEW: fetch contact by email with REST API NEW: fetch contact by email with REST API
@ -215,14 +220,15 @@ NEW: field ref_ext in llx_commandedet
NEW: fields ref_ext for Attributes and Combinations NEW: fields ref_ext for Attributes and Combinations
NEW: get state by REST API NEW: get state by REST API
NEW: get state dictionnary by REST API NEW: get state dictionnary by REST API
NEW: Improve Product API for variant products NEW: improve Product API for variant products
NEW: Oauth SCOPE for Admin SDK NEW: OAuth SCOPE for Admin SDK
NEW: Retrieve discount from invoice from API NEW: retrieve discount from invoice from API
NEW: standardizes API thirdparties by email like other object NEW: standardizes API thirdparties by email like other object
NEW: thirdparty REST API: endpoint to set price level NEW: Thirdparty REST API: endpoint to set price level
NEW: Use new category API for project list view NEW: use new category API for project list view
NEW: Triggers Attributes and Attributes values NEW: Triggers Attributes and Attributes values
NEW: Add hooks on newpayment page to allow external payment modules NEW: add hooks on newpayment page to allow external payment modules
WARNING: WARNING:
@ -288,6 +294,7 @@ FIX: Visualization rights correction on last modified contacts box
FIX: Wrong redirection FIX: Wrong redirection
FIX: Yogosha report 4425 (backport) FIX: Yogosha report 4425 (backport)
***** ChangeLog for 12.0.2 compared to 12.0.1 ***** ***** ChangeLog for 12.0.2 compared to 12.0.1 *****
FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet
FIX: DebugBar hides content at page bottom FIX: DebugBar hides content at page bottom

View File

@ -6,7 +6,7 @@
Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans). Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans).
Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...). Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...).
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg) ![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENCE ## LICENCE

View File

@ -15,7 +15,7 @@ You can use it as a standalone application or as a web application to access it
Dolibarr has a large community ready to help you, free forums and [oficially preferred partners ready to offer commercial support should you need it](https://partners.dolibarr.org) Dolibarr has a large community ready to help you, free forums and [oficially preferred partners ready to offer commercial support should you need it](https://partners.dolibarr.org)
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg) ![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENSE ## LICENSE

View File

@ -232,7 +232,7 @@ $dolibarr_main_prod='0';
# Examples: # Examples:
# $dolibarr_mailing_limit_sendbycli='0'; # $dolibarr_mailing_limit_sendbycli='0';
# dolibarr_distrib # dolibarr_main_distrib
# A key to identify the distribution used for first installation # A key to identify the distribution used for first installation
$dolibarr_distrib = 'deb'; $dolibarr_main_distrib = 'debian';

View File

@ -24,6 +24,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='444'; $force_install_lockinstall='444';
$force_install_distrib='debian';
// Value to overwrite path to use shared libraries/fonts instead of embedded one. // Value to overwrite path to use shared libraries/fonts instead of embedded one.
// If during install, we enable/disable declaration to use non embedded libraries, we must also check they are // If during install, we enable/disable declaration to use non embedded libraries, we must also check they are

View File

@ -22,6 +22,7 @@ $force_install_databaserootpass='WAMPMYSQLNEWPASSWORD';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='644'; $force_install_lockinstall='644';
$force_install_distrib='doliwamp';
$force_install_module=''; $force_install_module='';
?> ?>

View File

@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='444'; $force_install_lockinstall='444';
$force_install_distrib='rpmfedora';
// Value to overwrite path to use shared libraries/fonts instead of embedded one // Value to overwrite path to use shared libraries/fonts instead of embedded one
$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';

View File

@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='444'; $force_install_lockinstall='444';
$force_install_distrib='rpmgeneric';
// Value to overwrite path to use shared libraries/fonts instead of embedded one // Value to overwrite path to use shared libraries/fonts instead of embedded one
// We don't force any external lib with generic package // We don't force any external lib with generic package

View File

@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='444'; $force_install_lockinstall='444';
$force_install_distrib='rpmmandriva';
// Value to overwrite path to use shared libraries/fonts instead of embedded one // Value to overwrite path to use shared libraries/fonts instead of embedded one
$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; $force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';

View File

@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
$force_install_dolibarrlogin='admin'; $force_install_dolibarrlogin='admin';
$force_install_nophpinfo='1'; $force_install_nophpinfo='1';
$force_install_lockinstall='444'; $force_install_lockinstall='444';
$force_install_distrib='rpmopensuse';
// Value to overwrite path to use shared libraries/fonts instead of embedded one // Value to overwrite path to use shared libraries/fonts instead of embedded one
//$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; //$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';

View File

@ -1,10 +1,19 @@
# HOW TO BUILD # HOW TO BUILD
## DEVELOPPER ACCOUNT
## ENABLE MODULE ZAPIER ON DOLIBARR
This should also enable the module API (required for authentication by Zapier service and to execute action in Dolibarr by Zapier).
Create the Dolibarr login that will be used by Zapier to call APIs. Give the login the permissions on the action you plan to automate.
## CREATE A ZAPIER DEVELOPPER ACCOUNT
At first, you need to have a Zapier developper acoount, create it here [Zapier Platform](https://developer.zapier.com/) At first, you need to have a Zapier developper acoount, create it here [Zapier Platform](https://developer.zapier.com/)
## BUILD INTEGRATION
## INSTALL ZAPIER COMMAND LINE TOOLS WITH LINK TO ZAPIER ONLINE ACCOUNT
### Install Node.js ### Install Node.js
@ -17,7 +26,7 @@ After installation, confirm that Node.js is ready to use:
Next let's install the Zapier CLI tools. The CLI will allow you to build your app, deploy it to the Zapier platform, do local testing, manage users and testers, view remote logs, collaborate with your team, and more: Next let's install the Zapier CLI tools. The CLI will allow you to build your app, deploy it to the Zapier platform, do local testing, manage users and testers, view remote logs, collaborate with your team, and more:
`cd dev/exemples/zapier` `cd dev/examples/zapier`
`npm install -g zapier-platform-cli` to install the CLI globally `npm install -g zapier-platform-cli` to install the CLI globally
@ -27,13 +36,15 @@ Next let's install the Zapier CLI tools. The CLI will allow you to build your ap
Let's configure authentication between your dev environment and the Zapier platform. You'll use the email address and password you use to log in to the Zapier application. Let's configure authentication between your dev environment and the Zapier platform. You'll use the email address and password you use to log in to the Zapier application.
`zapier --version` `zapier login`
This command will set up a .zapierrc file in your home directory. This command will set up a .zapierrc file in your home directory.
### Install the Project ### Install the Project
In zapier exemple directory, run: In zapier example directory, run:
`cd dev/examples/zapier`
`npm install` `npm install`
@ -41,8 +52,17 @@ In zapier exemple directory, run:
Let's deploy it! When you're ready to try your code out on the Zapier platform use the push command. Only you will be able to see the app until you invite testers. Let's deploy it! When you're ready to try your code out on the Zapier platform use the push command. Only you will be able to see the app until you invite testers.
`zapier register` (the first time, choose name for example "Dolibarr")
`zapier push` `zapier push`
### More info After a push, the Application, with the name you defined during the register step, is available when creating a Zap.
You will find original tutorial here : [https://zapier.com/developer/start/introduction](https://zapier.com/developer/start/introduction) You will find original tutorial here : [https://zapier.com/developer/start/introduction](https://zapier.com/developer/start/introduction)
### Create a Zap
Create a ZAP that use the application you registered.
For authentication, you must enter the login / pass of account used by Zapier to call APIs.

View File

@ -1,6 +1,6 @@
/*jshint esversion: 6 */ /*jshint esversion: 6 */
const testAuth = (z , bundle) => { const test = (z , bundle) => {
const url = bundle.authData.url+'/api/index.php/login'; const url = bundle.authData.url+'/api/index.php/status';
// Normally you want to make a request to an endpoint that is either specifically designed to test auth, or one that // Normally you want to make a request to an endpoint that is either specifically designed to test auth, or one that
// every user will have access to, such as an account or profile endpoint like /me. // every user will have access to, such as an account or profile endpoint like /me.
// In this example, we'll hit httpbin, which validates the Authorization Header against the arguments passed in the URL path // In this example, we'll hit httpbin, which validates the Authorization Header against the arguments passed in the URL path
@ -11,67 +11,92 @@ const testAuth = (z , bundle) => {
// This method can return any truthy value to indicate the credentials are valid. // This method can return any truthy value to indicate the credentials are valid.
// Raise an error to show // Raise an error to show
return promise.then((response) => { return promise.then((response) => {
if (response.status === 401) { if (response.status === 400) {
throw new Error('The Session Key you supplied is invalid'); throw new Error('400 -The Session Key you supplied is invalid');
}
if (response.status === 403) {
throw new Error('403 -The Session Key you supplied is invalid');
} }
return response; return response;
}); });
}; };
const getSessionKey = (z, bundle) => { // To include the session key header on all outbound requests, simply define a function here.
// It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot
const includeSessionKeyHeader = (request, z, bundle) => {
if (bundle.authData.sessionKey) {
request.headers = request.headers || {};
request.headers['DOLAPIKEY'] = bundle.authData.sessionKey;
}
return request;
};
// If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange.
const sessionRefreshIf401 = (response, z, bundle) => {
if (bundle.authData.sessionKey) {
if (response.status === 401) {
throw new z.errors.RefreshAuthError('Session apikey needs refreshing.');
}
}
return response;
};
const getSessionKey = async (z, bundle) => {
const url = bundle.authData.url + '/api/index.php/login'; const url = bundle.authData.url + '/api/index.php/login';
const promise = z.request({ const response = await z.request({
method: 'POST',
url: url, url: url,
method: 'POST',
body: { body: {
login: bundle.authData.login, login: bundle.authData.login,
password: bundle.authData.password, password: bundle.authData.password,
} },
}); });
return promise.then((response) => { // if (response.status === 401) {
if (response.status === 401) { // throw new Error('The login/password you supplied is invalid');
throw new Error('The login/password you supplied is invalid'); // }
} const json = JSON.parse(response.content);
const json = JSON.parse(response.content); return {
return { sessionKey: json.success.token || '',
sessionKey: json.success.token || 'secret' };
};
});
}; };
module.exports = { module.exports = {
type: 'session', config: {
// Define any auth fields your app requires here. The user will be prompted to enter this info when type: 'session',
// they connect their account. sessionConfig: {
fields: [ perform: getSessionKey
{
key: 'url',
label: 'Url of service',
required: true,
type: 'string'
}, },
{ // Define any auth fields your app requires here. The user will be prompted to enter this info when
key: 'login', // they connect their account.
label: 'Login', fields: [
required: true, {
type: 'string' key: 'url',
}, label: 'Url of service without trailing-slash',
{ required: true,
key: 'password', type: 'string'
label: 'Password', },
required: true, {
type: 'password' key: 'login',
} label: 'Login',
], required: true,
// The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this type: 'string'
// method whenever a user connects their account for the first time. },
test: testAuth, {
// The method that will exchange the fields provided by the user for session credentials. key: 'password',
sessionConfig: { label: 'Password',
perform: getSessionKey required: true,
type: 'password'
}
],
// The test method allows Zapier to verify that the credentials a user provides are valid. We'll execute this
// method whenever a user connects their account for the first time.
test,
// The method that will exchange the fields provided by the user for session credentials.
// assuming "login" is a key returned from the test
connectionLabel: '{{login}}'
}, },
// assuming "login" is a key returned from the test befores: [includeSessionKeyHeader],
connectionLabel: '{{login}}' afters: [sessionRefreshIf401],
}; };

View File

@ -72,7 +72,7 @@ module.exports = {
}, },
outputFields: [ outputFields: [
{key: 'id', label: 'ID'}, {key: 'id', type: "integer", label: 'ID'},
{key: 'name', label: 'Name'}, {key: 'name', label: 'Name'},
{key: 'name_alias', label: 'Name alias'}, {key: 'name_alias', label: 'Name alias'},
{key: 'address', label: 'Address'}, {key: 'address', label: 'Address'},
@ -81,8 +81,8 @@ module.exports = {
{key: 'phone', label: 'Phone'}, {key: 'phone', label: 'Phone'},
{key: 'fax', label: 'Fax'}, {key: 'fax', label: 'Fax'},
{key: 'email', label: 'Email'}, {key: 'email', label: 'Email'},
{key: 'client', label: 'Customer/Prospect 0/1/2/3'}, {key: 'client', type: "integer", label: 'Customer/Prospect 0/1/2/3'},
{key: 'fournisseur', label: 'Supplier 0/1'}, {key: 'fournisseur', type: "integer", label: 'Supplier 0/1'},
{key: 'code_client', label: 'Customer code'}, {key: 'code_client', label: 'Customer code'},
{key: 'code_fournisseur', label: 'Supplier code'} {key: 'code_fournisseur', label: 'Supplier code'}
] ]

View File

@ -1,33 +1,39 @@
/*jshint esversion: 6 */ /*jshint esversion: 6 */
const triggerThirdparty = require('./triggers/thirdparty');
const triggerOrder = require('./triggers/order');
const triggerAction = require('./triggers/action'); const triggerAction = require('./triggers/action');
const triggerOrder = require('./triggers/order');
const triggerThirdparty = require('./triggers/thirdparty');
const triggerTicket = require('./triggers/ticket');
const triggerUser = require('./triggers/user');
const searchThirdparty = require('./searches/thirdparty'); const searchThirdparty = require('./searches/thirdparty');
const createThirdparty = require('./creates/thirdparty'); const createThirdparty = require('./creates/thirdparty');
const authentication = require('./authentication'); const {
config: authentication,
befores = [],
afters = [],
} = require('./authentication');
// To include the session key header on all outbound requests, simply define a function here. // To include the session key header on all outbound requests, simply define a function here.
// It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot // It runs runs before each request is sent out, allowing you to make tweaks to the request in a centralized spot
const includeSessionKeyHeader = (request, z, bundle) => { // const includeSessionKeyHeader = (request, z, bundle) => {
if (bundle.authData.sessionKey) { // if (bundle.authData.sessionKey) {
request.headers = request.headers || {}; // request.headers = request.headers || {};
request.headers['DOLAPIKEY'] = bundle.authData.sessionKey; // request.headers['DOLAPIKEY'] = bundle.authData.sessionKey;
} // }
return request; // return request;
}; // };
// If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange. // If we get a response and it is a 401, we can raise a special error telling Zapier to retry this after another exchange.
const sessionRefreshIf401 = (response, z, bundle) => { // const sessionRefreshIf401 = (response, z, bundle) => {
if (bundle.authData.sessionKey) { // if (bundle.authData.sessionKey) {
if (response.status === 401) { // if (response.status === 401) {
throw new z.errors.RefreshAuthError('Session apikey needs refreshing.'); // throw new z.errors.RefreshAuthError('Session apikey needs refreshing.');
} // }
} // }
return response; // return response;
}; // };
// We can roll up all our behaviors in an App. // We can roll up all our behaviors in an App.
const App = { const App = {
@ -40,11 +46,11 @@ const App = {
// beforeRequest & afterResponse are optional hooks into the provided HTTP client // beforeRequest & afterResponse are optional hooks into the provided HTTP client
beforeRequest: [ beforeRequest: [
includeSessionKeyHeader ...befores
], ],
afterResponse: [ afterResponse: [
sessionRefreshIf401 ...afters
], ],
// If you want to define optional resources to simplify creation of triggers, searches, creates - do that here! // If you want to define optional resources to simplify creation of triggers, searches, creates - do that here!
@ -53,9 +59,11 @@ const App = {
// If you want your trigger to show up, you better include it here! // If you want your trigger to show up, you better include it here!
triggers: { triggers: {
[triggerThirdparty.key]: triggerThirdparty, [triggerAction.key]: triggerAction,
[triggerOrder.key]: triggerOrder, [triggerOrder.key]: triggerOrder,
[triggerAction.key]: triggerAction [triggerThirdparty.key]: triggerThirdparty,
[triggerTicket.key]: triggerTicket,
[triggerUser.key]: triggerUser,
}, },
// If you want your searches to show up, you better include it here! // If you want your searches to show up, you better include it here!

View File

@ -1,6 +1,6 @@
{ {
"name": "dolibarr", "name": "dolibarr",
"version": "1.0.0", "version": "1.13.0",
"description": "An app for connecting Dolibarr to the Zapier platform.", "description": "An app for connecting Dolibarr to the Zapier platform.",
"repository": "Dolibarr/dolibarr", "repository": "Dolibarr/dolibarr",
"homepage": "https://www.dolibarr.org/", "homepage": "https://www.dolibarr.org/",
@ -15,7 +15,7 @@
"npm": ">=5.6.0" "npm": ">=5.6.0"
}, },
"dependencies": { "dependencies": {
"zapier-platform-core": "8.0.1" "zapier-platform-core": "10.1.1"
}, },
"devDependencies": { "devDependencies": {
"mocha": "^5.2.0", "mocha": "^5.2.0",

View File

@ -54,13 +54,20 @@ module.exports = {
// outputFields: () => { return []; } // outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields // Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [ outputFields: [
{key: 'id', label: 'ID'}, {
{key: 'createdAt', label: 'Created At'}, key: 'id',
type: "integer",
label: 'ID'
},
{key: 'createdAt', type: "integer", label: 'Created At'},
{key: 'name', label: 'Name'}, {key: 'name', label: 'Name'},
{key: 'firstname', label: 'Firstname'}, {key: 'firstname', label: 'Firstname'},
{key: 'directions', label: 'Directions'}, {key: 'directions', label: 'Directions'},
{key: 'authorId', label: 'Author ID'}, {key: 'authorId', type: "integer", label: 'Author ID'},
{key: 'style', label: 'Style'} {
key: 'style',
label: 'Style'
}
] ]
} }
}; };

View File

@ -10,14 +10,14 @@ const subscribeHook = (z, bundle) => {
action: bundle.inputData.action action: bundle.inputData.action
}; };
const url = bundle.authData.url + '/api/index.php/zapierapi/hook'; const url = bundle.authData.url + '/api/index.php/zapierapi/hook';
// You can build requests and our client will helpfully inject all the variables // You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this. // you need to complete. You can also register middleware to control this.
const options = { const options = {
url: url, url: url,
method: 'POST', method: 'POST',
body: JSON.stringify(data) body: data,
}; };
// You may return a promise or a normal data structure from any perform method. // You may return a promise or a normal data structure from any perform method.
@ -32,7 +32,7 @@ const unsubscribeHook = (z, bundle) => {
// You can build requests and our client will helpfully inject all the variables // You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this. // you need to complete. You can also register middleware to control this.
const options = { const options = {
url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id, url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id,
method: 'DELETE', method: 'DELETE',
}; };
@ -74,7 +74,7 @@ const getFallbackRealAction = (z, bundle) => {
// For the test poll, you should get some real data, to aid the setup process. // For the test poll, you should get some real data, to aid the setup process.
const module = bundle.inputData.module; const module = bundle.inputData.module;
const options = { const options = {
url: bundle.authData.url + '/api/index.php/agendaevents/0', url: bundle.authData.url + '/api/index.php/agendaevents/0',
}; };
return z.request(options).then((response) => [JSON.parse(response.content)]); return z.request(options).then((response) => [JSON.parse(response.content)]);
@ -100,7 +100,7 @@ module.exports = {
noun: 'Action', noun: 'Action',
display: { display: {
label: 'New Agenda', label: 'New Agenda',
description: 'Trigger when a new agenda with action is done in Dolibarr.' description: 'Triggers when a new agenda with action is done in Dolibarr.'
}, },
// `operation` is where the business logic goes. // `operation` is where the business logic goes.
@ -111,6 +111,7 @@ module.exports = {
inputFields: [ inputFields: [
{ {
key: 'action', key: 'action',
required: true,
type: 'string', type: 'string',
helpText: 'Which action of agenda this should trigger on.', helpText: 'Which action of agenda this should trigger on.',
choices: { choices: {
@ -145,12 +146,33 @@ module.exports = {
// outputFields: () => { return []; } // outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields // Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [ outputFields: [
{key: 'id', label: 'ID'}, {
{key: 'createdAt', label: 'Created At'}, key: 'id',
{key: 'name', label: 'Name'}, type: "integer",
{key: 'usertodo__name', label: 'UserToDo Name'}, label: 'ID'
{key: 'authorId', label: 'Author ID'}, },
{key: 'action', label: 'Action'} {
key: 'createdAt',
type: "integer",
label: 'Created At'
},
{
key: 'name',
label: 'Name'
},
{
key: 'usertodo__name',
label: 'UserToDo Name'
},
{
key: 'authorId',
type: "integer",
label: 'Author ID'
},
{
key: 'action',
label: 'Action'
}
] ]
} }
}; };

View File

@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => {
const options = { const options = {
url: url, url: url,
method: 'POST', method: 'POST',
body: JSON.stringify(data) body: data,
}; };
// You may return a promise or a normal data structure from any perform method. // You may return a promise or a normal data structure from any perform method.
@ -90,7 +90,7 @@ module.exports = {
noun: 'Order', noun: 'Order',
display: { display: {
label: 'New Order', label: 'New Order',
description: 'Trigger when a new order with action is done in Dolibarr.' description: 'Triggers when a new order with action is done in Dolibarr.'
}, },
// `operation` is where the business logic goes. // `operation` is where the business logic goes.
@ -101,6 +101,7 @@ module.exports = {
inputFields: [ inputFields: [
{ {
key: 'action', key: 'action',
required: true,
type: 'string', type: 'string',
helpText: 'Which action of order this should trigger on.', helpText: 'Which action of order this should trigger on.',
choices: { choices: {
@ -136,11 +137,11 @@ module.exports = {
// outputFields: () => { return []; } // outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields // Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [ outputFields: [
{key: 'id', label: 'ID'}, {key: 'id', type: "integer", label: 'ID'},
{key: 'createdAt', label: 'Created At'}, {key: 'createdAt', type: "integer", label: 'Created At'},
{key: 'name', label: 'Name'}, {key: 'name', label: 'Name'},
{key: 'directions', label: 'Directions'}, {key: 'directions', label: 'Directions'},
{key: 'authorId', label: 'Author ID'}, {key: 'authorId', type: "integer", label: 'Author ID'},
{key: 'module', label: 'Module'}, {key: 'module', label: 'Module'},
{key: 'action', label: 'Action'} {key: 'action', label: 'Action'}
] ]

View File

@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => {
const options = { const options = {
url: url, url: url,
method: 'POST', method: 'POST',
body: JSON.stringify(data) body: data,
}; };
// You may return a promise or a normal data structure from any perform method. // You may return a promise or a normal data structure from any perform method.
@ -112,7 +112,7 @@ module.exports = {
noun: 'Thirdparty', noun: 'Thirdparty',
display: { display: {
label: 'New Thirdparty', label: 'New Thirdparty',
description: 'Trigger when a new thirdpaty action is done in Dolibarr.' description: 'Triggers when a new thirdpaty action is done in Dolibarr.'
}, },
// `operation` is where the business logic goes. // `operation` is where the business logic goes.
@ -123,6 +123,7 @@ module.exports = {
inputFields: [ inputFields: [
{ {
key: 'action', key: 'action',
required: true,
type: 'string', type: 'string',
helpText: 'Which action of thirdparty this should trigger on.', helpText: 'Which action of thirdparty this should trigger on.',
choices: { choices: {
@ -159,12 +160,12 @@ module.exports = {
// outputFields: () => { return []; } // outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields // Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [ outputFields: [
{key: 'id', label: 'ID'}, {key: 'id', type: "integer", label: 'ID'},
{key: 'createdAt', label: 'Created At'}, {key: 'createdAt', label: 'Created At'},
{key: 'name', label: 'Name'}, {key: 'name', label: 'Name'},
{key: 'name_alias', label: 'Name alias'}, {key: 'name_alias', label: 'Name alias'},
{key: 'firstname', label: 'Firstame'}, {key: 'firstname', label: 'Firstname'},
{key: 'authorId', label: 'Author ID'}, {key: 'authorId', type: "integer", label: 'Author ID'},
{key: 'action', label: 'Action'}, {key: 'action', label: 'Action'},
{key: 'client', label: 'Customer/Prospect 0/1/2/3'}, {key: 'client', label: 'Customer/Prospect 0/1/2/3'},
{key: 'fournisseur', label: 'Supplier 0/1'}, {key: 'fournisseur', label: 'Supplier 0/1'},

View File

@ -0,0 +1,237 @@
const subscribeHook = (z, bundle) => {
// `z.console.log()` is similar to `console.log()`.
z.console.log('suscribing hook!');
// bundle.targetUrl has the Hook URL this app should call when an action is created.
const data = {
url: bundle.targetUrl,
event: bundle.event,
module: 'ticket',
action: bundle.inputData.action
};
const url = bundle.authData.url + '/api/index.php/zapierapi/hook';
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: url,
method: 'POST',
body: data,
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options).then((response) => JSON.parse(response.content));
};
const unsubscribeHook = (z, bundle) => {
// bundle.subscribeData contains the parsed response JSON from the subscribe
// request made initially.
z.console.log('unsuscribing hook!');
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id,
method: 'DELETE',
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options).then((response) => JSON.parse(response.content));
};
const getTicket = (z, bundle) => {
// bundle.cleanedRequest will include the parsed JSON object (if it's not a
// test poll) and also a .querystring property with the URL's query string.
const ticket = {
id: bundle.cleanedRequest.id,
track_id: bundle.cleanedRequest.track_id,
subject: bundle.cleanedRequest.subject,
message: bundle.cleanedRequest.message,
lastname: bundle.cleanedRequest.lastname,
firstname: bundle.cleanedRequest.firstname,
address: bundle.cleanedRequest.address,
zip: bundle.cleanedRequest.zip,
town: bundle.cleanedRequest.town,
email_from: bundle.cleanedRequest.email_from,
login: bundle.cleanedRequest.login,
authorId: bundle.cleanedRequest.authorId,
createdAt: bundle.cleanedRequest.createdAt,
action: bundle.cleanedRequest.action
};
return [ticket];
};
const getFallbackRealTicket = (z, bundle) => {
// For the test poll, you should get some real data, to aid the setup process.
const module = bundle.inputData.module;
const options = {
url: bundle.authData.url + '/api/index.php/tickets/0',
};
return z.request(options).then((response) => [JSON.parse(response.content)]);
};
// const getModulesChoices = (z/*, bundle*/) => {
// // For the test poll, you should get some real data, to aid the setup process.
// const options = {
// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices',
// };
// return z.request(options).then((response) => JSON.parse(response.content));
// };
// const getModulesChoices = () => {
// return {
// orders: "Order",
// invoices: "Invoice",
// thirdparties: "Thirdparty",
// users: "User",
// tickets: "Ticket",
// contacts: "Contacts"
// };
// };
// const getActionsChoices = (z, bundle) => {
// // For the test poll, you should get some real data, to aid the setup process.
// const module = bundle.inputData.module;
// const options = {
// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`,
// };
// return z.request(options).then((response) => JSON.parse(response.content));
// };
// We recommend writing your triggers separate like this and rolling them
// into the App definition at the end.
module.exports = {
key: 'ticket',
// You'll want to provide some helpful display labels and descriptions
// for tickets. Zapier will put them into the UX.
noun: 'Ticket',
display: {
label: 'New Ticket',
description: 'Triggers when a new ticket action is done in Dolibarr.'
},
// `operation` is where the business logic goes.
operation: {
// `inputFields` can define the fields a ticket could provide,
// we'll pass them in as `bundle.inputData` later.
inputFields: [
{
key: 'action',
type: 'string',
required: true,
helpText: 'Which action of ticket this should trigger on.',
choices: {
create: "Create",
modify: "Modify",
validate: "Validate",
}
}
],
type: 'hook',
performSubscribe: subscribeHook,
performUnsubscribe: unsubscribeHook,
perform: getTicket,
performList: getFallbackRealTicket,
// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example
// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of
// returned records, and have obviously dummy values that we can show to any user.
sample: {
id: 1,
track_id: 'Xaz123er',
subject: 'Subject',
message: 'Message',
createdAt: 1472069465,
lastname: 'DOE',
firstname: 'John',
email: 'john@doe.com',
address: 'Park Avenue',
zip: '12345',
town: 'NEW-YORK',
email_from: 'doe.john@example;com',
authorId: 1,
action: 'create'
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [
{
key: 'id',
type: "integer",
label: 'ID'
},
{
key: 'track_id',
type: "string",
label: 'TrackID'
},
{
key: 'subject',
type: "string",
label: 'Subject'
},
{
key: 'message',
type: "string",
label: 'Message'
},
{
key: 'createdAt',
type: "integer",
label: 'Created At'
},
{
key: 'lastname',
label: 'Lastname'
},
{
key: 'firstname',
label: 'Firstname'
},
{
key: 'email',
label: 'Email'
},
{
key: 'address',
label: 'Address'
},
{
key: 'zip',
label: 'Zip'
},
{
key: 'town',
label: 'Town'
},
{
key: 'email_from',
type: 'string',
label: 'Email from'
},
{
key: 'authorId',
type: "integer",
label: 'Author ID'
},
{
key: 'action',
type: 'string',
label: 'Action'
}
]
}
};

View File

@ -0,0 +1,177 @@
const subscribeHook = (z, bundle) => {
// `z.console.log()` is similar to `console.log()`.
z.console.log('suscribing hook!');
// bundle.targetUrl has the Hook URL this app should call when an action is created.
const data = {
url: bundle.targetUrl,
event: bundle.event,
module: 'user',
action: bundle.inputData.action
};
const url = bundle.authData.url + '/api/index.php/zapierapi/hook';
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: url,
method: 'POST',
body: data,
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options).then((response) => JSON.parse(response.content));
};
const unsubscribeHook = (z, bundle) => {
// bundle.subscribeData contains the parsed response JSON from the subscribe
// request made initially.
z.console.log('unsuscribing hook!');
// You can build requests and our client will helpfully inject all the variables
// you need to complete. You can also register middleware to control this.
const options = {
url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id,
method: 'DELETE',
};
// You may return a promise or a normal data structure from any perform method.
return z.request(options).then((response) => JSON.parse(response.content));
};
const getUser = (z, bundle) => {
// bundle.cleanedRequest will include the parsed JSON object (if it's not a
// test poll) and also a .querystring property with the URL's query string.
const user = {
id: bundle.cleanedRequest.id,
lastname: bundle.cleanedRequest.lastname,
firstname: bundle.cleanedRequest.firstname,
address: bundle.cleanedRequest.address,
zip: bundle.cleanedRequest.zip,
town: bundle.cleanedRequest.town,
email: bundle.cleanedRequest.email,
login: bundle.cleanedRequest.login,
authorId: bundle.cleanedRequest.authorId,
createdAt: bundle.cleanedRequest.createdAt,
action: bundle.cleanedRequest.action
};
return [user];
};
const getFallbackRealUser = (z, bundle) => {
// For the test poll, you should get some real data, to aid the setup process.
const module = bundle.inputData.module;
const options = {
url: bundle.authData.url + '/api/index.php/users/0',
};
return z.request(options).then((response) => [JSON.parse(response.content)]);
};
// const getModulesChoices = (z/*, bundle*/) => {
// // For the test poll, you should get some real data, to aid the setup process.
// const options = {
// url: bundle.authData.url + '/api/index.php/zapierapi/getmoduleschoices',
// };
// return z.request(options).then((response) => JSON.parse(response.content));
// };
// const getModulesChoices = () => {
// return {
// orders: "Order",
// invoices: "Invoice",
// thirdparties: "Thirdparty",
// users: "User",
// contacts: "Contacts"
// };
// };
// const getActionsChoices = (z, bundle) => {
// // For the test poll, you should get some real data, to aid the setup process.
// const module = bundle.inputData.module;
// const options = {
// url: url: bundle.authData.url + '/api/index.php/zapierapi/getactionschoices/thirparty`,
// };
// return z.request(options).then((response) => JSON.parse(response.content));
// };
// We recommend writing your triggers separate like this and rolling them
// into the App definition at the end.
module.exports = {
key: 'user',
// You'll want to provide some helpful display labels and descriptions
// for users. Zapier will put them into the UX.
noun: 'User',
display: {
label: 'New User',
description: 'Triggers when a new user action is done in Dolibarr.'
},
// `operation` is where the business logic goes.
operation: {
// `inputFields` can define the fields a user could provide,
// we'll pass them in as `bundle.inputData` later.
inputFields: [
{
key: 'action',
required: true,
type: 'string',
helpText: 'Which action of user this should trigger on.',
choices: {
create: "Create",
modify: "Modify",
validate: "Validate",
}
}
],
type: 'hook',
performSubscribe: subscribeHook,
performUnsubscribe: unsubscribeHook,
perform: getUser,
performList: getFallbackRealUser,
// In cases where Zapier needs to show an example record to the user, but we are unable to get a live example
// from the API, Zapier will fallback to this hard-coded sample. It should reflect the data structure of
// returned records, and have obviously dummy values that we can show to any user.
sample: {
id: 1,
createdAt: 1472069465,
lastname: 'DOE',
firstname: 'John',
email: 'john@doe.com',
address: 'Park Avenue',
zip: '12345',
town: 'NEW-YORK',
login: 'doe.john',
authorId: 1,
action: 'create'
},
// If the resource can have fields that are custom on a per-user basis, define a function to fetch the custom
// field definitions. The result will be used to augment the sample.
// outputFields: () => { return []; }
// Alternatively, a static field definition should be provided, to specify labels for the fields
outputFields: [
{key: 'id', type: "integer", label: 'ID'},
{key: 'createdAt', type: "integer", label: 'Created At'},
{key: 'lastname', label: 'Lastname'},
{key: 'firstname', label: 'Firstname'},
{key: 'email', label: 'Email'},
{key: 'address', label: 'Address'},
{key: 'zip', label: 'Zip'},
{key: 'town', label: 'Town'},
{key: 'login', label: 'Login'},
{key: 'authorId', type: "integer", label: 'Author ID'},
{key: 'action', label: 'Action'}
]
}
};

View File

@ -1,28 +1,29 @@
README (deutsch / german / allemand) README (deutsch / german / allemand)
-------------------------------- ------------------------------------
-------------------------------- ------------------------------------
Download / Herunterladen Download / Herunterladen
-------------------------------- ------------------------------------
* Dolibarr ERP/CRM kann man über die offizielle Dolibarr Website * Dolibarr ERP/CRM kann man über die offizielle Dolibarr Website
https://www.dolibarr.org/downloads https://www.dolibarr.org/downloads
oder direkt von Sourceforge
oder direkt bei Sourceforge
https://sourceforge.net/projects/dolibarr/files/ https://sourceforge.net/projects/dolibarr/files/
herunterladen. herunterladen.
* Die meisten externen Module/Themens sind über den DoliStore verfügbar:
https://www.dolistore.com/de/
------------------------------------
Installation / Hilfe
------------------------------------
-------------------------------- * Für eine kurze Einleitung schau in die README Datei im Hauptverzeichnis.
Installation
--------------------------------
* Für eine kurze Einleitung, schau auf die README Datei im Hauptverzeichnis.
* Umfangreiche Dokumentationen sind im Dolibarr Wiki zu finden: * Umfangreiche Dokumentationen sind im Dolibarr Wiki zu finden:
https://wiki.dolibarr.org/index.php/Hauptseite https://wiki.dolibarr.org/index.php/Hauptseite
@ -31,3 +32,14 @@ Installation
https://www.dolibarr.de/ https://www.dolibarr.de/
------------------------------------
Zusatzmodule
------------------------------------
* Die meisten externen Module/Themen sind über den offiziellen DoliStore verfügbar:
https://www.dolistore.com/de/

View File

@ -65,12 +65,12 @@ if (!$sortfield) $sortfield = "aa.account_number";
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) $sortorder = "ASC";
$arrayfields = array( $arrayfields = array(
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1), 'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1), 'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1), 'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1), 'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'), 'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1), 'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1) 'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
); );
@ -93,24 +93,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
if (!empty($cancel)) $action = ''; if (!empty($cancel)) $action = '';
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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 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_account = ""; $search_account = "";
$search_label = ""; $search_label = "";
$search_labelshort = ""; $search_labelshort = "";
$search_accountparent = ""; $search_accountparent = "";
$search_pcgtype = ""; $search_pcgtype = "";
$search_array_options = array(); $search_array_options = array();
} }
if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
|| (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified
{ {
if ($chartofaccounts > 0) if ($chartofaccounts > 0)
{ {
// Get language code for this $chartofaccounts // Get language code for this $chartofaccounts
$sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a'; $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
$sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts; $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
@ -147,34 +147,34 @@ if (empty($reshook))
} }
} }
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} else { } else {
$error++; $error++;
} }
} }
if ($action == 'disable') { if ($action == 'disable') {
if ($accounting->fetch($id)) { if ($accounting->fetch($id)) {
$mode = GETPOST('mode', 'int'); $mode = GETPOST('mode', 'int');
$result = $accounting->accountDeactivate($id, $mode); $result = $accounting->accountDeactivate($id, $mode);
} }
$action = 'update'; $action = 'update';
if ($result < 0) { if ($result < 0) {
setEventMessages($accounting->error, $accounting->errors, 'errors'); setEventMessages($accounting->error, $accounting->errors, 'errors');
} }
} elseif ($action == 'enable') { } elseif ($action == 'enable') {
if ($accounting->fetch($id)) { if ($accounting->fetch($id)) {
$mode = GETPOST('mode', 'int'); $mode = GETPOST('mode', 'int');
$result = $accounting->account_activate($id, $mode); $result = $accounting->account_activate($id, $mode);
} }
$action = 'update'; $action = 'update';
if ($result < 0) { if ($result < 0) {
setEventMessages($accounting->error, $accounting->errors, 'errors'); setEventMessages($accounting->error, $accounting->errors, 'errors');
} }
} }
} }
@ -273,9 +273,9 @@ if ($resql)
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
if (!empty($conf->use_javascript_ajax)) if (!empty($conf->use_javascript_ajax))
{ {
print '<!-- Add javascript to reload page when we click "Change plan" --> print '<!-- Add javascript to reload page when we click "Change plan" -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$("#change_chart").on("click", function (e) { $("#change_chart").on("click", function (e) {
@ -285,7 +285,7 @@ if ($resql)
}); });
}); });
</script>'; </script>';
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@ -296,48 +296,48 @@ if ($resql)
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
$newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
// Box to select active chart of account // Box to select active chart of account
print $langs->trans("Selectchartofaccounts")." : "; print $langs->trans("Selectchartofaccounts")." : ";
print '<select class="flat" name="chartofaccounts" id="chartofaccounts">'; print '<select class="flat" name="chartofaccounts" id="chartofaccounts">';
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code"; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1";
$sql .= " WHERE a.active = 1"; $sql .= " WHERE a.active = 1";
dol_syslog('accountancy/admin/account.php $sql='.$sql); dol_syslog('accountancy/admin/account.php $sql='.$sql);
print $sql; print $sql;
$resqlchart = $db->query($sql); $resqlchart = $db->query($sql);
if ($resqlchart) { if ($resqlchart) {
$numbis = $db->num_rows($resqlchart); $numbis = $db->num_rows($resqlchart);
$i = 0; $i = 0;
while ($i < $numbis) { while ($i < $numbis) {
$obj = $db->fetch_object($resqlchart); $obj = $db->fetch_object($resqlchart);
print '<option value="'.$obj->rowid.'"'; print '<option value="'.$obj->rowid.'"';
print ($pcgver == $obj->rowid) ? ' selected' : ''; print ($pcgver == $obj->rowid) ? ' selected' : '';
print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>'; print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
$i++; $i++;
} }
} else dol_print_error($db); } else dol_print_error($db);
print "</select>"; print "</select>";
print ajax_combobox("chartofaccounts"); print ajax_combobox("chartofaccounts");
print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">'; print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
print '<br>'; print '<br>';
print '<br>'; print '<br>';
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $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); // This also change content of $arrayfields
$moreforfilter = ''; $moreforfilter = '';
$massactionbutton = ''; $massactionbutton = '';
print '<div class="div-table-responsive">'; print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n"; print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Line for search fields // Line for search fields
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
@ -358,7 +358,7 @@ if ($resql)
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder); if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
@ -422,7 +422,7 @@ if ($resql)
print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->'; print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
$accountparent->id = $obj->rowid2; $accountparent->id = $obj->rowid2;
$accountparent->label = $obj->label2; $accountparent->label = $obj->label2;
$accountparent->account_number = $obj->account_number2; // Sotre an account number for output $accountparent->account_number = $obj->account_number2; // Sotre an account number for output
print $accountparent->getNomUrl(1); print $accountparent->getNomUrl(1);
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;

View File

@ -472,13 +472,13 @@ if ($id)
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) {
print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>'; print '<a href="'.$tabhelp[$id][$value].'" target="_blank">'.$valuetoshow.' '.img_help(1, $valuetoshow).'</a>';
} elseif (!empty($tabhelp[$id][$value])) { } elseif (!empty($tabhelp[$id][$value])) {
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
} else { } else {
print $valuetoshow; print $valuetoshow;
} }
print '</td>'; print '</td>';
} }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1; if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;

View File

@ -108,16 +108,16 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} elseif ($res < 0) } elseif ($res < 0)
{ {
$error++; $error++;
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = "create"; $action = "create";
} }
if (!$error) if (!$error)
{ {
setEventMessages("RecordCreatedSuccessfully", null, 'mesgs'); setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1); $urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
header("Location: ".$urltogo); header("Location: ".$urltogo);
exit; exit;
} }
} }
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) { } elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
@ -158,15 +158,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
$result = $object->update($user); $result = $object->update($user);
if ($result > 0) { if ($result > 0) {
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo); header("Location: ".$urltogo);
exit(); exit();
} else { } else {
$mesg = $object->error; $mesg = $object->error;
} }
} else { } else {
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id); $urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
header("Location: ".$urltogo); header("Location: ".$urltogo);
exit(); exit();
} }
} elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) { } elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,8 @@ $action = GETPOST('action', 'aZ09');
$list_account_main = array( $list_account_main = array(
'ACCOUNTING_RESULT_PROFIT', 'ACCOUNTING_RESULT_PROFIT',
'ACCOUNTING_RESULT_LOSS' 'ACCOUNTING_RESULT_LOSS'
); );
/* /*
@ -48,17 +48,17 @@ $list_account_main = array(
*/ */
if ($action == 'update') { if ($action == 'update') {
$error = 0; $error = 0;
$defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha'); $defaultjournal = GETPOST('ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', 'alpha');
if (!empty($defaultjournal)) { if (!empty($defaultjournal)) {
if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} else { } else {
$error++; $error++;
} }
foreach ($list_account_main as $constname) { foreach ($list_account_main as $constname) {
$constvalue = GETPOST($constname, 'alpha'); $constvalue = GETPOST($constname, 'alpha');
@ -99,20 +99,20 @@ print '<input type="hidden" name="action" value="update">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
foreach ($list_account_main as $key) { foreach ($list_account_main as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $langs->trans($key); $label = $langs->trans($key);
$keydesc = $key.'_Desc'; $keydesc = $key.'_Desc';
$htmltext = $langs->trans($keydesc); $htmltext = $langs->trans($keydesc);
print '<td class="fieldrequired" width="50%">'; print '<td class="fieldrequired" width="50%">';
print $form->textwithpicto($label, $htmltext); print $form->textwithpicto($label, $htmltext);
print '</td>'; print '</td>';
// Value // Value
print '<td>'; // Do not force class=right, or it align also the content of the select box print '<td>'; // Do not force class=right, or it align also the content of the select box
print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Journal // Journal

View File

@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09');
// Parameters ACCOUNTING_EXPORT_* // Parameters ACCOUNTING_EXPORT_*
$main_option = array( $main_option = array(
'ACCOUNTING_EXPORT_PREFIX_SPEC', 'ACCOUNTING_EXPORT_PREFIX_SPEC',
); );
$configuration = AccountancyExport::getTypeConfig(); $configuration = AccountancyExport::getTypeConfig();
@ -58,22 +58,22 @@ $listcr = $configuration['cr'];
$model_option = array( $model_option = array(
'1' => array( '1' => array(
'label' => 'ACCOUNTING_EXPORT_FORMAT', 'label' => 'ACCOUNTING_EXPORT_FORMAT',
'param' => $listformat, 'param' => $listformat,
), ),
'2' => array( '2' => array(
'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV', 'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
'param' => '', 'param' => '',
), ),
'3' => array( '3' => array(
'label' => 'ACCOUNTING_EXPORT_ENDLINE', 'label' => 'ACCOUNTING_EXPORT_ENDLINE',
'param' => $listcr, 'param' => $listcr,
), ),
'4' => array( '4' => array(
'label' => 'ACCOUNTING_EXPORT_DATE', 'label' => 'ACCOUNTING_EXPORT_DATE',
'param' => '', 'param' => '',
), ),
); );
@ -105,22 +105,22 @@ if ($action == 'update') {
} }
} }
foreach ($listparam[$modelcsv] as $key => $value) { foreach ($listparam[$modelcsv] as $key => $value) {
$constante = $key; $constante = $key;
if (strpos($constante, 'ACCOUNTING') !== false) { if (strpos($constante, 'ACCOUNTING') !== false) {
$constvalue = GETPOST($key, 'alpha'); $constvalue = GETPOST($key, 'alpha');
if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) { if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++; $error++;
} }
} }
} }
if (!$error) { if (!$error) {
// reload // reload
$configuration = AccountancyExport::getTypeConfig(); $configuration = AccountancyExport::getTypeConfig();
$listparam = $configuration['param']; $listparam = $configuration['param'];
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
@ -148,36 +148,36 @@ print 'jQuery(document).ready(function () {'."\n";
print ' function initfields()'."\n"; print ' function initfields()'."\n";
print ' {'."\n"; print ' {'."\n";
foreach ($listparam as $key => $param) { foreach ($listparam as $key => $param) {
print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n"; print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
print ' {'."\n"; print ' {'."\n";
print ' //console.log("'.$param['label'].'");'."\n"; print ' //console.log("'.$param['label'].'");'."\n";
if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) { if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
} else { } else {
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
} }
if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) { if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
} else { } else {
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
} }
if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) { if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
} else { } else {
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
} }
if (empty($param['ACCOUNTING_EXPORT_DATE'])) { if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
} else { } else {
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n";
print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n"; print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
} }
print ' }'."\n"; print ' }'."\n";
} }
print ' }'."\n"; print ' }'."\n";
print ' initfields();'."\n"; print ' initfields();'."\n";
@ -262,17 +262,17 @@ if ($num2) {
foreach ($model_option as $key) { foreach ($model_option as $key) {
print '<tr class="oddeven value">'; print '<tr class="oddeven value">';
// Param // Param
$label = $key['label']; $label = $key['label'];
print '<td width="50%">'.$langs->trans($label).'</td>'; print '<td width="50%">'.$langs->trans($label).'</td>';
// Value // Value
print '<td>'; print '<td>';
if (is_array($key['param'])) { if (is_array($key['param'])) {
print $form->selectarray($label, $key['param'], $conf->global->$label, 0); print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
} else { } else {
print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">'; print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
} }
print '</td></tr>'; print '</td></tr>';
} }

View File

@ -113,7 +113,7 @@ if ($result)
$i = 0; $i = 0;
$addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write); $addbutton .= dolGetButtonTitle($langs->trans('NewFiscalYear'), '', 'fa fa-plus-circle', 'fiscalyear_card.php?action=create', '', $user->rights->accounting->fiscalyear->write);
$title = $langs->trans('AccountingPeriods'); $title = $langs->trans('AccountingPeriods');

View File

@ -420,15 +420,15 @@ if ($id)
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
$class = "left"; $class = "left";
if ($fieldlist[$field] == 'code') { if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code"); $valuetoshow = $langs->trans("Code");
} }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label"); $valuetoshow = $langs->trans("Label");
} }
if ($fieldlist[$field] == 'nature') { if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal"); $valuetoshow = $langs->trans("NatureOfJournal");
} }
if ($valuetoshow != '') { if ($valuetoshow != '') {
print '<td class="'.$class.'">'; print '<td class="'.$class.'">';
@ -540,14 +540,14 @@ if ($id)
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut $valuetoshow = ucfirst($fieldlist[$field]); // By defaut
$valuetoshow = $langs->trans($valuetoshow); // try to translate $valuetoshow = $langs->trans($valuetoshow); // try to translate
if ($fieldlist[$field] == 'code') { if ($fieldlist[$field] == 'code') {
$valuetoshow = $langs->trans("Code"); $valuetoshow = $langs->trans("Code");
} }
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') { if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
$valuetoshow = $langs->trans("Label"); $valuetoshow = $langs->trans("Label");
} }
if ($fieldlist[$field] == 'nature') { if ($fieldlist[$field] == 'nature') {
$valuetoshow = $langs->trans("NatureOfJournal"); $valuetoshow = $langs->trans("NatureOfJournal");
} }
// Affiche nom du champ // Affiche nom du champ
if ($showfield) { if ($showfield) {
@ -594,7 +594,7 @@ if ($id)
if (empty($reshook)) if (empty($reshook))
{ {
$langs->load("accountancy"); $langs->load("accountancy");
foreach ($fieldlist as $field => $value) foreach ($fieldlist as $field => $value)
{ {
$showfield = 1; $showfield = 1;
@ -607,7 +607,7 @@ if ($id)
$valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]}); $valuetoshow = ($obj->nature && $key != "AccountingJournalType".strtoupper($langs->trans($obj->nature)) ? $key : $obj->{$fieldlist[$field]});
} elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') { } elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'accounting_journal') {
$valuetoshow = $langs->trans($obj->label); $valuetoshow = $langs->trans($obj->label);
} }
$class = 'tddict'; $class = 'tddict';
// Show value for field // Show value for field
@ -619,15 +619,15 @@ if ($id)
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default $iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
if (isset($obj->code) && $id != 10) { if (isset($obj->code) && $id != 10) {
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) { if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
$iserasable = 0; $iserasable = 0;
$canbedisabled = 0; $canbedisabled = 0;
} elseif ($obj->code == 'RECEP') { } elseif ($obj->code == 'RECEP') {
$iserasable = 0; $iserasable = 0;
$canbedisabled = 0; $canbedisabled = 0;
} elseif ($obj->code == 'EF0') { } elseif ($obj->code == 'EF0') {
$iserasable = 0; $iserasable = 0;
$canbedisabled = 0; $canbedisabled = 0;
} }
} }
$canbemodified = $iserasable; $canbemodified = $iserasable;

View File

@ -42,7 +42,7 @@ if (empty($conf->accounting->enabled)) {
accessforbidden(); accessforbidden();
} }
if (!$user->rights->accounting->bind->write) if (!$user->rights->accounting->bind->write)
accessforbidden(); accessforbidden();
// search & action GETPOST // search & action GETPOST
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -100,14 +100,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
// Purge search criteria // Purge search criteria
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 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_ref = ''; $search_ref = '';
$search_label = ''; $search_label = '';
$search_desc = ''; $search_desc = '';
$search_vat = ''; $search_vat = '';
$search_onsell = ''; $search_onsell = '';
$search_onpurchase = ''; $search_onpurchase = '';
$search_current_account = ''; $search_current_account = '';
$search_current_account_valid = '-1'; $search_current_account_valid = '-1';
} }
// Sales or Purchase mode ? // Sales or Purchase mode ?
@ -117,8 +117,8 @@ if ($action == 'update') {
$accounting_product_modes = array( $accounting_product_modes = array(
'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL',
'ACCOUNTANCY_SELL_INTRA', 'ACCOUNTANCY_SELL_INTRA',
'ACCOUNTANCY_SELL_EXPORT', 'ACCOUNTANCY_SELL_EXPORT',
'ACCOUNTANCY_BUY', 'ACCOUNTANCY_BUY',
'ACCOUNTANCY_BUY_INTRA', 'ACCOUNTANCY_BUY_INTRA',
'ACCOUNTANCY_BUY_EXPORT' 'ACCOUNTANCY_BUY_EXPORT'
@ -172,22 +172,22 @@ if ($action == 'update') {
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
$sql .= " SET accountancy_code_sell = ".$accounting->account_number; $sql .= " SET accountancy_code_sell = ".$accounting->account_number;
} }
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number; $sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
} }
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number; $sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
} }
$sql .= " WHERE rowid = ".((int) $productid); $sql .= " WHERE rowid = ".((int) $productid);
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
if ($db->query($sql)) if ($db->query($sql))
{ {
$ok++; $ok++;
$db->commit(); $db->commit();
} else { } else {
$ko++; $ko++;
$db->rollback(); $db->rollback();
} }
} }
@ -253,7 +253,7 @@ $sql .= " aa.rowid as aaid";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p"; $sql .= " FROM ".MAIN_DB_PREFIX."product as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
{ {
$sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'"; $sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
@ -271,9 +271,9 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
} }
$sql .= ' WHERE p.entity IN ('.getEntity('product').')'; $sql .= ' WHERE p.entity IN ('.getEntity('product').')';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_buy", $search_current_account); $sql .= natural_search("p.accountancy_code_buy", $search_current_account);
} }
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account);
@ -283,17 +283,17 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
$sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account);
} }
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell", $search_current_account); $sql .= natural_search("p.accountancy_code_sell", $search_current_account);
} }
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account); $sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
} }
} else { } else {
if (strlen(trim($search_current_account))) { if (strlen(trim($search_current_account))) {
$sql .= natural_search("p.accountancy_code_sell_export", $search_current_account); $sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
} }
} }
if ($search_current_account_valid == 'withoutvalidaccount') if ($search_current_account_valid == 'withoutvalidaccount')
{ {
@ -301,7 +301,7 @@ if ($search_current_account_valid == 'withoutvalidaccount')
} }
if ($search_current_account_valid == 'withvalidaccount') if ($search_current_account_valid == 'withvalidaccount')
{ {
$sql .= " AND aa.account_number IS NOT NULL"; $sql .= " AND aa.account_number IS NOT NULL";
} }
// Add search filter like // Add search filter like
if (strlen(trim($search_ref))) { if (strlen(trim($search_ref))) {
@ -324,13 +324,13 @@ $sql .= $db->order($sortfield, $sortorder);
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($result);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -342,32 +342,32 @@ if ($result)
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref); if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label); if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc); if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat); if ($search_vat > 0) $param .= '&search_vat='.urlencode($search_vat);
if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account); if ($search_current_account > 0) $param .= "&search_current_account=".urlencode($search_current_account);
if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid); if ($search_current_account_valid && $search_current_account_valid != '-1') $param .= "&search_current_account_valid=".urlencode($search_current_account_valid);
if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode); if ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy'); print load_fiche_titre($langs->trans("ProductsBinding"), '', 'title_accountancy');
print '<br>'; print '<br>';
print '<span class="opacitymedium">'.$langs->trans("InitAccountancyDesc").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("InitAccountancyDesc").'</span><br>';
print '<br>'; print '<br>';
// Select mode // Select mode
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Options').'</td><td>'.$langs->trans('Description').'</td>'; print '<td>'.$langs->trans('Options').'</td><td>'.$langs->trans('Description').'</td>';
@ -377,13 +377,13 @@ if ($result)
print "</td></tr>\n"; print "</td></tr>\n";
if ($mysoc->isInEEC()) if ($mysoc->isInEEC())
{ {
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellIntra').'</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellIntra').'</td>';
print '<td>'.$langs->trans('OptionModeProductSellIntraDesc'); print '<td>'.$langs->trans('OptionModeProductSellIntraDesc');
print "</td></tr>\n"; print "</td></tr>\n";
} }
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellExport').'</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSellExport').'</td>';
print '<td>'.$langs->trans('OptionModeProductSellExportDesc'); print '<td>'.$langs->trans('OptionModeProductSellExportDesc');
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"'.($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuy').'</td>'; print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY"'.($accounting_product_mode == 'ACCOUNTANCY_BUY' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuy').'</td>';
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n"; print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
if ($mysoc->isInEEC()) if ($mysoc->isInEEC())
@ -405,8 +405,8 @@ if ($result)
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $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); // This also change content of $arrayfields
$buttonsave = '<input type="submit" class="button" id="changeaccount" name="changeaccount" value="'.$langs->trans("Save").'">'; $buttonsave = '<input type="submit" class="button" id="changeaccount" name="changeaccount" value="'.$langs->trans("Save").'">';
//print '<br><div class="center">'.$buttonsave.'</div>'; //print '<br><div class="center">'.$buttonsave.'</div>';
$texte = $langs->trans("ListOfProductsServices"); $texte = $langs->trans("ListOfProductsServices");
print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $buttonsave, $num, $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
@ -444,22 +444,22 @@ if ($result)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder);
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder);
print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "p.tva_tx", "", $param, '', $sortfield, $sortorder, 'right ');
// On sell / On purchase // On sell / On purchase
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_sell"; $fieldtosortaccount = "p.accountancy_code_sell";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_sell_intra"; $fieldtosortaccount = "p.accountancy_code_sell_intra";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_sell_export"; $fieldtosortaccount = "p.accountancy_code_sell_export";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_buy"; $fieldtosortaccount = "p.accountancy_code_buy";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
$fieldtosortaccount = "p.accountancy_code_buy_intra"; $fieldtosortaccount = "p.accountancy_code_buy_intra";
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
@ -475,8 +475,8 @@ if ($result)
$product_static = new Product($db); $product_static = new Product($db);
$i = 0; $i = 0;
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
// Ref produit as link // Ref produit as link
@ -494,12 +494,12 @@ if ($result)
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell; $compta_prodsell_id = $aarowid_prodsell;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_intra; $compta_prodsell_id = $aarowid_prodsell_intra;
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell_export; $compta_prodsell_id = $aarowid_prodsell_export;
} else { } else {
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
$compta_prodsell_id = $aarowid_prodsell; $compta_prodsell_id = $aarowid_prodsell;
} }
@ -560,11 +560,11 @@ if ($result)
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
{ {
// TODO ADJUST DESCRIPTION SIZE // TODO ADJUST DESCRIPTION SIZE
// print '<td class="left">' . $obj->description . '</td>'; // print '<td class="left">' . $obj->description . '</td>';
// TODO: we should set a user defined value to adjust user square / wide screen size // TODO: we should set a user defined value to adjust user square / wide screen size
$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION; $trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>'; print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>';
} }
// VAT // VAT
@ -581,36 +581,36 @@ if ($result)
// Current accounting account // Current accounting account
print '<td class="left">'; print '<td class="left">';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
print length_accountg($obj->accountancy_code_buy); print length_accountg($obj->accountancy_code_buy);
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
print length_accountg($obj->accountancy_code_buy_intra); print length_accountg($obj->accountancy_code_buy_intra);
if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
print length_accountg($obj->accountancy_code_buy_export); print length_accountg($obj->accountancy_code_buy_export);
if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_buy_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
print length_accountg($obj->accountancy_code_sell); print length_accountg($obj->accountancy_code_sell);
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
print length_accountg($obj->accountancy_code_sell_intra); print length_accountg($obj->accountancy_code_sell_intra);
if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} else { } else {
print length_accountg($obj->accountancy_code_sell_export); print length_accountg($obj->accountancy_code_sell_export);
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
} }
print '</td>'; print '</td>';
// New account to set // New account to set
$defaultvalue = ''; $defaultvalue = '';
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
// Accounting account buy // Accounting account buy
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy; if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
$codesell = length_accountg($obj->accountancy_code_buy); $codesell = length_accountg($obj->accountancy_code_buy);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
// Accounting account buy intra (In EEC) // Accounting account buy intra (In EEC)
@ -620,7 +620,7 @@ if ($result)
$codesell = length_accountg($obj->accountancy_code_buy_intra); $codesell = length_accountg($obj->accountancy_code_buy_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
// Accounting account buy export (Out of EEC) // Accounting account buy export (Out of EEC)
@ -630,7 +630,7 @@ if ($result)
$codesell = length_accountg($obj->accountancy_code_buy_export); $codesell = length_accountg($obj->accountancy_code_buy_export);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
// Accounting account sell // Accounting account sell
@ -640,32 +640,32 @@ if ($result)
$codesell = length_accountg($obj->accountancy_code_sell); $codesell = length_accountg($obj->accountancy_code_sell);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') { } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
// Accounting account sell intra (In EEC) // Accounting account sell intra (In EEC)
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
$codesell = length_accountg($obj->accountancy_code_sell_intra); $codesell = length_accountg($obj->accountancy_code_sell_intra);
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} else { } else {
// Accounting account sell export (Out of EEC) // Accounting account sell export (Out of EEC)
print '<td class="left">'; print '<td class="left">';
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell; if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
$codesell = length_accountg($obj->accountancy_code_sell_export); $codesell = length_accountg($obj->accountancy_code_sell_export);
if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid if (!empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid
print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1); print $form->select_account($defaultvalue, 'codeventil_'.$product_static->id, 1, array(), 1, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
print '</td>'; print '</td>';
} }
// Checkbox select // Checkbox select
print '<td class="center">'; print '<td class="center">';
print '<input type="checkbox" class="checkforselect" name="chk_prod[]" value="'.$obj->rowid.'"/></td>'; print '<input type="checkbox" class="checkforselect productforselectcodeventil_'.$product_static->id.'" name="chk_prod[]" value="'.$obj->rowid.'"/></td>';
print "</tr>"; print "</tr>";
$i++; $i++;
} }
@ -689,7 +689,17 @@ if ($result)
if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\'); if (atleastoneselected) jQuery("#changeaccount").attr(\'class\',\'button\');
else jQuery("#changeaccount").attr(\'class\',\'button\'); else jQuery("#changeaccount").attr(\'class\',\'button\');
} }
jQuery(".checkforselect, #checkallactions").click(function() {
jQuery(".checkforselect").change(function() {
init_savebutton();
});
jQuery(".productforselect").change(function() {
console.log($(this).attr("id")+" "+$(this).val());
if ($(this).val() && $(this).val() != -1) {
$(".productforselect"+$(this).attr("id")).prop(\'checked\', true);
} else {
$(".productforselect"+$(this).attr("id")).prop(\'checked\', false);
}
init_savebutton(); init_savebutton();
}); });

View File

@ -105,7 +105,7 @@ $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
llxHeader('', $title); llxHeader('', $title);
// Customer // Customer
$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '0' as type, sa.entity"; $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"; $sql .= " FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta <> ''"; $sql .= " AND sa.code_compta <> ''";
@ -148,7 +148,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db
// Supplier // Supplier
$sql .= " UNION "; $sql .= " UNION ";
$sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '1' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa"; $sql .= " SELECT sa.rowid, sa.nom as label, sa.code_compta_fournisseur as subaccount, '2' as type, sa.entity FROM ".MAIN_DB_PREFIX."societe sa";
$sql .= " WHERE sa.entity IN (".getEntity('societe').")"; $sql .= " WHERE sa.entity IN (".getEntity('societe').")";
$sql .= " AND sa.code_compta_fournisseur <> ''"; $sql .= " AND sa.code_compta_fournisseur <> ''";
//print $sql; //print $sql;
@ -190,7 +190,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db
// User // User
$sql .= " UNION "; $sql .= " UNION ";
$sql .= " SELECT u.rowid, u.lastname as label, u.accountancy_code as subaccount, '2' as type, u.entity FROM ".MAIN_DB_PREFIX."user u"; $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').")"; $sql .= " WHERE u.entity IN (".getEntity('user').")";
$sql .= " AND u.accountancy_code <> ''"; $sql .= " AND u.accountancy_code <> ''";
//print $sql; //print $sql;
@ -287,7 +287,7 @@ if ($resql)
print '<tr class="liste_titre_filter">'; print '<tr class="liste_titre_filter">';
if (!empty($arrayfields['subaccount']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>'; if (!empty($arrayfields['subaccount']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_subaccount" value="'.$search_subaccount.'"></td>';
if (!empty($arrayfields['label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>'; if (!empty($arrayfields['label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_label" value="'.$search_label.'"></td>';
if (!empty($arrayfields['type']['checked'])) print '<td class="liste_titre center">'.$form->selectarray('search_type', array('0'=>$langs->trans('Customer'), '1'=>$langs->trans('Supplier'), '2'=>$langs->trans('Employee')), $search_type, 1).'</td>'; if (!empty($arrayfields['type']['checked'])) print '<td class="liste_titre center">'.$form->selectarray('search_type', array('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
print '<td class="liste_titre maxwidthsearch">'; print '<td class="liste_titre maxwidthsearch">';
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
@ -335,17 +335,17 @@ if ($resql)
print '<td class="center">'; print '<td class="center">';
$s = ''; $s = '';
// Customer // Customer
if ($obj->type == 0) if ($obj->type == 1)
{ {
$s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>'; $s .= '<a class="customer-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->rowid.'">'.$langs->trans("Customer").'</a>';
} }
// Supplier // Supplier
elseif ($obj->type == 1) elseif ($obj->type == 2)
{ {
$s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>'; $s .= '<a class="vendor-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->rowid.'">'.$langs->trans("Supplier").'</a>';
} }
// User // User
elseif ($obj->type == 2) elseif ($obj->type == 3)
{ {
$s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->id.'">'.$langs->trans("Employee").'</a>'; $s .= '<a class="user-back" style="padding-left: 6px; padding-right: 6px" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?id='.$obj->id.'">'.$langs->trans("Employee").'</a>';
} }
@ -378,17 +378,17 @@ if ($resql)
print '<td class="center">'; print '<td class="center">';
$e = ''; $e = '';
// Customer // Customer
if ($obj->type == 0) if ($obj->type == 1)
{ {
$e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Customer").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} }
// Supplier // Supplier
elseif ($obj->type == 1) elseif ($obj->type == 2)
{ {
$e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Supplier").'" href="'.DOL_URL_ROOT.'/societe/card.php?action=edit&socid='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} }
// User // User
elseif ($obj->type == 2) elseif ($obj->type == 3)
{ {
$e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>'; $e .= '<a class="editfielda" title="'.$langs->trans("Employee").'" href="'.DOL_URL_ROOT.'/user/card.php?action=edit&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().'</a>';
} }

View File

@ -274,11 +274,11 @@ if ($action != 'export_csv')
$sous_total_credit = 0; $sous_total_credit = 0;
$displayed_account = ""; $displayed_account = "";
$accountingaccountstatic = new AccountingAccount($db); $accountingaccountstatic = new AccountingAccount($db);
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance"; $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as t";
$sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features $sql .= " WHERE t.entity = ".$conf->entity; // Never do sharing into accounting features
$sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'"; $sql .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
$sql .= " GROUP BY t.numero_compte"; $sql .= " GROUP BY t.numero_compte";
@ -292,12 +292,12 @@ if ($action != 'export_csv')
foreach ($object->lines as $line) foreach ($object->lines as $line)
{ {
$accountingaccountstatic->fetch(null, $line->numero_compte, true); $accountingaccountstatic->fetch(null, $line->numero_compte, true);
if (!empty($accountingaccountstatic->account_number)) { if (!empty($accountingaccountstatic->account_number)) {
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1); $accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
} else { } else {
$accounting_account = length_accountg($line->numero_compte); $accounting_account = length_accountg($line->numero_compte);
} }
$link = ''; $link = '';
$total_debit += $line->debit; $total_debit += $line->debit;

View File

@ -114,12 +114,12 @@ if ($action == "confirm_update") {
$object->credit = $credit; $object->credit = $credit;
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$object->montant = $debit; // deprecated $object->montant = $debit; // deprecated
$object->amount = $debit; $object->amount = $debit;
$object->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$object->montant = $credit; // deprecated $object->montant = $credit; // deprecated
$object->amount = $credit; $object->amount = $credit;
$object->sens = 'C'; $object->sens = 'C';
} }
@ -175,13 +175,13 @@ if ($action == "confirm_update") {
$object->fk_docdet = (int) GETPOST('fk_docdet', 'int'); $object->fk_docdet = (int) GETPOST('fk_docdet', 'int');
if (floatval($debit) != 0.0) { if (floatval($debit) != 0.0) {
$object->montant = $debit; // deprecated $object->montant = $debit; // deprecated
$object->amount = $debit; $object->amount = $debit;
$object->sens = 'D'; $object->sens = 'D';
} }
if (floatval($credit) != 0.0) { if (floatval($credit) != 0.0) {
$object->montant = $credit; // deprecated $object->montant = $credit; // deprecated
$object->amount = $credit; $object->amount = $credit;
$object->sens = 'C'; $object->sens = 'C';
} }
@ -245,7 +245,7 @@ if ($action == "confirm_update") {
$object->journal_label = $journal_label; $object->journal_label = $journal_label;
$object->fk_doc = 0; $object->fk_doc = 0;
$object->fk_docdet = 0; $object->fk_docdet = 0;
$object->montant = 0; // deprecated $object->montant = 0; // deprecated
$object->amount = 0; $object->amount = 0;
$result = $object->createStd($user, 0, $mode); $result = $object->createStd($user, 0, $mode);

View File

@ -151,7 +151,7 @@ $arrayfields = array(
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1), 't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0), 't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0), 't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1), 't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
); );
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']); if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
@ -176,145 +176,145 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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 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_mvt_num = ''; $search_mvt_num = '';
$search_doc_type = ''; $search_doc_type = '';
$search_doc_ref = ''; $search_doc_ref = '';
$search_doc_date = ''; $search_doc_date = '';
$search_accountancy_code = ''; $search_accountancy_code = '';
$search_accountancy_code_start = ''; $search_accountancy_code_start = '';
$search_accountancy_code_end = ''; $search_accountancy_code_end = '';
$search_accountancy_aux_code = ''; $search_accountancy_aux_code = '';
$search_accountancy_aux_code_start = ''; $search_accountancy_aux_code_start = '';
$search_accountancy_aux_code_end = ''; $search_accountancy_aux_code_end = '';
$search_mvt_label = ''; $search_mvt_label = '';
$search_direction = ''; $search_direction = '';
$search_ledger_code = ''; $search_ledger_code = '';
$search_date_start = ''; $search_date_start = '';
$search_date_end = ''; $search_date_end = '';
$search_date_creation_start = ''; $search_date_creation_start = '';
$search_date_creation_end = ''; $search_date_creation_end = '';
$search_date_modification_start = ''; $search_date_modification_start = '';
$search_date_modification_end = ''; $search_date_modification_end = '';
$search_date_export_start = ''; $search_date_export_start = '';
$search_date_export_end = ''; $search_date_export_end = '';
$search_debit = ''; $search_debit = '';
$search_credit = ''; $search_credit = '';
$search_lettering_code = ''; $search_lettering_code = '';
$search_not_reconciled = ''; $search_not_reconciled = '';
} }
// Must be after the remove filter action, before the export. // Must be after the remove filter action, before the export.
$param = ''; $param = '';
$filter = array(); $filter = array();
if (!empty($search_date_start)) { if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start; $filter['t.doc_date>='] = $search_date_start;
$tmp = dol_getdate($search_date_start); $tmp = dol_getdate($search_date_start);
$param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']); $param .= '&search_date_startmonth='.urlencode($tmp['mon']).'&search_date_startday='.urlencode($tmp['mday']).'&search_date_startyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_end)) { if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end; $filter['t.doc_date<='] = $search_date_end;
$tmp = dol_getdate($search_date_end); $tmp = dol_getdate($search_date_end);
$param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']); $param .= '&search_date_endmonth='.urlencode($tmp['mon']).'&search_date_endday='.urlencode($tmp['mday']).'&search_date_endyear='.urlencode($tmp['year']);
} }
if (!empty($search_doc_date)) { if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $search_doc_date; $filter['t.doc_date'] = $search_doc_date;
$tmp = dol_getdate($search_doc_date); $tmp = dol_getdate($search_doc_date);
$param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']); $param .= '&doc_datemonth='.urlencode($tmp['mon']).'&doc_dateday='.urlencode($tmp['mday']).'&doc_dateyear='.urlencode($tmp['year']);
} }
if (!empty($search_doc_type)) { if (!empty($search_doc_type)) {
$filter['t.doc_type'] = $search_doc_type; $filter['t.doc_type'] = $search_doc_type;
$param .= '&search_doc_type='.urlencode($search_doc_type); $param .= '&search_doc_type='.urlencode($search_doc_type);
} }
if (!empty($search_doc_ref)) { if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref; $filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref='.urlencode($search_doc_ref); $param .= '&search_doc_ref='.urlencode($search_doc_ref);
} }
if (!empty($search_accountancy_code)) { if (!empty($search_accountancy_code)) {
$filter['t.numero_compte'] = $search_accountancy_code; $filter['t.numero_compte'] = $search_accountancy_code;
$param .= '&search_accountancy_code='.urlencode($search_accountancy_code); $param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
} }
if (!empty($search_accountancy_code_start)) { if (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start; $filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start); $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
} }
if (!empty($search_accountancy_code_end)) { if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end; $filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
} }
if (!empty($search_accountancy_aux_code)) { if (!empty($search_accountancy_aux_code)) {
$filter['t.subledger_account'] = $search_accountancy_aux_code; $filter['t.subledger_account'] = $search_accountancy_aux_code;
$param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
} }
if (!empty($search_accountancy_aux_code_start)) { if (!empty($search_accountancy_aux_code_start)) {
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
$param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start);
} }
if (!empty($search_accountancy_aux_code_end)) { if (!empty($search_accountancy_aux_code_end)) {
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end; $filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
$param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end); $param .= '&search_accountancy_aux_code_end='.urlencode($search_accountancy_aux_code_end);
} }
if (!empty($search_mvt_label)) { if (!empty($search_mvt_label)) {
$filter['t.label_operation'] = $search_mvt_label; $filter['t.label_operation'] = $search_mvt_label;
$param .= '&search_mvt_label='.urlencode($search_mvt_label); $param .= '&search_mvt_label='.urlencode($search_mvt_label);
} }
if (!empty($search_direction)) { if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction; $filter['t.sens'] = $search_direction;
$param .= '&search_direction='.urlencode($search_direction); $param .= '&search_direction='.urlencode($search_direction);
} }
if (!empty($search_ledger_code)) { if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code; $filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code); $param .= '&search_ledger_code='.urlencode($search_ledger_code);
} }
if (!empty($search_mvt_num)) { if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num; $filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num='.urlencode($search_mvt_num); $param .= '&search_mvt_num='.urlencode($search_mvt_num);
} }
if (!empty($search_date_creation_start)) { if (!empty($search_date_creation_start)) {
$filter['t.date_creation>='] = $search_date_creation_start; $filter['t.date_creation>='] = $search_date_creation_start;
$tmp = dol_getdate($search_date_creation_start); $tmp = dol_getdate($search_date_creation_start);
$param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']); $param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_creation_end)) { if (!empty($search_date_creation_end)) {
$filter['t.date_creation<='] = $search_date_creation_end; $filter['t.date_creation<='] = $search_date_creation_end;
$tmp = dol_getdate($search_date_creation_end); $tmp = dol_getdate($search_date_creation_end);
$param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']); $param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_modification_start)) { if (!empty($search_date_modification_start)) {
$filter['t.tms>='] = $search_date_modification_start; $filter['t.tms>='] = $search_date_modification_start;
$tmp = dol_getdate($search_date_modification_start); $tmp = dol_getdate($search_date_modification_start);
$param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']); $param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_modification_end)) { if (!empty($search_date_modification_end)) {
$filter['t.tms<='] = $search_date_modification_end; $filter['t.tms<='] = $search_date_modification_end;
$tmp = dol_getdate($search_date_modification_end); $tmp = dol_getdate($search_date_modification_end);
$param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']); $param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_export_start)) { if (!empty($search_date_export_start)) {
$filter['t.date_export>='] = $search_date_export_start; $filter['t.date_export>='] = $search_date_export_start;
$tmp = dol_getdate($search_date_export_start); $tmp = dol_getdate($search_date_export_start);
$param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']); $param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']);
} }
if (!empty($search_date_export_end)) { if (!empty($search_date_export_end)) {
$filter['t.date_export<='] = $search_date_export_end; $filter['t.date_export<='] = $search_date_export_end;
$tmp = dol_getdate($search_date_export_end); $tmp = dol_getdate($search_date_export_end);
$param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']); $param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']);
} }
if (!empty($search_debit)) { if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit; $filter['t.debit'] = $search_debit;
$param .= '&search_debit='.urlencode($search_debit); $param .= '&search_debit='.urlencode($search_debit);
} }
if (!empty($search_credit)) { if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit; $filter['t.credit'] = $search_credit;
$param .= '&search_credit='.urlencode($search_credit); $param .= '&search_credit='.urlencode($search_credit);
} }
if (!empty($search_lettering_code)) { if (!empty($search_lettering_code)) {
$filter['t.lettering_code'] = $search_lettering_code; $filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code); $param .= '&search_lettering_code='.urlencode($search_lettering_code);
} }
if (!empty($search_not_reconciled)) { if (!empty($search_not_reconciled)) {
$filter['t.reconciled_option'] = $search_not_reconciled; $filter['t.reconciled_option'] = $search_not_reconciled;
$param .= '&search_not_reconciled='.urlencode($search_not_reconciled); $param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
@ -475,48 +475,48 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
{ {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} else { } else {
// Export files // Export files
$accountancyexport = new AccountancyExport($db); $accountancyexport = new AccountancyExport($db);
$accountancyexport->export($object->lines, $formatexportset); $accountancyexport->export($object->lines, $formatexportset);
if (!empty($accountancyexport->errors)) if (!empty($accountancyexport->errors))
{ {
setEventMessages('', $accountancyexport->errors, 'errors'); setEventMessages('', $accountancyexport->errors, 'errors');
} else { } else {
// Specify as export : update field date_export // Specify as export : update field date_export
$error = 0; $error = 0;
$db->begin(); $db->begin();
if (is_array($object->lines)) if (is_array($object->lines))
{ {
foreach ($object->lines as $movement) foreach ($object->lines as $movement)
{ {
$now = dol_now(); $now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping"; $sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_export = '".$db->idate($now)."'"; $sql .= " SET date_export = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id; $sql .= " WHERE rowid = ".$movement->id;
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG); dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if (!$result) if (!$result)
{ {
$error++; $error++;
break; break;
} }
} }
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs'); // setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
} else { } else {
$error++; $error++;
$db->rollback(); $db->rollback();
setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors'); setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
} }
} }
exit; exit;
} }
} }
@ -629,9 +629,9 @@ else $buttonLabel = $langs->trans("ExportList");
// Button re-export // Button re-export
if (!empty($conf->global->ACCOUNTING_REEXPORT)) { if (!empty($conf->global->ACCOUNTING_REEXPORT)) {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> '; $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=0'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Activated"), 'switch_on').'</a> ';
} else { } else {
$newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> '; $newcardbutton = '<a class="valignmiddle" href="'.$_SERVER['PHP_SELF'].'?action=setreexport&token='.newToken().'&value=1'.($param ? '&'.$param : '').'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a> ';
} }
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>'; $newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
@ -791,14 +791,14 @@ if (!empty($arrayfields['t.tms']['checked']))
// Date export // Date export
if (!empty($arrayfields['t.date_export']['checked'])) if (!empty($arrayfields['t.date_export']['checked']))
{ {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} }
// Action column // Action column
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
@ -854,7 +854,7 @@ while ($i < min($num, $limit))
$line->label_operation = $obj->label_operation; $line->label_operation = $obj->label_operation;
$line->debit = $obj->debit; $line->debit = $obj->debit;
$line->credit = $obj->credit; $line->credit = $obj->credit;
$line->montant = $obj->amount; // deprecated $line->montant = $obj->amount; // deprecated
$line->amount = $obj->amount; $line->amount = $obj->amount;
$line->sens = $obj->sens; $line->sens = $obj->sens;
$line->lettering_code = $obj->lettering_code; $line->lettering_code = $obj->lettering_code;
@ -893,65 +893,65 @@ while ($i < min($num, $limit))
// Document ref // Document ref
if (!empty($arrayfields['t.doc_ref']['checked'])) if (!empty($arrayfields['t.doc_ref']['checked']))
{ {
if ($line->doc_type == 'customer_invoice') if ($line->doc_type == 'customer_invoice')
{ {
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$objectstatic = new Facture($db); $objectstatic = new Facture($db);
$objectstatic->fetch($line->fk_doc); $objectstatic->fetch($line->fk_doc);
//$modulepart = 'facture'; //$modulepart = 'facture';
$filename = dol_sanitizeFileName($line->doc_ref); $filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice') } elseif ($line->doc_type == 'supplier_invoice')
{ {
$langs->loadLangs(array('bills')); $langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$objectstatic = new FactureFournisseur($db); $objectstatic = new FactureFournisseur($db);
$objectstatic->fetch($line->fk_doc); $objectstatic->fetch($line->fk_doc);
//$modulepart = 'invoice_supplier'; //$modulepart = 'invoice_supplier';
$filename = dol_sanitizeFileName($line->doc_ref); $filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref); $subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report') } elseif ($line->doc_type == 'expense_report')
{ {
$langs->loadLangs(array('trips')); $langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$objectstatic = new ExpenseReport($db); $objectstatic = new ExpenseReport($db);
$objectstatic->fetch($line->fk_doc); $objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport'; //$modulepart = 'expensereport';
$filename = dol_sanitizeFileName($line->doc_ref); $filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref); $filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id; $urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir); $documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} else { } else {
// Other type // Other type
} }
print '<td class="nowrap">'; print '<td class="nowrap">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">'; print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref // Picto + Ref
print '<td class="nobordernopadding nowrap">'; print '<td class="nobordernopadding nowrap">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{ {
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1); print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink; print $documentlink;
} else { } else {
print $line->doc_ref; print $line->doc_ref;
} }
print '</td></tr></table>'; print '</td></tr></table>';
print "</td>\n"; print "</td>\n";
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
@ -1065,9 +1065,9 @@ print '</div>';
// TODO Replace this with mass delete action // TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) { if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">'."\n"; print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>'; print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>'; print '</div>';
} }
print '</form>'; print '</form>';

View File

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("accountancy")); $langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int')); $search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
@ -138,7 +138,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook)) if (empty($reshook))
{ {
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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 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
{ {
@ -172,55 +172,55 @@ if (empty($reshook))
if (!empty($search_date_start)) { if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start; $filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth=' . GETPOST('search_date_startmonth', 'int') . '&search_date_startday=' . GETPOST('search_date_startday', 'int') . '&search_date_startyear=' . GETPOST('search_date_startyear', 'int'); $param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int');
} }
if (!empty($search_date_end)) { if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end; $filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth=' . GETPOST('search_date_endmonth', 'int') . '&search_date_endday=' . GETPOST('search_date_endday', 'int') . '&search_date_endyear=' . GETPOST('search_date_endyear', 'int'); $param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_date_endyear', 'int');
} }
if (!empty($search_doc_date)) { if (!empty($search_doc_date)) {
$filter['t.doc_date'] = $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'); $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 (!empty($search_accountancy_code_start)) {
$filter['t.numero_compte>='] = $search_accountancy_code_start; $filter['t.numero_compte>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start=' . urlencode($search_accountancy_code_start); $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
} }
if (!empty($search_accountancy_code_end)) { if (!empty($search_accountancy_code_end)) {
$filter['t.numero_compte<='] = $search_accountancy_code_end; $filter['t.numero_compte<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end=' . urlencode($search_accountancy_code_end); $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
} }
if (!empty($search_label_account)) { if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account; $filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte=' . urlencode($search_label_account); $param .= '&search_label_compte='.urlencode($search_label_account);
} }
if (!empty($search_mvt_num)) { if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num; $filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num=' . urlencode($search_mvt_num); $param .= '&search_mvt_num='.urlencode($search_mvt_num);
} }
if (!empty($search_doc_ref)) { if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref; $filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref=' . urlencode($search_doc_ref); $param .= '&search_doc_ref='.urlencode($search_doc_ref);
} }
if (!empty($search_label_operation)) { if (!empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation; $filter['t.label_operation'] = $search_label_operation;
$param .= '&search_label_operation=' . urlencode($search_label_operation); $param .= '&search_label_operation='.urlencode($search_label_operation);
} }
if (!empty($search_direction)) { if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction; $filter['t.sens'] = $search_direction;
$param .= '&search_direction=' . urlencode($search_direction); $param .= '&search_direction='.urlencode($search_direction);
} }
if (!empty($search_ledger_code)) { if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code; $filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code=' . urlencode($search_ledger_code); $param .= '&search_ledger_code='.urlencode($search_ledger_code);
} }
if (!empty($search_debit)) { if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit; $filter['t.debit'] = $search_debit;
$param .= '&search_debit=' . urlencode($search_debit); $param .= '&search_debit='.urlencode($search_debit);
} }
if (!empty($search_credit)) { if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit; $filter['t.credit'] = $search_credit;
$param .= '&search_credit=' . urlencode($search_credit); $param .= '&search_credit='.urlencode($search_credit);
} }
if (!empty($search_lettering_code)) { if (!empty($search_lettering_code)) {
$filter['t.lettering_code'] = $search_lettering_code; $filter['t.lettering_code'] = $search_lettering_code;
@ -376,18 +376,17 @@ print '<input type="hidden" name="formfilteraction" id="formfilteraction" value=
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">'; print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param);
$newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected')); $newcardbutton .= dolGetButtonTitle($langs->trans('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected'));
$newcardbutton .= ' &nbsp; '; $newcardbutton .= ' &nbsp; ';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create'); $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 (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $viewflat.$newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $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); // This also change content of $arrayfields
@ -427,7 +426,7 @@ print '<tr class="liste_titre_filter">';
// Code journal // Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) { if (!empty($arrayfields['t.code_journal']['checked'])) {
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="' . dol_escape_htmltag($search_ledger_code) . '"></td>'; print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.dol_escape_htmltag($search_ledger_code).'"></td>';
} }
// Date document // Date document
if (!empty($arrayfields['t.doc_date']['checked'])) { if (!empty($arrayfields['t.doc_date']['checked'])) {
@ -447,19 +446,19 @@ if (!empty($arrayfields['t.piece_num']['checked']))
} }
// Ref document // Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) { if (!empty($arrayfields['t.doc_ref']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="' . dol_escape_htmltag($search_doc_ref) . '"/></td>'; print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
} }
// Label operation // Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) { if (!empty($arrayfields['t.label_operation']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="' . dol_escape_htmltag($search_label_operation) . '"/></td>'; print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
} }
// Debit // Debit
if (!empty($arrayfields['t.debit']['checked'])) { if (!empty($arrayfields['t.debit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="' . dol_escape_htmltag($search_debit) . '"></td>'; print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
} }
// Credit // Credit
if (!empty($arrayfields['t.credit']['checked'])) { if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="' . dol_escape_htmltag($search_credit) . '"></td>'; print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
} }
// Lettering code // Lettering code
if (!empty($arrayfields['t.lettering_code']['checked'])) if (!empty($arrayfields['t.lettering_code']['checked']))
@ -535,7 +534,7 @@ while ($i < min($num, $limit))
$balance = $sous_total_debit - $sous_total_credit; $balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0 ) if ($balance > 0)
{ {
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);
@ -666,7 +665,7 @@ while ($i < min($num, $limit))
if (!empty($arrayfields['t.label_operation']['checked'])) { if (!empty($arrayfields['t.label_operation']['checked'])) {
// Affiche un lien vers la facture client/fournisseur // Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref); $doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>' . $line->label_operation . '</td>' : '<td>' . $line->label_operation . '<br><span style="font-size:0.8em">(' . length_accounta($line->subledger_account) . ')</span></td>'; print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
@ -681,7 +680,7 @@ while ($i < min($num, $limit))
// Amount credit // Amount credit
if (!empty($arrayfields['t.credit']['checked'])) { if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="nowrap right">' . ($line->credit ? price($line->credit) : '') . '</td>'; print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit'; if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
$totalarray['val']['totalcredit'] += $line->credit; $totalarray['val']['totalcredit'] += $line->credit;
@ -734,7 +733,7 @@ print '</tr>';
$balance = $sous_total_debit - $sous_total_credit; $balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">'; print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>'; print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0 ) if ($balance > 0)
{ {
print '<td class="nowraponall right">'; print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit); print price($sous_total_debit - $sous_total_credit);

View File

@ -0,0 +1,766 @@
<?php
/* Copyright (C) 2016 Neil Orley <neil.orley@oeris.fr>
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/accountancy/bookkeeping/listbysubaccount.php
* \ingroup Accountancy (Double entries)
* \brief List operation of ledger ordered by subaccount number
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.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/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("accountancy", "compta"));
$action = GETPOST('action', 'aZ09');
$search_date_start = dol_mktime(0, 0, 0, GETPOST('search_date_startmonth', 'int'), GETPOST('search_date_startday', 'int'), GETPOST('search_date_startyear', 'int'));
$search_date_end = dol_mktime(0, 0, 0, GETPOST('search_date_endmonth', 'int'), GETPOST('search_date_endday', 'int'), GETPOST('search_date_endyear', 'int'));
$search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
$search_accountancy_code = GETPOST("search_accountancy_code");
$search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
if ($search_accountancy_code_start == - 1) {
$search_accountancy_code_start = '';
}
$search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
if ($search_accountancy_code_end == - 1) {
$search_accountancy_code_end = '';
}
$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
$search_label_operation = GETPOST('search_label_operation', 'alpha');
$search_mvt_num = GETPOST('search_mvt_num', 'int');
$search_direction = GETPOST('search_direction', 'alpha');
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
$search_debit = GETPOST('search_debit', 'alpha');
$search_credit = GETPOST('search_credit', 'alpha');
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
$action = 'delbookkeepingyear';
}
// 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');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0) { $page = 0; }
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
if ($sortorder == "") $sortorder = "ASC";
if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$object = new BookKeeping($db);
$formfile = new FormFile($db);
$hookmanager->initHooks(array('bookkeepingbysubaccountlist'));
$formaccounting = new FormAccounting($db);
$form = new Form($db);
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('search_date_startday') && !GETPOSTISSET('search_date_startmonth') && !GETPOSTISSET('search_date_starthour')) {
$sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
$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);
$search_date_end = strtotime($fiscalYear->date_end);
} else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
}
}
$arrayfields = array(
// 't.subledger_account'=>array('label'=>$langs->trans("SubledgerAccount"), 'checked'=>1),
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
't.label_operation'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
't.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1),
't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
);
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
/*
* Action
*/
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $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))
{
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
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_accountancy_code_start = '';
$search_accountancy_code_end = '';
$search_label_account = '';
$search_doc_ref = '';
$search_label_operation = '';
$search_mvt_num = '';
$search_direction = '';
$search_ledger_code = '';
$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_debit = '';
$search_credit = '';
$search_lettering_code = '';
$search_not_reconciled = '';
}
// Must be after the remove filter action, before the export.
$param = '';
$filter = array();
if (!empty($search_date_start)) {
$filter['t.doc_date>='] = $search_date_start;
$param .= '&search_date_startmonth='.GETPOST('search_date_startmonth', 'int').'&search_date_startday='.GETPOST('search_date_startday', 'int').'&search_date_startyear='.GETPOST('search_date_startyear', 'int');
}
if (!empty($search_date_end)) {
$filter['t.doc_date<='] = $search_date_end;
$param .= '&search_date_endmonth='.GETPOST('search_date_endmonth', 'int').'&search_date_endday='.GETPOST('search_date_endday', 'int').'&search_date_endyear='.GETPOST('search_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)) {
$filter['t.subledger_account>='] = $search_accountancy_code_start;
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
}
if (!empty($search_accountancy_code_end)) {
$filter['t.subledger_account<='] = $search_accountancy_code_end;
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
}
if (!empty($search_label_account)) {
$filter['t.label_compte'] = $search_label_account;
$param .= '&search_label_compte='.urlencode($search_label_account);
}
if (!empty($search_mvt_num)) {
$filter['t.piece_num'] = $search_mvt_num;
$param .= '&search_mvt_num='.urlencode($search_mvt_num);
}
if (!empty($search_doc_ref)) {
$filter['t.doc_ref'] = $search_doc_ref;
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
}
if (!empty($search_label_operation)) {
$filter['t.label_operation'] = $search_label_operation;
$param .= '&search_label_operation='.urlencode($search_label_operation);
}
if (!empty($search_direction)) {
$filter['t.sens'] = $search_direction;
$param .= '&search_direction='.urlencode($search_direction);
}
if (!empty($search_ledger_code)) {
$filter['t.code_journal'] = $search_ledger_code;
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
}
if (!empty($search_debit)) {
$filter['t.debit'] = $search_debit;
$param .= '&search_debit='.urlencode($search_debit);
}
if (!empty($search_credit)) {
$filter['t.credit'] = $search_credit;
$param .= '&search_credit='.urlencode($search_credit);
}
if (!empty($search_lettering_code)) {
$filter['t.lettering_code'] = $search_lettering_code;
$param .= '&search_lettering_code='.urlencode($search_lettering_code);
}
if (!empty($search_not_reconciled)) {
$filter['t.reconciled_option'] = $search_not_reconciled;
$param .= '&search_not_reconciled='.urlencode($search_not_reconciled);
}
}
if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
$import_key = GETPOST('importkey', 'alpha');
if (!empty($import_key)) {
$result = $object->deleteByImportkey($import_key);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: listbyaccount.php".($param ? '?'.$param : ''));
exit;
}
}
if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouvements->supprimer_tous) {
$delmonth = GETPOST('delmonth', 'int');
$delyear = GETPOST('delyear', 'int');
if ($delyear == -1) {
$delyear = 0;
}
$deljournal = GETPOST('deljournal', 'alpha');
if ($deljournal == -1) {
$deljournal = 0;
}
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal))
{
$result = $object->deleteByYearAndJournal($delyear, $deljournal, '', ($delmonth > 0 ? $delmonth : 0));
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages("RecordDeleted", null, 'mesgs');
}
// Make a redirect to avoid to launch the delete later after a back button
header("Location: listbysubaccount.php".($param ? '?'.$param : ''));
exit;
} else {
setEventMessages("NoRecordDeleted", null, 'warnings');
}
}
if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->supprimer) {
$mvt_num = GETPOST('mvt_num', 'int');
if (!empty($mvt_num)) {
$result = $object->deleteMvtNum($mvt_num);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
} else {
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
}
header("Location: listbysubaccount.php?noreset=1".($param ? '&'.$param : ''));
exit;
}
}
/*
* View
*/
$formaccounting = new FormAccounting($db);
$formfile = new FormFile($db);
$formother = new FormOther($db);
$form = new Form($db);
$title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccounting").' ('.$langs->trans("BookkeepingSubAccount").')';
llxHeader('', $title_page);
// List
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $object->fetchAllByAccount($sortorder, $sortfield, 0, 0, $filter, 'AND', 1);
if ($nbtotalofrecords < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
}
$result = $object->fetchAllByAccount($sortorder, $sortfield, $limit, $offset, $filter, 'AND', 1);
if ($result < 0) {
setEventMessages($object->error, $object->errors, 'errors');
}
$num = count($object->lines);
if ($action == 'delmouv') {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num'), $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
print $formconfirm;
}
if ($action == 'delbookkeepingyear') {
$form_question = array();
$delyear = GETPOST('delyear', 'int');
$deljournal = GETPOST('deljournal', 'alpha');
if (empty($delyear)) {
$delyear = dol_print_date(dol_now(), '%Y');
}
$month_array = array();
for ($i = 1; $i <= 12; $i++) {
$month_array[$i] = $langs->trans("Month".sprintf("%02d", $i));
}
$year_array = $formaccounting->selectyear_accountancy_bookkepping($delyear, 'delyear', 0, 'array');
$journal_array = $formaccounting->select_journal($deljournal, 'deljournal', '', 1, 1, 1, '', 0, 1);
$form_question['delmonth'] = array(
'name' => 'delmonth',
'type' => 'select',
'label' => $langs->trans('DelMonth'),
'values' => $month_array,
'default' => ''
);
$form_question['delyear'] = array(
'name' => 'delyear',
'type' => 'select',
'label' => $langs->trans('DelYear'),
'values' => $year_array,
'default' => $delyear
);
$form_question['deljournal'] = array(
'name' => 'deljournal',
'type' => 'other', // We don't use select here, the journal_array is already a select html component
'label' => $langs->trans('DelJournal'),
'value' => $journal_array,
'default' => $deljournal
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'delbookkeepingyearconfirm', $form_question, '', 1, 300);
print $formconfirm;
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="list">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
$newcardbutton = dolGetButtonTitle($langs->trans('ViewAccountList'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php', '', 1, array('morecss'=>'marginleftonly btnTitleSelected'));
$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, '', $result, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit);
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
// Reverse sort order
if (preg_match('/^asc/i', $sortorder)) $sortorder = "asc";
else $sortorder = "desc";
$moreforfilter = '';
// Accountancy account
$moreforfilter .= '<div class="divsearchfield">';
$moreforfilter .= $langs->trans('AccountAccounting').': ';
$moreforfilter .= '<div class="nowrap inline-block">';
$moreforfilter .= $langs->trans('From').' ';
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, 'maxwidth200');
$moreforfilter .= ' '.$langs->trans('to').' ';
$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, 'maxwidth200');
$moreforfilter .= '</div>';
$moreforfilter .= '</div>';
$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;
print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter;
print '</div>';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste centpercent">';
// Filters lines
print '<tr class="liste_titre_filter">';
// Code journal
if (!empty($arrayfields['t.code_journal']['checked'])) {
print '<td class="liste_titre center"><input type="text" name="search_ledger_code" size="3" value="'.dol_escape_htmltag($search_ledger_code).'"></td>';
}
// Date document
if (!empty($arrayfields['t.doc_date']['checked'])) {
print '<td class="liste_titre center">';
print '<div class="nowrap">';
print $form->selectDate($search_date_start, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
print '</div>';
print '<div class="nowrap">';
print $form->selectDate($search_date_end, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
print '</div>';
print '</td>';
}
// Movement number
if (!empty($arrayfields['t.piece_num']['checked']))
{
print '<td class="liste_titre"><input type="text" name="search_mvt_num" size="6" value="'.dol_escape_htmltag($search_mvt_num).'"></td>';
}
// Ref document
if (!empty($arrayfields['t.doc_ref']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_doc_ref" value="'.dol_escape_htmltag($search_doc_ref).'"/></td>';
}
// Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) {
print '<td class="liste_titre"><input type="text" size="7" class="flat" name="search_label_operation" value="'.dol_escape_htmltag($search_label_operation).'"/></td>';
}
// Debit
if (!empty($arrayfields['t.debit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'"></td>';
}
// Credit
if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="liste_titre right"><input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'"></td>';
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked']))
{
print '<td class="liste_titre center">';
print '<input type="text" size="3" class="flat" name="search_lettering_code" value="'.$search_lettering_code.'"/>';
print '<br><span class="nowrap"><input type="checkbox" name="search_reconciled_option" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
print '</td>';
}
// 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;
// Action column
print '<td class="liste_titre center">';
$searchpicto = $form->showFilterButtons();
print $searchpicto;
print '</td>';
print "</tr>\n";
print '<tr class="liste_titre">';
if (!empty($arrayfields['t.code_journal']['checked'])) print_liste_field_titre($arrayfields['t.code_journal']['label'], $_SERVER['PHP_SELF'], "t.code_journal", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['t.doc_date']['checked'])) print_liste_field_titre($arrayfields['t.doc_date']['label'], $_SERVER['PHP_SELF'], "t.doc_date", "", $param, '', $sortfield, $sortorder, 'center ');
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);
if (!empty($arrayfields['t.doc_ref']['checked'])) print_liste_field_titre($arrayfields['t.doc_ref']['label'], $_SERVER['PHP_SELF'], "t.doc_ref", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.label_operation']['checked'])) print_liste_field_titre($arrayfields['t.label_operation']['label'], $_SERVER['PHP_SELF'], "t.label_operation", "", $param, "", $sortfield, $sortorder);
if (!empty($arrayfields['t.debit']['checked'])) print_liste_field_titre($arrayfields['t.debit']['label'], $_SERVER['PHP_SELF'], "t.debit", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.credit']['checked'])) print_liste_field_titre($arrayfields['t.credit']['label'], $_SERVER['PHP_SELF'], "t.credit", "", $param, '', $sortfield, $sortorder, 'right ');
if (!empty($arrayfields['t.lettering_code']['checked'])) print_liste_field_titre($arrayfields['t.lettering_code']['label'], $_SERVER['PHP_SELF'], "t.lettering_code", "", $param, '', $sortfield, $sortorder, 'center ');
// 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;
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$total_debit = 0;
$total_credit = 0;
$sous_total_debit = 0;
$sous_total_credit = 0;
$displayed_account_number = null; // Start with undefined to be able to distinguish with empty
// Loop on record
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
$line = $object->lines[$i];
$total_debit += $line->debit;
$total_credit += $line->credit;
$accountg = length_accounta($line->subledger_account);
//if (empty($accountg)) $accountg = '-';
// Is it a break ?
if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
$colspan = $totalarray['nbfield'] - 3;
$colspanend = $totalarray['nbfield'] - 7;
// Show a subtotal by accounting account
if (isset($displayed_account_number)) {
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.length_accounta($displayed_account_number).':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
}
// Show the break account
print "<tr>";
print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 9).'" style="font-weight:bold; border-bottom: 1pt solid black;">';
if ($line->subledger_account != "" && $line->subledger_account != '-1') print length_accounta($line->subledger_account).' : '.$object->get_compte_desc($line->numero_compte);
else print '<span class="error">'.$langs->trans("Unknown").'</span>';
print '</td>';
print '</tr>';
$displayed_account_number = $accountg;
//if (empty($displayed_account_number)) $displayed_account_number='-';
$sous_total_debit = 0;
$sous_total_credit = 0;
$colspan = 0;
}
print '<tr class="oddeven">';
// Journal code
if (!empty($arrayfields['t.code_journal']['checked']))
{
$accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $line->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $line->code_journal);
print '<td class="center">'.$journaltoshow.'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Document date
if (!empty($arrayfields['t.doc_date']['checked']))
{
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Piece number
if (!empty($arrayfields['t.piece_num']['checked']))
{
print '<td>';
$object->id = $line->id;
$object->piece_num = $line->piece_num;
print $object->getNomUrl(1, '', 0, '', 1);
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Document ref
if (!empty($arrayfields['t.doc_ref']['checked']))
{
if ($line->doc_type == 'customer_invoice')
{
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$objectstatic = new Facture($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'facture';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->facture->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} elseif ($line->doc_type == 'supplier_invoice')
{
$langs->loadLangs(array('bills'));
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$objectstatic = new FactureFournisseur($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'invoice_supplier';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($line->fk_doc, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$subdir = get_exdir($objectstatic->id, 2, 0, 0, $objectstatic, $modulepart).dol_sanitizeFileName($line->doc_ref);
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $subdir, $filedir);
} elseif ($line->doc_type == 'expense_report')
{
$langs->loadLangs(array('trips'));
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
$objectstatic = new ExpenseReport($db);
$objectstatic->fetch($line->fk_doc);
//$modulepart = 'expensereport';
$filename = dol_sanitizeFileName($line->doc_ref);
$filedir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($line->doc_ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$objectstatic->id;
$documentlink = $formfile->getDocumentsLink($objectstatic->element, $filename, $filedir);
} else {
// Other type
}
print '<td class="nowrap">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
// Picto + Ref
print '<td class="nobordernopadding nowrap">';
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
{
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
print $documentlink;
} else {
print $line->doc_ref;
}
print '</td></tr></table>';
print "</td>\n";
if (!$i) $totalarray['nbfield']++;
}
// Label operation
if (!empty($arrayfields['t.label_operation']['checked'])) {
// Affiche un lien vers la facture client/fournisseur
$doc_ref = preg_replace('/\(.*\)/', '', $line->doc_ref);
print strlen(length_accounta($line->subledger_account)) == 0 ? '<td>'.$line->label_operation.'</td>' : '<td>'.$line->label_operation.'<br><span style="font-size:0.8em">('.length_accounta($line->subledger_account).')</span></td>';
if (!$i) $totalarray['nbfield']++;
}
// Amount debit
if (!empty($arrayfields['t.debit']['checked']))
{
print '<td class="nowrap right">'.($line->debit ? price($line->debit) : '').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
$totalarray['val']['totaldebit'] += $line->debit;
}
// Amount credit
if (!empty($arrayfields['t.credit']['checked'])) {
print '<td class="nowrap right">'.($line->credit ? price($line->credit) : '').'</td>';
if (!$i) $totalarray['nbfield']++;
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
$totalarray['val']['totalcredit'] += $line->credit;
}
// Lettering code
if (!empty($arrayfields['t.lettering_code']['checked']))
{
print '<td class="center">'.$line->lettering_code.'</td>';
if (!$i) $totalarray['nbfield']++;
}
// Fields from hook
$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
// Action column
print '<td class="nowraponall center">';
if (empty($line->date_export)) {
if ($user->rights->accounting->mouvements->creer) {
print '<a class="editfielda" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
}
if ($user->rights->accounting->mouvements->supprimer) {
print ' &nbsp; <a class="paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
}
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
// Comptabilise le sous-total
$sous_total_debit += $line->debit;
$sous_total_credit += $line->credit;
print "</tr>\n";
$i++;
}
// Show sub-total of last shown account
$colspan = $totalarray['nbfield'] - 3;
$colspanend = $totalarray['nbfield'] - 8;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show balance of last shown account
$balance = $sous_total_debit - $sous_total_credit;
print '<tr class="liste_total">';
print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("Balance").':</td>';
if ($balance > 0)
{
print '<td class="nowraponall right">';
print price($sous_total_debit - $sous_total_credit);
print '</td>';
print '<td></td>';
} else {
print '<td></td>';
print '<td class="nowraponall right">';
print price($sous_total_credit - $sous_total_debit);
print '</td>';
}
print '<td colspan="'.$colspanend.'"></td>';
print '</tr>';
// Show total line
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "</table>";
print '</div>';
// TODO Replace this with mass delete action
if ($user->rights->accounting->mouvements->supprimer_tous) {
print '<div class="tabsAction tabsActionNoBottom">'."\n";
print '<a class="butActionDelete" name="button_delmvt" href="'.$_SERVER["PHP_SELF"].'?action=delbookkeepingyear'.($param ? '&'.$param : '').'">'.$langs->trans("DeleteMvt").'</a>';
print '</div>';
}
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -195,17 +195,17 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$param = "&socid=".$socid; $param = "&socid=".$socid;
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="socid" value="'.$object->id.'">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>'; $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="liste centpercent">'."\n"; print '<table class="liste centpercent">'."\n";
/* /*
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -244,13 +244,13 @@ if ($resql) {
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
print "</tr>\n"; print "</tr>\n";
$solde = 0; $solde = 0;
$tmp = ''; $tmp = '';
while ($obj = $db->fetch_object($resql)) { while ($obj = $db->fetch_object($resql)) {
if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code; if ($tmp != $obj->lettering_code || empty($tmp)) $tmp = $obj->lettering_code;
/*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit); /*if ($tmp != $obj->lettering_code || empty($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
@ -265,20 +265,20 @@ if ($resql) {
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>'; print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
// Journal // Journal
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $obj->code_journal); $result = $accountingjournal->fetch('', $obj->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">'.$journaltoshow.'</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (empty($obj->lettering_code)) { if (empty($obj->lettering_code)) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>'; print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">'; print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
print img_edit(); print img_edit();
print '</a></td>'."\n"; print '</a></td>'."\n";
} else { } else {
print '<td class="center">'.$obj->lettering_code.'</td>'; print '<td class="center">'.$obj->lettering_code.'</td>';
print '<td></td>'; print '<td></td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
@ -299,9 +299,9 @@ if ($resql) {
print "</table>"; print "</table>";
print '<div class="tabsAction tabsActionNoBottom">'."\n"; print '<div class="tabsAction tabsActionNoBottom">'."\n";
print $letteringbutton; print $letteringbutton;
print '</div>'; print '</div>';
print "</form>"; print "</form>";
$db->free($resql); $db->free($resql);

View File

@ -4,7 +4,7 @@
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com> * Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2013-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -41,7 +41,7 @@ $massaction = GETPOST('massaction', 'alpha');
$show_files = GETPOST('show_files', 'int'); $show_files = GETPOST('show_files', 'int');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$toselect = GETPOST('toselect', 'array'); $toselect = GETPOST('toselect', 'array');
$socid = GETPOST('socid', 'int') ?GETPOST('socid', 'int') : GETPOST('id', 'int'); $socid = GETPOST('socid', 'int') ? ((int) GETPOST('socid', 'int')) : ((int) GETPOST('id', 'int'));
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
@ -193,17 +193,17 @@ if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
$param = "&socid=".$socid; $param = "&socid=".$socid;
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">'; print '<form name="add" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="socid" value="'.$object->id.'">'; print '<input type="hidden" name="socid" value="'.$object->id.'">';
$letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>'; $letteringbutton = '<a class="divButAction"><span class="valignmiddle"><input class="butAction" type="submit" value="lettering" name="lettering" id="lettering"></span></a>';
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, $letteringbutton, '', $limit);
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="liste centpercent">'."\n"; print '<table class="liste centpercent">'."\n";
/* /*
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -242,7 +242,7 @@ if ($resql) {
print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Balancing", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder);
print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("Codejournal", $_SERVER["PHP_SELF"], "bk.code_journal", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center '); print_liste_field_titre("LetteringCode", $_SERVER["PHP_SELF"], "bk.lettering_code", "", $param, "", $sortfield, $sortorder, 'center ');
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center '); print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
print "</tr>\n"; print "</tr>\n";
$solde = 0; $solde = 0;
@ -261,21 +261,21 @@ if ($resql) {
print '<td class="nowrap right">'.price($obj->credit).'</td>'; print '<td class="nowrap right">'.price($obj->credit).'</td>';
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>'; print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
// Journal // Journal
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
$result = $accountingjournal->fetch('', $obj->code_journal); $result = $accountingjournal->fetch('', $obj->code_journal);
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal); $journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
print '<td class="center">'.$journaltoshow.'</td>'; print '<td class="center">'.$journaltoshow.'</td>';
if (empty($obj->lettering_code) && empty($obj->date_validated)) { if (empty($obj->lettering_code) && empty($obj->date_validated)) {
print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>'; print '<td class="nowrap center"><input type="checkbox" class="flat checkforselect" name="toselect[]" id="toselect[]" value="'.$obj->rowid.'" /></td>';
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">'; print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
print img_edit(); print img_edit();
print '</a></td>'."\n"; print '</a></td>'."\n";
} else { } else {
print '<td class="center">'.$obj->lettering_code.'</td>'; print '<td class="center">'.$obj->lettering_code.'</td>';
print '<td></td>'; print '<td></td>';
} }
print "</tr>\n"; print "</tr>\n";
} }
@ -296,9 +296,9 @@ if ($resql) {
print "</table>"; print "</table>";
print '<div class="tabsAction tabsActionNoBottom">'."\n"; print '<div class="tabsAction tabsActionNoBottom">'."\n";
print $letteringbutton; print $letteringbutton;
print '</div>'; print '</div>';
print "</form>"; print "</form>";
$db->free($resql); $db->free($resql);

View File

@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
*/ */
class AccountancyCategory // extends CommonObject class AccountancyCategory // extends CommonObject
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var string Error string * @var string Error string
@ -63,9 +63,9 @@ class AccountancyCategory // extends CommonObject
public $rowid; public $rowid;
/** /**
* @var int ID * @var int ID
*/ */
public $id; public $id;
/** /**
* @var string Accountancy code * @var string Accountancy code
@ -73,11 +73,11 @@ class AccountancyCategory // extends CommonObject
public $code; public $code;
/** /**
* @var string Accountancy Category label * @var string Accountancy Category label
*/ */
public $label; public $label;
/** /**
* @var string Accountancy range account * @var string Accountancy range account
*/ */
public $range_account; public $range_account;
@ -381,8 +381,8 @@ class AccountancyCategory // extends CommonObject
* @param int $id Id * @param int $id Id
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function display($id) public function display($id)
{ {
global $conf; global $conf;
$sql = "SELECT t.rowid, t.account_number, t.label"; $sql = "SELECT t.rowid, t.account_number, t.label";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
@ -408,7 +408,7 @@ class AccountancyCategory // extends CommonObject
return -1; return -1;
} }
} }
/** /**
* Function to select accounting category of an accounting account present in chart of accounts * Function to select accounting category of an accounting account present in chart of accounts
@ -417,8 +417,8 @@ class AccountancyCategory // extends CommonObject
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function getCptBK($id) public function getCptBK($id)
{ {
global $conf; global $conf;
$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref"; $sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
@ -457,7 +457,7 @@ class AccountancyCategory // extends CommonObject
return -1; return -1;
} }
} }
/** /**
* Function to select accounting category of an accounting account present in chart of accounts * Function to select accounting category of an accounting account present in chart of accounts
@ -466,41 +466,41 @@ class AccountancyCategory // extends CommonObject
* *
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function getAccountsWithNoCategory($id) public function getAccountsWithNoCategory($id)
{ {
global $conf; global $conf;
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte"; $sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version";
$sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)"; $sql .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = ".$conf->entity; $sql .= " AND aa.entity = ".$conf->entity;
$sql .= " GROUP BY aa.account_number, aa.label"; $sql .= " GROUP BY aa.account_number, aa.label";
$sql .= " ORDER BY aa.account_number, aa.label"; $sql .= " ORDER BY aa.account_number, aa.label";
$this->lines_CptBk = array(); $this->lines_CptBk = array();
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
if ($num) { if ($num) {
while ($obj = $this->db->fetch_object($resql)) { while ($obj = $this->db->fetch_object($resql)) {
$this->lines_cptbk[] = $obj; $this->lines_cptbk[] = $obj;
} }
} }
return $num; return $num;
} else { } else {
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = $this->error; $this->errors[] = $this->error;
dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR); dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
return -1; return -1;
} }
} }
/** /**
* Function to add an accounting account in an accounting category * Function to add an accounting account in an accounting category
@ -510,8 +510,8 @@ class AccountancyCategory // extends CommonObject
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function updateAccAcc($id_cat, $cpts = array()) public function updateAccAcc($id_cat, $cpts = array())
{ {
global $conf; global $conf;
$error = 0; $error = 0;
@ -523,7 +523,7 @@ class AccountancyCategory // extends CommonObject
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS; $sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
$sql .= " AND aa.active = 1"; $sql .= " AND aa.active = 1";
$sql .= " AND aa.entity = ".$conf->entity; $sql .= " AND aa.entity = ".$conf->entity;
$sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql $sql .= " ORDER BY LENGTH(aa.account_number) DESC;"; // LENGTH is ok with mysql and postgresql
$this->db->begin(); $this->db->begin();
@ -539,13 +539,13 @@ class AccountancyCategory // extends CommonObject
$accountincptsadded = array(); $accountincptsadded = array();
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql))
{ {
$account_number_formated = length_accountg($obj->account_number); $account_number_formated = length_accountg($obj->account_number);
if (!empty($accountincptsadded[$account_number_formated])) continue; if (!empty($accountincptsadded[$account_number_formated])) continue;
if (array_key_exists($account_number_formated, $cpts)) if (array_key_exists($account_number_formated, $cpts))
{ {
$accountincptsadded[$account_number_formated] = 1; $accountincptsadded[$account_number_formated] = 1;
// We found an account number that is in list $cpts of account to add // We found an account number that is in list $cpts of account to add
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
$sql .= " SET fk_accounting_category=".$id_cat; $sql .= " SET fk_accounting_category=".$id_cat;
$sql .= " WHERE rowid=".$obj->rowid; $sql .= " WHERE rowid=".$obj->rowid;
@ -572,7 +572,7 @@ class AccountancyCategory // extends CommonObject
return 1; return 1;
} }
} }
/** /**
* Function to delete an accounting account from an accounting category * Function to delete an accounting account from an accounting category
@ -581,8 +581,8 @@ class AccountancyCategory // extends CommonObject
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function deleteCptCat($cpt_id) public function deleteCptCat($cpt_id)
{ {
$error = 0; $error = 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa";
@ -598,7 +598,7 @@ class AccountancyCategory // extends CommonObject
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
foreach ($this->errors as $errmsg) { foreach ($this->errors as $errmsg) {
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR); dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
$this->error .= ($this->error ? ', '.$errmsg : $errmsg); $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
@ -606,12 +606,12 @@ class AccountancyCategory // extends CommonObject
$this->db->rollback(); $this->db->rollback();
return -1 * $error; return -1 * $error;
} else { } else {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} }
/** /**
* Function to know all category from accounting account * Function to know all category from accounting account
@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject
'formula' => $obj->formula, 'formula' => $obj->formula,
'position' => $obj->position, 'position' => $obj->position,
'category_type' => $obj->category_type, 'category_type' => $obj->category_type,
'bc' => $obj->sens 'bc' => $obj->sens
); );
$i++; $i++;
} }

View File

@ -55,7 +55,7 @@ class AccountancyExport
public static $EXPORT_TYPE_QUADRATUS = 60; public static $EXPORT_TYPE_QUADRATUS = 60;
public static $EXPORT_TYPE_WINFIC = 70; public static $EXPORT_TYPE_WINFIC = 70;
public static $EXPORT_TYPE_OPENCONCERTO = 100; public static $EXPORT_TYPE_OPENCONCERTO = 100;
public static $EXPORT_TYPE_LDCOMPTA = 110; public static $EXPORT_TYPE_LDCOMPTA = 110;
public static $EXPORT_TYPE_LDCOMPTA10 = 120; public static $EXPORT_TYPE_LDCOMPTA10 = 120;
public static $EXPORT_TYPE_FEC = 1000; public static $EXPORT_TYPE_FEC = 1000;
@ -111,7 +111,7 @@ class AccountancyExport
self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'),
self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'),
self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'), self::$EXPORT_TYPE_OPENCONCERTO => $langs->trans('Modelcsv_openconcerto'),
self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'), self::$EXPORT_TYPE_SAGE50_SWISS => $langs->trans('Modelcsv_Sage50_Swiss'),
self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'), self::$EXPORT_TYPE_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'), self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
@ -144,9 +144,9 @@ class AccountancyExport
self::$EXPORT_TYPE_COGILOG => 'cogilog', self::$EXPORT_TYPE_COGILOG => 'cogilog',
self::$EXPORT_TYPE_AGIRIS => 'agiris', self::$EXPORT_TYPE_AGIRIS => 'agiris',
self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto', self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch', self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta', self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10', self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
self::$EXPORT_TYPE_FEC => 'fec', self::$EXPORT_TYPE_FEC => 'fec',
); );
@ -201,22 +201,22 @@ class AccountancyExport
self::$EXPORT_TYPE_AGIRIS => array( self::$EXPORT_TYPE_AGIRIS => array(
'label' => $langs->trans('Modelcsv_agiris'), 'label' => $langs->trans('Modelcsv_agiris'),
), ),
self::$EXPORT_TYPE_OPENCONCERTO => array( self::$EXPORT_TYPE_OPENCONCERTO => array(
'label' => $langs->trans('Modelcsv_openconcerto'), 'label' => $langs->trans('Modelcsv_openconcerto'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv', 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
), ),
self::$EXPORT_TYPE_SAGE50_SWISS => array( self::$EXPORT_TYPE_SAGE50_SWISS => array(
'label' => $langs->trans('Modelcsv_Sage50_Swiss'), 'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv', 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
), ),
self::$EXPORT_TYPE_LDCOMPTA => array( self::$EXPORT_TYPE_LDCOMPTA => array(
'label' => $langs->trans('Modelcsv_LDCompta'), 'label' => $langs->trans('Modelcsv_LDCompta'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv', 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
), ),
self::$EXPORT_TYPE_LDCOMPTA10 => array( self::$EXPORT_TYPE_LDCOMPTA10 => array(
'label' => $langs->trans('Modelcsv_LDCompta10'), 'label' => $langs->trans('Modelcsv_LDCompta10'),
'ACCOUNTING_EXPORT_FORMAT' => 'csv', 'ACCOUNTING_EXPORT_FORMAT' => 'csv',
), ),
self::$EXPORT_TYPE_FEC => array( self::$EXPORT_TYPE_FEC => array(
'label' => $langs->trans('Modelcsv_FEC'), 'label' => $langs->trans('Modelcsv_FEC'),
'ACCOUNTING_EXPORT_FORMAT' => 'txt', 'ACCOUNTING_EXPORT_FORMAT' => 'txt',
@ -254,7 +254,7 @@ class AccountancyExport
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset); $filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
$type_export = 'general_ledger'; $type_export = 'general_ledger';
global $db; // The tpl file use $db global $db; // The tpl file use $db
include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php'; include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
@ -289,21 +289,21 @@ class AccountancyExport
case self::$EXPORT_TYPE_AGIRIS : case self::$EXPORT_TYPE_AGIRIS :
$this->exportAgiris($TData); $this->exportAgiris($TData);
break; break;
case self::$EXPORT_TYPE_OPENCONCERTO : case self::$EXPORT_TYPE_OPENCONCERTO :
$this->exportOpenConcerto($TData); $this->exportOpenConcerto($TData);
break; break;
case self::$EXPORT_TYPE_SAGE50_SWISS : case self::$EXPORT_TYPE_SAGE50_SWISS :
$this->exportSAGE50SWISS($TData); $this->exportSAGE50SWISS($TData);
break; break;
case self::$EXPORT_TYPE_LDCOMPTA : case self::$EXPORT_TYPE_LDCOMPTA :
$this->exportLDCompta($TData); $this->exportLDCompta($TData);
break; break;
case self::$EXPORT_TYPE_LDCOMPTA10 : case self::$EXPORT_TYPE_LDCOMPTA10 :
$this->exportLDCompta10($TData); $this->exportLDCompta10($TData);
break; break;
case self::$EXPORT_TYPE_FEC : case self::$EXPORT_TYPE_FEC :
$this->exportFEC($TData); $this->exportFEC($TData);
break; break;
case self::$EXPORT_TYPE_CHARLEMAGNE : case self::$EXPORT_TYPE_CHARLEMAGNE :
$this->exportCharlemagne($TData); $this->exportCharlemagne($TData);
break; break;
@ -386,6 +386,7 @@ class AccountancyExport
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y'); $date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date.$separator; print $date.$separator;
print $line->code_journal.$separator; print $line->code_journal.$separator;
print length_accountg($line->numero_compte).$separator; print length_accountg($line->numero_compte).$separator;
@ -394,7 +395,7 @@ class AccountancyExport
print price($line->debit).$separator; print price($line->debit).$separator;
print price($line->credit).$separator; print price($line->credit).$separator;
print 'E'.$separator; print 'E'.$separator;
print length_accountg($line->subledger_account).$separator; print length_accounta($line->subledger_account).$separator;
print $end_line; print $end_line;
} }
} }
@ -599,7 +600,7 @@ class AccountancyExport
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0'); $Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
if ($data->sens == 'D') { if ($data->sens == 'D') {
$Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_debit'] = str_pad(number_format(abs($data->montant), 2, ',', ''), 13, ' ', STR_PAD_LEFT);
$Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT); $Tab['montant_crebit'] = str_pad(number_format(0, 2, ',', ''), 13, ' ', STR_PAD_LEFT);
} else { } else {
@ -659,10 +660,10 @@ class AccountancyExport
print $date.$separator; print $date.$separator;
print $line->code_journal.$separator; print $line->code_journal.$separator;
if (empty($line->subledger_account)) { if (empty($line->subledger_account)) {
print $line->numero_compte.$separator; print $line->numero_compte.$separator;
} else { } else {
print $line->subledger_account.$separator; print $line->subledger_account.$separator;
} }
//print substr(length_accountg($line->numero_compte), 0, 2) . $separator; //print substr(length_accountg($line->numero_compte), 0, 2) . $separator;
print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->label_operation, 40, 'right', 'UTF-8', 1).'"'.$separator;
print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator; print '"'.dol_trunc($line->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
@ -714,36 +715,36 @@ class AccountancyExport
} }
} }
/** /**
* Export format : OpenConcerto * Export format : OpenConcerto
* *
* @param array $objectLines data * @param array $objectLines data
* @return void * @return void
*/ */
public function exportOpenConcerto($objectLines) public function exportOpenConcerto($objectLines)
{ {
$separator = ';'; $separator = ';';
$end_line = "\n"; $end_line = "\n";
foreach ($objectLines as $line) { foreach ($objectLines as $line) {
$date = dol_print_date($line->doc_date, '%d/%m/%Y'); $date = dol_print_date($line->doc_date, '%d/%m/%Y');
print $date.$separator; print $date.$separator;
print $line->code_journal.$separator; print $line->code_journal.$separator;
if (empty($line->subledger_account)) { if (empty($line->subledger_account)) {
print length_accountg($line->numero_compte).$separator; print length_accountg($line->numero_compte).$separator;
} else { } else {
print length_accounta($line->subledger_account).$separator; print length_accounta($line->subledger_account).$separator;
} }
print $line->doc_ref.$separator; print $line->doc_ref.$separator;
print $line->label_operation.$separator; print $line->label_operation.$separator;
print price($line->debit).$separator; print price($line->debit).$separator;
print price($line->credit).$separator; print price($line->credit).$separator;
print $end_line; print $end_line;
} }
} }
/** /**
* Export format : Configurable CSV * Export format : Configurable CSV
@ -822,25 +823,25 @@ class AccountancyExport
print $line->piece_num.$separator; print $line->piece_num.$separator;
// FEC:EcritureDate // FEC:EcritureDate
print $date_document . $separator; print $date_document.$separator;
// FEC:CompteNum // FEC:CompteNum
print $line->numero_compte.$separator; print $line->numero_compte.$separator;
// FEC:CompteLib // FEC:CompteLib
print dol_string_unaccent($line->label_compte) . $separator; print dol_string_unaccent($line->label_compte).$separator;
// FEC:CompAuxNum // FEC:CompAuxNum
print $line->subledger_account.$separator; print $line->subledger_account.$separator;
// FEC:CompAuxLib // FEC:CompAuxLib
print dol_string_unaccent($line->subledger_label) . $separator; print dol_string_unaccent($line->subledger_label).$separator;
// FEC:PieceRef // FEC:PieceRef
print $line->doc_ref.$separator; print $line->doc_ref.$separator;
// FEC:PieceDate // FEC:PieceDate
print dol_string_unaccent($date_creation) . $separator; print dol_string_unaccent($date_creation).$separator;
// FEC:EcritureLib // FEC:EcritureLib
print $line->label_operation.$separator; print $line->label_operation.$separator;
@ -858,7 +859,7 @@ class AccountancyExport
print $line->date_lettering.$separator; print $line->date_lettering.$separator;
// FEC:ValidDate // FEC:ValidDate
print $date_validation . $separator; print $date_validation.$separator;
// FEC:Montantdevise // FEC:Montantdevise
print $line->multicurrency_amount.$separator; print $line->multicurrency_amount.$separator;
@ -870,152 +871,152 @@ class AccountancyExport
} }
} }
/** /**
* Export format : SAGE50SWISS * Export format : SAGE50SWISS
* *
* https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984 * https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984
* http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf * http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf
* *
* @param array $objectLines data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportSAGE50SWISS($objectLines) public function exportSAGE50SWISS($objectLines)
{ {
// SAGE50SWISS // SAGE50SWISS
$this->separator = ','; $this->separator = ',';
$this->end_line = "\r\n"; $this->end_line = "\r\n";
// Print header line // Print header line
print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag"; print "Blg,Datum,Kto,S/H,Grp,GKto,SId,SIdx,KIdx,BTyp,MTyp,Code,Netto,Steuer,FW-Betrag,Tx1,Tx2,PkKey,OpId,Flag";
print $this->end_line; print $this->end_line;
$thisPieceNum = ""; $thisPieceNum = "";
$thisPieceAccountNr = ""; $thisPieceAccountNr = "";
$aSize = count($objectLines); $aSize = count($objectLines);
foreach ($objectLines as $aIndex=>$line) foreach ($objectLines as $aIndex=>$line)
{ {
$sammelBuchung = false; $sammelBuchung = false;
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num) if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
{ {
$sammelBuchung = true; $sammelBuchung = true;
} elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num) } elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
{ {
$sammelBuchung = true; $sammelBuchung = true;
} elseif ($aIndex + 1 < $aSize } elseif ($aIndex + 1 < $aSize
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num && $objectLines[$aIndex + 1]->piece_num == $line->piece_num
&& $aIndex - 1 < $aSize && $aIndex - 1 < $aSize
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num && $objectLines[$aIndex - 1]->piece_num == $line->piece_num
) )
{ {
$sammelBuchung = true; $sammelBuchung = true;
} }
//Blg //Blg
print $line->piece_num.$this->separator; print $line->piece_num.$this->separator;
// Datum // Datum
$date = dol_print_date($line->doc_date, '%d.%m.%Y'); $date = dol_print_date($line->doc_date, '%d.%m.%Y');
print $date.$this->separator; print $date.$this->separator;
// Kto // Kto
print length_accountg($line->numero_compte).$this->separator; print length_accountg($line->numero_compte).$this->separator;
// S/H // S/H
if ($line->sens == 'D') if ($line->sens == 'D')
{ {
print 'S'.$this->separator; print 'S'.$this->separator;
} else { } else {
print 'H'.$this->separator; print 'H'.$this->separator;
} }
//Grp //Grp
print self::trunc($line->code_journal, 1).$this->separator; print self::trunc($line->code_journal, 1).$this->separator;
// GKto // GKto
if (empty($line->code_tiers)) if (empty($line->code_tiers))
{ {
if ($line->piece_num == $thisPieceNum) if ($line->piece_num == $thisPieceNum)
{ {
print length_accounta($thisPieceAccountNr).$this->separator; print length_accounta($thisPieceAccountNr).$this->separator;
} else { } else {
print "div".$this->separator; print "div".$this->separator;
} }
} else { } else {
print length_accounta($line->code_tiers).$this->separator; print length_accounta($line->code_tiers).$this->separator;
} }
//SId //SId
print $this->separator; print $this->separator;
//SIdx //SIdx
print "0".$this->separator; print "0".$this->separator;
//KIdx //KIdx
print "0".$this->separator; print "0".$this->separator;
//BTyp //BTyp
print "0".$this->separator; print "0".$this->separator;
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung //MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
if ($sammelBuchung) if ($sammelBuchung)
{ {
print "2".$this->separator; print "2".$this->separator;
} else { } else {
print "1".$this->separator; print "1".$this->separator;
} }
// Code // Code
print '""'.$this->separator; print '""'.$this->separator;
// Netto // Netto
if ($line->montant >= 0) if ($line->montant >= 0)
{ {
print $line->montant.$this->separator; print $line->montant.$this->separator;
} else { } else {
print ($line->montant * -1).$this->separator; print ($line->montant * -1).$this->separator;
} }
// Steuer // Steuer
print "0.00".$this->separator; print "0.00".$this->separator;
// FW-Betrag // FW-Betrag
print "0.00".$this->separator; print "0.00".$this->separator;
// Tx1 // Tx1
$line1 = self::toAnsi($line->label_compte, 29); $line1 = self::toAnsi($line->label_compte, 29);
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3) if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
{ {
$line1 = ""; $line1 = "";
} }
$line2 = self::toAnsi($line->doc_ref, 29); $line2 = self::toAnsi($line->doc_ref, 29);
if (strlen($line1) == 0) if (strlen($line1) == 0)
{ {
$line1 = $line2; $line1 = $line2;
$line2 = ""; $line2 = "";
} }
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27) if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
{ {
$line1 = $line1.' / '.$line2; $line1 = $line1.' / '.$line2;
$line2 = ""; $line2 = "";
} }
print '"'.self::toAnsi($line1).'"'.$this->separator; print '"'.self::toAnsi($line1).'"'.$this->separator;
// Tx2 // Tx2
print '"'.self::toAnsi($line2).'"'.$this->separator; print '"'.self::toAnsi($line2).'"'.$this->separator;
//PkKey //PkKey
print "0".$this->separator; print "0".$this->separator;
//OpId //OpId
print $this->separator; print $this->separator;
// Flag // Flag
print "0"; print "0";
print $this->end_line; print $this->end_line;
if ($line->piece_num !== $thisPieceNum) if ($line->piece_num !== $thisPieceNum)
{ {
$thisPieceNum = $line->piece_num; $thisPieceNum = $line->piece_num;
$thisPieceAccountNr = $line->numero_compte; $thisPieceAccountNr = $line->numero_compte;
} }
} }
} }
/** /**
* Export format : LD Compta version 9 * Export format : LD Compta version 9
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
* *
* @param array $objectLines data * @param array $objectLines data
* *
* @return void * @return void
*/ */
public function exportLDCompta($objectLines) public function exportLDCompta($objectLines)
{ {
@ -1168,23 +1169,23 @@ class AccountancyExport
{ {
$soc = $this->db->fetch_object($resql); $soc = $this->db->fetch_object($resql);
$address = array('', '', ''); $address = array('', '', '');
if (strpos($soc->address, "\n") !== false) { if (strpos($soc->address, "\n") !== false) {
$address = explode("\n", $soc->address); $address = explode("\n", $soc->address);
if (is_array($address) && count($address) > 0) { if (is_array($address) && count($address) > 0) {
foreach ($address as $key=>$data) { foreach ($address as $key=>$data) {
$address[$key] = str_replace(array("\t", "\n", "\r"), "", $data); $address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
$address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1); $address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
} }
} }
} else { } else {
$address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40); $address[0] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 0, 40);
$address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40); $address[1] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 41, 40);
$address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40); $address[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
} }
$type_enregistrement = 'C'; $type_enregistrement = 'C';
//TYPE //TYPE
print $type_enregistrement.$separator; print $type_enregistrement.$separator;
//NOCL //NOCL
print $soc->code_client.$separator; print $soc->code_client.$separator;
@ -1193,15 +1194,15 @@ class AccountancyExport
//LIBI //LIBI
print $separator; print $separator;
//TITR //TITR
print $separator; print $separator;
//RSSO //RSSO
print $soc->nom.$separator; print $soc->nom.$separator;
//CAD1 //CAD1
print $address[0].$separator; print $address[0].$separator;
//CAD2 //CAD2
print $address[1].$separator; print $address[1].$separator;
//CAD3 //CAD3
print $address[2].$separator; print $address[2].$separator;
//COPO //COPO
print $soc->zip.$separator; print $soc->zip.$separator;
//BUDI //BUDI
@ -1223,7 +1224,7 @@ class AccountancyExport
//COMM //COMM
print $separator; print $separator;
//SIRE //SIRE
print str_replace(" ", "", $soc->siret).$separator; print str_replace(" ", "", $soc->siret).$separator;
//RIBP //RIBP
print $separator; print $separator;
//DOBQ //DOBQ
@ -1486,15 +1487,15 @@ class AccountancyExport
* *
* @param string $str Original string to encode and optionaly truncate * @param string $str Original string to encode and optionaly truncate
* @param integer $size Truncate string after $size characters * @param integer $size Truncate string after $size characters
* @return string String encoded in Windows-1251 charset * @return string String encoded in Windows-1251 charset
*/ */
public static function toAnsi($str, $size = -1) public static function toAnsi($str, $size = -1)
{ {
$retVal = dol_string_nohtmltag($str, 1, 'Windows-1251'); $retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
if ($retVal >= 0 && $size >= 0) if ($retVal >= 0 && $size >= 0)
{ {
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251'); $retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
} }
return $retVal; return $retVal;
} }
} }

View File

@ -28,10 +28,10 @@
*/ */
class AccountancySystem class AccountancySystem
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
/** /**
* @var string Error code (or message) * @var string Error code (or message)
@ -44,13 +44,13 @@ class AccountancySystem
public $rowid; public $rowid;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_pcg_version; public $fk_pcg_version;
/** /**
* @var string pcg type * @var string pcg type
*/ */
public $pcg_type; public $pcg_type;
/** /**
@ -59,18 +59,18 @@ class AccountancySystem
public $numero; public $numero;
/** /**
* @var string Accountancy System label * @var string Accountancy System label
*/ */
public $label; public $label;
/** /**
* @var string account number * @var string account number
*/ */
public $account_number; public $account_number;
/** /**
* @var string account parent * @var string account parent
*/ */
public $account_parent; public $account_parent;
/** /**
@ -78,10 +78,10 @@ class AccountancySystem
* *
* @param DoliDB $db handler * @param DoliDB $db handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
@ -93,42 +93,42 @@ class AccountancySystem
*/ */
public function fetch($rowid = 0, $ref = '') public function fetch($rowid = 0, $ref = '')
{ {
global $conf; global $conf;
if ($rowid > 0 || $ref) if ($rowid > 0 || $ref)
{ {
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active"; $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a"; $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
$sql .= " WHERE"; $sql .= " WHERE";
if ($rowid) { if ($rowid) {
$sql .= " a.rowid = ".((int) $rowid); $sql .= " a.rowid = ".((int) $rowid);
} elseif ($ref) { } elseif ($ref) {
$sql .= " a.pcg_version = '".$this->db->escape($ref)."'"; $sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
} }
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($obj) { if ($obj) {
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->rowid = $obj->rowid; $this->rowid = $obj->rowid;
$this->pcg_version = $obj->pcg_version; $this->pcg_version = $obj->pcg_version;
$this->ref = $obj->pcg_version; $this->ref = $obj->pcg_version;
$this->label = $obj->label; $this->label = $obj->label;
$this->active = $obj->active; $this->active = $obj->active;
return $this->id; return $this->id;
} else { } else {
return 0; return 0;
} }
} else { } else {
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
$this->errors[] = "Error ".$this->db->lasterror(); $this->errors[] = "Error ".$this->db->lasterror();
} }
} }
return -1; return -1;
} }
@ -138,8 +138,8 @@ class AccountancySystem
* @param User $user making insert * @param User $user making insert
* @return int if KO, Id of line if OK * @return int if KO, Id of line if OK
*/ */
public function create($user) public function create($user)
{ {
$now = dol_now(); $now = dol_now();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
@ -165,6 +165,6 @@ class AccountancySystem
dol_syslog($this->error, LOG_ERR); dol_syslog($this->error, LOG_ERR);
} }
return $result; return $result;
} }
} }

View File

@ -74,35 +74,35 @@ class AccountingAccount extends CommonObject
public $rowid; public $rowid;
/** /**
* Date creation record (datec) * Date creation record (datec)
* *
* @var integer * @var integer
*/ */
public $datec; public $datec;
/** /**
* @var string pcg version * @var string pcg version
*/ */
public $fk_pcg_version; public $fk_pcg_version;
/** /**
* @var string pcg type * @var string pcg type
*/ */
public $pcg_type; public $pcg_type;
/** /**
* @var string account number * @var string account number
*/ */
public $account_number; public $account_number;
/** /**
* @var int ID parent account * @var int ID parent account
*/ */
public $account_parent; public $account_parent;
/** /**
* @var int ID category account * @var int ID category account
*/ */
public $account_category; public $account_category;
/** /**
@ -110,10 +110,10 @@ class AccountingAccount extends CommonObject
*/ */
public $status; public $status;
/** /**
* @var string Label of account * @var string Label of account
*/ */
public $label; public $label;
/** /**
* @var string Label short of account * @var string Label short of account
@ -121,19 +121,19 @@ class AccountingAccount extends CommonObject
public $labelshort; public $labelshort;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_author; public $fk_user_author;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_user_modif; public $fk_user_modif;
/** /**
* @var int active (duplicate with status) * @var int active (duplicate with status)
*/ */
public $active; public $active;
/** /**
* @var int reconcilable * @var int reconcilable
@ -145,13 +145,13 @@ class AccountingAccount extends CommonObject
* *
* @param DoliDB $db Database handle * @param DoliDB $db Database handle
*/ */
public function __construct($db) public function __construct($db)
{ {
global $conf; global $conf;
$this->db = $db; $this->db = $db;
$this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method $this->next_prev_filter = 'fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS.')'; // Used to add a filter in Form::showrefnav method
} }
/** /**
* Load record in memory * Load record in memory
@ -162,7 +162,7 @@ class AccountingAccount extends CommonObject
* @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code). * @param string $limittoachartaccount 'ABC'=Load record only if it is into chart account with code 'ABC' (better and faster than previous parameter if you have chart of account code).
* @return int <0 if KO, 0 if not found, Id of record if OK and found * @return int <0 if KO, 0 if not found, Id of record if OK and found
*/ */
public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '') public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0, $limittoachartaccount = '')
{ {
global $conf; global $conf;
@ -182,7 +182,7 @@ class AccountingAccount extends CommonObject
$sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')'; $sql .= ' AND a.fk_pcg_version IN (SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$this->db->escape($conf->global->CHARTOFACCOUNTS).')';
} }
if (!empty($limittoachartaccount)) { if (!empty($limittoachartaccount)) {
$sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'"; $sql .= " AND a.fk_pcg_version = '".$this->db->escape($limittoachartaccount)."'";
} }
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
@ -229,8 +229,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger Disable triggers * @param int $notrigger Disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function create($user, $notrigger = 0) public function create($user, $notrigger = 0)
{ {
global $conf; global $conf;
$error = 0; $error = 0;
$now = dol_now(); $now = dol_now();
@ -318,7 +318,7 @@ class AccountingAccount extends CommonObject
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} }
} }
/** /**
* Update record * Update record
@ -366,8 +366,8 @@ class AccountingAccount extends CommonObject
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function checkUsage() public function checkUsage()
{ {
global $langs; global $langs;
$sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet"; $sql = "(SELECT fk_code_ventilation FROM ".MAIN_DB_PREFIX."facturedet";
@ -400,8 +400,8 @@ class AccountingAccount extends CommonObject
* @param int $notrigger 0=triggers after, 1=disable triggers * @param int $notrigger 0=triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function delete($user, $notrigger = 0) public function delete($user, $notrigger = 0)
{ {
$error = 0; $error = 0;
$result = $this->checkUsage(); $result = $this->checkUsage();
@ -436,9 +436,9 @@ class AccountingAccount extends CommonObject
} else { } else {
return -1; return -1;
} }
} }
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
@ -446,12 +446,12 @@ class AccountingAccount extends CommonObject
* @param int $nourl 1=Disable url * @param int $nourl 1=Disable url
* @param string $moretitle Add more text to title tooltip * @param string $moretitle Add more text to title tooltip
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label) * @param int $withcompletelabel 0=Short label (field short label), 1=Complete label (field label)
* @param string $option 'ledger', 'journals', 'accountcard' * @param string $option 'ledger', 'journals', 'accountcard'
* @return string String with URL * @return string String with URL
*/ */
public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '') public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1, $withcompletelabel = 0, $option = '')
{ {
global $langs, $conf; global $langs, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
@ -524,7 +524,7 @@ class AccountingAccount extends CommonObject
if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto && $withpicto != 2) $result .= ' ';
if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend; if ($withpicto != 2) $result .= $linkstart.$label_link.$linkend;
return $result; return $result;
} }
/** /**
* Information on record * Information on record
@ -532,8 +532,8 @@ class AccountingAccount extends CommonObject
* @param int $id of record * @param int $id of record
* @return void * @return void
*/ */
public function info($id) public function info($id)
{ {
$sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms';
$sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a'; $sql .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a';
$sql .= ' WHERE a.rowid = '.$id; $sql .= ' WHERE a.rowid = '.$id;
@ -568,18 +568,18 @@ class AccountingAccount extends CommonObject
* Deactivate an account (for status active or status reconcilable) * Deactivate an account (for status active or status reconcilable)
* *
* @param int $id Id * @param int $id Id
* @param int $mode 0=field active, 1=field reconcilable * @param int $mode 0=field active, 1=field reconcilable
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function accountDeactivate($id, $mode = 0) public function accountDeactivate($id, $mode = 0)
{ {
$result = $this->checkUsage(); $result = $this->checkUsage();
$fieldtouse = 'active'; $fieldtouse = 'active';
if ($mode == 1) if ($mode == 1)
{ {
$fieldtouse = 'reconcilable'; $fieldtouse = 'reconcilable';
} }
if ($result > 0) { if ($result > 0) {
$this->db->begin(); $this->db->begin();
@ -604,26 +604,26 @@ class AccountingAccount extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Account activated * Account activated
* *
* @param int $id Id * @param int $id Id
* @param int $mode 0=field active, 1=field reconcilable * @param int $mode 0=field active, 1=field reconcilable
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function account_activate($id, $mode = 0) public function account_activate($id, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
$this->db->begin(); $this->db->begin();
if ($mode == 0) if ($mode == 0)
{ {
$fieldtouse = 'active'; $fieldtouse = 'active';
} elseif ($mode == 1) } elseif ($mode == 1)
{ {
$fieldtouse = 'reconcilable'; $fieldtouse = 'reconcilable';
} }
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account "; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
$sql .= "SET ".$fieldtouse." = '1'"; $sql .= "SET ".$fieldtouse." = '1'";
@ -631,15 +631,15 @@ class AccountingAccount extends CommonObject
dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} }
/** /**
@ -653,7 +653,7 @@ class AccountingAccount extends CommonObject
return $this->LibStatut($this->status, $mode); return $this->LibStatut($this->status, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
@ -663,7 +663,7 @@ class AccountingAccount extends CommonObject
*/ */
public function LibStatut($status, $mode = 0) public function LibStatut($status, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->loadLangs(array("users")); $langs->loadLangs(array("users"));

View File

@ -56,29 +56,29 @@ class AccountingJournal extends CommonObject
*/ */
public $rowid; public $rowid;
/** /**
* @var string Accounting journal code * @var string Accounting journal code
*/ */
public $code; public $code;
/** /**
* @var string Accounting Journal label * @var string Accounting Journal label
*/ */
public $label; public $label;
/** /**
* @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new * @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
*/ */
public $nature; public $nature;
/** /**
* @var int is active or not * @var int is active or not
*/ */
public $active; public $active;
/** /**
* @var array array of lines * @var array array of lines
*/ */
public $lines; public $lines;
/** /**
@ -86,10 +86,10 @@ class AccountingJournal extends CommonObject
* *
* @param DoliDB $db Database handle * @param DoliDB $db Database handle
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Load an object from database * Load an object from database
@ -155,8 +155,8 @@ class AccountingJournal extends CommonObject
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{ {
$sql = "SELECT rowid, code, label, nature, active"; $sql = "SELECT rowid, code, label, nature, active";
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
// Manage filter // Manage filter
@ -284,7 +284,7 @@ class AccountingJournal extends CommonObject
return $this->LibType($this->nature, $mode); return $this->LibType($this->nature, $mode);
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Return type of an accounting journal * Return type of an accounting journal
* *
@ -294,7 +294,7 @@ class AccountingJournal extends CommonObject
*/ */
public function LibType($nature, $mode = 0) public function LibType($nature, $mode = 0)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->loadLangs(array("accountancy")); $langs->loadLangs(array("accountancy"));

View File

@ -768,10 +768,11 @@ class BookKeeping extends CommonObject
* @param int $offset offset limit * @param int $offset offset limit
* @param array $filter filter array * @param array $filter filter array
* @param string $filtermode filter mode (AND or OR) * @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 * @return int <0 if KO, >=0 if OK
*/ */
public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') public function fetchAllByAccount($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND', $option = 0)
{ {
global $conf; global $conf;
@ -836,7 +837,13 @@ class BookKeeping extends CommonObject
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere); $sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
} }
// Affichage par compte comptable // Affichage par compte comptable
$sql .= ' ORDER BY t.numero_compte ASC'; if (!empty($option)) {
$sql .= ' AND t.subledger_account IS NOT NULL';
$sql .= ' ORDER BY t.subledger_account ASC';
} else {
$sql .= ' ORDER BY t.numero_compte ASC';
}
if (!empty($sortfield)) { if (!empty($sortfield)) {
$sql .= ', '.$sortfield.' '.$sortorder; $sql .= ', '.$sortfield.' '.$sortorder;
} }

View File

@ -63,24 +63,24 @@ $year_current = $year_start;
if ($action == 'validate') if ($action == 'validate')
{ {
$now = dol_now(); $now = dol_now();
// Update database // Update database
$db->begin(); $db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b"; $sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '".$db->idate($now)."'"; $sql .= " SET b.date_validated = '".$db->idate($now)."'";
$sql .= ' WHERE b.date_validated IS NULL'; $sql .= ' WHERE b.date_validated IS NULL';
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG); dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql1) { if (!$resql1) {
$error++; $error++;
$db->rollback(); $db->rollback();
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
$db->commit(); $db->commit();
} }
// End clean database // End clean database
} }
@ -135,8 +135,8 @@ if ($resql) {
while ($row = $db->fetch_row($resql)) { while ($row = $db->fetch_row($resql)) {
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap center">'.$row[$i].'<br><br>'; print '<td class="nowrap center">'.$row[$i].'<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
print '</td>'; print '</td>';
} }
print '<td class="valigntop"><b>'.$row[13].'</b></td>'; print '<td class="valigntop"><b>'.$row[13].'</b></td>';
} }

View File

@ -50,7 +50,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
{ {
if (!$cancel) if (!$cancel)
{ {
if ($codeventil < 0) $codeventil = 0; if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
$sql .= " SET fk_code_ventilation = ".$codeventil; $sql .= " SET fk_code_ventilation = ".$codeventil;
@ -60,12 +60,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
if (!$resql) { if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit(); exit();
} }
} }
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");

View File

@ -357,12 +357,6 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
$objecttmp=new Project($db);
$trackid='prj'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/
if ($msg) print $msg.'<br>'; if ($msg) print $msg.'<br>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -285,12 +285,6 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoExpenseReport").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
$objecttmp=new Project($db);
$trackid='prj'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/
if ($msg) print $msg.'<br>'; if ($msg) print $msg.'<br>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -45,14 +45,14 @@ $hookmanager->initHooks(array('accountancyindex'));
if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled) if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled)
{ {
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone = GETPOST('areacode', 'aZ09'); $zone = GETPOST('areacode', 'aZ09');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
$boxorder = GETPOST('boxorder', 'aZ09'); $boxorder = GETPOST('boxorder', 'aZ09');
$boxorder .= GETPOST('boxcombo', 'aZ09'); $boxorder .= GETPOST('boxcombo', 'aZ09');
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid); $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null); if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
} }
@ -64,11 +64,11 @@ llxHeader('', $langs->trans("AccountancyArea"));
if ($conf->accounting->enabled) if ($conf->accounting->enabled)
{ {
$step = 0; $step = 0;
$resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb) $resultboxes = FormOther::getBoxesArea($user, "27"); // Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
$helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default. $helpisexpanded = empty($resultboxes['boxactivated']) || (empty($resultboxes['boxlista']) && empty($resultboxes['boxlistb'])); // If there is no widget, the tooltip help is expanded by default.
$showtutorial = ''; $showtutorial = '';
if (!$helpisexpanded) if (!$helpisexpanded)
@ -92,9 +92,9 @@ if ($conf->accounting->enabled)
print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial); print load_fiche_titre($langs->trans("AccountancyArea"), $resultboxes['selectboxlist'], 'title_accountancy', 0, '', '', $showtutorial);
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
print "<br>\n"; print "<br>\n";
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
print "<br>\n"; print "<br>\n"; print "<br>\n"; print "<br>\n";
print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n"; print load_fiche_titre('<span class="fa fa-calendar-check-o"></span> '.$langs->trans("AccountancyAreaDescActionOnce"), '', '')."\n";
@ -132,9 +132,9 @@ if ($conf->accounting->enabled)
if (!empty($conf->tax->enabled)) if (!empty($conf->tax->enabled))
{ {
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>'; $textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
print "<br>\n"; print "<br>\n";
} }
/*if (! empty($conf->salaries->enabled)) /*if (! empty($conf->salaries->enabled))
{ {
@ -146,9 +146,9 @@ if ($conf->accounting->enabled)
}*/ }*/
if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. if (!empty($conf->expensereport->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several.
{ {
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>'); print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescExpenseReport", $step, '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=17&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuExpenseReportAccounts").'</strong></a>');
print "<br>\n"; print "<br>\n";
} }
/* /*
if (! empty($conf->loan->enabled)) if (! empty($conf->loan->enabled))
@ -177,7 +177,7 @@ if ($conf->accounting->enabled)
print '<br>'; print '<br>';
// Step A - E // Step A - E
print "<br>\n"; print "<br>\n";
print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', ''); print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
@ -199,7 +199,7 @@ if ($conf->accounting->enabled)
{ {
$step++; $step++;
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>')."\n"; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBind", chr(64 + $step), $langs->transnoentitiesnoconv("ExpenseReports"), '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/index.php"><strong>'.$langs->transnoentitiesnoconv("TransferInAccounting").' - '.$langs->transnoentitiesnoconv("ExpenseReportsVentilation").'</strong></a>')."\n";
print "<br>\n"; print "<br>\n";
} }
$step++; $step++;
@ -214,36 +214,36 @@ if ($conf->accounting->enabled)
print '</div>'; print '</div>';
print '<div class="clearboth"></div>'; print '<div class="clearboth"></div>';
print '<div class="fichecenter fichecenterbis">'; print '<div class="fichecenter fichecenterbis">';
/* /*
* Show boxes * Show boxes
*/ */
$boxlist .= '<div class="twocolumns">'; $boxlist .= '<div class="twocolumns">';
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">'; $boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
$boxlist .= $resultboxes['boxlista']; $boxlist .= $resultboxes['boxlista'];
$boxlist .= '</div>'; $boxlist .= '</div>';
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">'; $boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
$boxlist .= $resultboxes['boxlistb']; $boxlist .= $resultboxes['boxlistb'];
$boxlist .= '</div>'; $boxlist .= '</div>';
$boxlist .= "\n"; $boxlist .= "\n";
$boxlist .= '</div>'; $boxlist .= '</div>';
print $boxlist; print $boxlist;
print '</div>'; print '</div>';
} else { } else {
print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy'); print load_fiche_titre($langs->trans("AccountancyArea"), '', 'accountancy');
print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span><br>\n"; print '<span class="opacitymedium">'.$langs->trans("Module10Desc")."</span><br>\n";
} }

View File

@ -394,9 +394,9 @@ if ($result) {
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id; $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
$paymentvariousstatic->fetch($paymentvariousstatic->id); $paymentvariousstatic->fetch($paymentvariousstatic->id);
$account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word
$account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word
$tabpay[$obj->rowid]["account_various"] = $account_various; $tabpay[$obj->rowid]["account_various"] = $account_various;
$tabtp[$obj->rowid][$account_subledger] += $obj->amount; $tabtp[$obj->rowid][$account_subledger] += $obj->amount;
} elseif ($links[$key]['type'] == 'payment_loan') { } elseif ($links[$key]['type'] == 'payment_loan') {
$paymentloanstatic->id = $links[$key]['url_id']; $paymentloanstatic->id = $links[$key]['url_id'];
$paymentloanstatic->ref = $links[$key]['url_id']; $paymentloanstatic->ref = $links[$key]['url_id'];
@ -668,7 +668,7 @@ if (!$error && $action == 'writebookkeeping') {
$bookkeeping->label_compte = $accountingaccount->label; $bookkeeping->label_compte = $accountingaccount->label;
} elseif ($tabtype[$key] == 'payment_various') { } elseif ($tabtype[$key] == 'payment_various') {
$bookkeeping->subledger_account = $k; $bookkeeping->subledger_account = $k;
$bookkeeping->subledger_label = $tabcompany[$key]['name']; $bookkeeping->subledger_label = $tabcompany[$key]['name'];
$bookkeeping->numero_compte = $tabpay[$key]["account_various"]; $bookkeeping->numero_compte = $tabpay[$key]["account_various"];
$accountingaccount->fetch(null, $bookkeeping->numero_compte, true); $accountingaccount->fetch(null, $bookkeeping->numero_compte, true);
@ -854,7 +854,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["type_payment"].'"'.$sep; print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print " ".$sep; print " ".$sep;
print '"'.$reflabel.'"'.$sep; print '"'.$reflabel.'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
@ -882,7 +882,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$key.'"'.$sep; print '"'.$key.'"'.$sep;
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["type_payment"].'"'.$sep; print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
if ($tabtype[$key] == 'payment_supplier') { if ($tabtype[$key] == 'payment_supplier') {
print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep; print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
} elseif ($tabtype[$key] == 'payment') { } elseif ($tabtype[$key] == 'payment') {
@ -892,7 +892,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
} elseif ($tabtype[$key] == 'payment_salary') { } elseif ($tabtype[$key] == 'payment_salary') {
print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep; print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
} else { } else {
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
} }
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.$reflabel.'"'.$sep; print '"'.$reflabel.'"'.$sep;
@ -915,7 +915,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["type_payment"].'"'.$sep; print '"'.$val["type_payment"].'"'.$sep;
print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print '"'.length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep; print '"'.length_accounta($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
print "".$sep; print "".$sep;
print '"'.$reflabel.'"'.$sep; print '"'.$reflabel.'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
@ -954,8 +954,8 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal='.$id_journal; $varlink = 'id_journal='.$id_journal;
@ -991,11 +991,11 @@ if (empty($action) || $action == 'view') {
if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />'; if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1' if (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1'
|| ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') { || ($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == "") || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />'; print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
} else { } else {
if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />'; if ($in_bookkeeping == 'notyet') print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>'; else print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
} }
print '</div>'; print '</div>';
@ -1115,7 +1115,7 @@ if (empty($action) || $action == 'view') {
if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT; if ($tabtype[$key] == 'payment_vat') $account_ledger = $conf->global->ACCOUNTING_VAT_PAY_ACCOUNT;
if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT; if ($tabtype[$key] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT;
if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"]; if ($tabtype[$key] == 'payment_various') $account_ledger = $tabpay[$key]["account_various"];
$accounttoshow = length_accounta($account_ledger); $accounttoshow = length_accountg($account_ledger);
if (empty($accounttoshow) || $accounttoshow == 'NotDefined') if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
{ {
if ($tabtype[$key] == 'unknown') if ($tabtype[$key] == 'unknown')

View File

@ -110,11 +110,11 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
// Already in bookkeeping or not // Already in bookkeeping or not
if ($in_bookkeeping == 'already') if ($in_bookkeeping == 'already')
{ {
$sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
} }
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet')
{ {
$sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')"; $sql .= " AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
} }
$sql .= " ORDER BY er.date_debut"; $sql .= " ORDER BY er.date_debut";
@ -370,8 +370,8 @@ if ($action == 'writebookkeeping') {
if ($error >= 10) if ($error >= 10)
{ {
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors'); setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
break; // Break in the foreach break; // Break in the foreach
} }
} }
} }
@ -433,48 +433,48 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print "\n"; print "\n";
foreach ($taber as $key => $val) { foreach ($taber as $key => $val) {
$date = dol_print_date($val["date"], 'day'); $date = dol_print_date($val["date"], 'day');
$userstatic->id = $tabuser[$key]['id']; $userstatic->id = $tabuser[$key]['id'];
$userstatic->name = $tabuser[$key]['name']; $userstatic->name = $tabuser[$key]['name'];
// Fees // Fees
foreach ($tabht[$key] as $k => $mt) { foreach ($tabht[$key] as $k => $mt) {
$accountingaccount = new AccountingAccount($db); $accountingaccount = new AccountingAccount($db);
$accountingaccount->fetch(null, $k, true); $accountingaccount->fetch(null, $k, true);
if ($mt) { if ($mt) {
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep; print '"'.$val["ref"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep; print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'; print '"'.($mt < 0 ? price(-$mt) : '').'"';
print "\n"; print "\n";
} }
} }
// VAT // VAT
foreach ($tabtva[$key] as $k => $mt) { foreach ($tabtva[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep; print '"'.$val["ref"].'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep; print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'; print '"'.($mt < 0 ? price(-$mt) : '').'"';
print "\n"; print "\n";
} }
} }
// Third party // Third party
foreach ($tabttc[$key] as $k => $mt) { foreach ($tabttc[$key] as $k => $mt) {
print '"'.$date.'"'.$sep; print '"'.$date.'"'.$sep;
print '"'.$val["ref"].'"'.$sep; print '"'.$val["ref"].'"'.$sep;
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep; print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
print '"'.dol_trunc($userstatic->name).'"'.$sep; print '"'.dol_trunc($userstatic->name).'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'; print '"'.($mt >= 0 ? price($mt) : '').'"';
} }
print "\n"; print "\n";
} }
} }
@ -489,8 +489,8 @@ if (empty($action) || $action == 'view') {
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>'; $description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal='.$id_journal; $varlink = 'id_journal='.$id_journal;

View File

@ -669,7 +669,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$sep; print '""'.$sep;
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].'"'.$sep; print '"'.$langs->trans("VAT").' - '.join(', ', $def_tva[$key][$k]).' %"'.$sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$val["refsuppliersologest"].' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
@ -719,8 +719,8 @@ if (empty($action) || $action == 'view') {
} }
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal='.$id_journal; $varlink = 'id_journal='.$id_journal;

View File

@ -130,7 +130,7 @@ if ($in_bookkeeping == 'already')
if ($in_bookkeeping == 'notyet') if ($in_bookkeeping == 'notyet')
{ {
$sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; $sql .= " AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
// $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account // $sql .= " AND fd.rowid NOT IN (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')"; // Useless, we save one line for all products with same account
} }
$sql .= " ORDER BY f.datef"; $sql .= " ORDER BY f.datef";
//print $sql; //print $sql;
@ -621,18 +621,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
foreach ($arrayofvat[$key] as $k => $mt) { foreach ($arrayofvat[$key] as $k => $mt) {
if ($mt) { if ($mt) {
print '"'.$key.'"'.$sep; print '"' . $key . '"' . $sep;
print '"'.$date.'"'.$sep; print '"' . $date . '"' . $sep;
print '"'.$val["ref"].'"'.$sep; print '"' . $val["ref"] . '"' . $sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep; print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
print '""'.$sep; print '""' . $sep;
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$sep; print '"' . $langs->trans("VAT") . ' - ' . join(', ', $def_tva[$key][$k]) . ' %"' . $sep;
print '"'.utf8_decode(dol_trunc($companystatic->name, 16)).' - '.$invoicestatic->ref.' - '.$langs->trans("VAT").join(', ', $def_tva[$key][$k]).' %'.($numtax ? ' - Localtax '.$numtax : '').'"'.$sep; print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ', $def_tva[$key][$k]) . ' %' . ($numtax ? ' - Localtax ' . $numtax : '') . '"' . $sep;
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep; print '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep;
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep; print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
print '"'.$journal.'"'; print '"' . $journal . '"';
print "\n"; print "\n";
} }
} }
@ -658,8 +658,8 @@ if (empty($action) || $action == 'view') {
} }
$listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger")); $listofchoices = array('notyet'=>$langs->trans("NotYetInGeneralLedger"), 'already'=>$langs->trans("AlreadyInGeneralLedger"));
$period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0); $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
$period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1); $period .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
$varlink = 'id_journal='.$id_journal; $varlink = 'id_journal='.$id_journal;

View File

@ -54,7 +54,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
{ {
if (!$cancel) if (!$cancel)
{ {
if ($codeventil < 0) $codeventil = 0; if ($codeventil < 0) $codeventil = 0;
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det"; $sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
$sql .= " SET fk_code_ventilation = ".$codeventil; $sql .= " SET fk_code_ventilation = ".$codeventil;
@ -64,12 +64,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
if (!$resql) { if (!$resql) {
setEventMessages($db->lasterror(), null, 'errors'); setEventMessages($db->lasterror(), null, 'errors');
} else { } else {
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs'); setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit(); exit();
} }
} }
} else { } else {
header("Location: ./lines.php"); header("Location: ./lines.php");

View File

@ -358,12 +358,6 @@ if ($result) {
print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilTodoCustomer").'</span></br><br>';
/*$topicmail="Information";
$modelmail="project";
$objecttmp=new Project($db);
$trackid='prj'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';*/
if ($msg) print $msg.'<br>'; if ($msg) print $msg.'<br>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -7,7 +7,8 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org> * Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,7 +40,12 @@ $langs->loadLangs(array("admin", "members"));
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
$type = array('yesno', 'texte', 'chaine'); $choices = array('yesno', 'texte', 'chaine');
$value = GETPOST('value', 'alpha');
$label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha');
$type = 'member';
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -48,29 +54,71 @@ $action = GETPOST('action', 'aZ09');
* Actions * Actions
*/ */
// include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'updateall') {
$db->begin(); if ($action == 'set_default') {
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0; $ret = addDocumentModel($value, $type, $label, $scandir);
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity); $res = true;
$res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'del_default') {
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity); $ret = delDocumentModel($value, $type);
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); if ($ret > 0) {
// Use vat for invoice creation if ($conf->global->MEMBER_ADDON_PDF_ODT == "$value") {
if ($conf->facture->enabled) { dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity);
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); }
$res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); }
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $res = true;
$res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); } elseif ($action == 'setdoc') {
} // Set default model
} if (dolibarr_set_const($db, "MEMBER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) {
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) { // La constante qui a ete lue en avant du nouveau set
setEventMessages('ErrorFailedToSaveDate', null, 'errors'); // on passe donc par une variable pour avoir un affichage coherent
$db->rollback(); $conf->global->MEMBER_ADDON_PDF_ODT = $value;
} else { }
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit(); // On active le modele
} $ret = delDocumentModel($value, $type);
if ($ret > 0) {
$ret = addDocumentModel($value, $type, $label, $scandir);
}
$res = true;
} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
dol_print_error($db);
}
} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
$code = $reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
dol_print_error($db);
}
} elseif ($action == 'updateall') {
$db->begin();
$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
$res1 = dolibarr_set_const($db, 'ADHERENT_LOGIN_NOT_REQUIRED', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha') ? 0 : 1, 'chaine', 0, '', $conf->entity);
$res2 = dolibarr_set_const($db, 'ADHERENT_MAIL_REQUIRED', GETPOST('ADHERENT_MAIL_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
$res3 = dolibarr_set_const($db, 'ADHERENT_DEFAULT_SENDINFOBYMAIL', GETPOST('ADHERENT_DEFAULT_SENDINFOBYMAIL', 'alpha'), 'chaine', 0, '', $conf->entity);
$res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity);
// Use vat for invoice creation
if ($conf->facture->enabled) {
$res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
$res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) {
$res6 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity);
}
}
if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
setEventMessages('ErrorFailedToSaveDate', null, 'errors');
$db->rollback();
} else {
setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
$db->commit();
}
} }
// Action to update or add a constant // Action to update or add a constant
@ -86,7 +134,7 @@ if ($action == 'update' || $action == 'add') {
$consttype = GETPOST('consttype', 'alpha'); $consttype = GETPOST('consttype', 'alpha');
$constnote = GETPOST('constnote'); $constnote = GETPOST('constnote');
$res = dolibarr_set_const($db, $constname, $constvalue, $type[$consttype], 0, $constnote, $conf->entity); $res = dolibarr_set_const($db, $constname, $constvalue, $choices[$consttype], 0, $constnote, $conf->entity);
if (!$res > 0) $error++; if (!$res > 0) $error++;
@ -99,18 +147,18 @@ if ($action == 'update' || $action == 'add') {
// Action to enable of a submodule of the adherent module // Action to enable of a submodule of the adherent module
if ($action == 'set') { if ($action == 'set') {
$result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity); $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
if ($result < 0) { if ($result < 0) {
print $db->error(); print $db->error();
} }
} }
// Action to disable a submodule of the adherent module // Action to disable a submodule of the adherent module
if ($action == 'unset') { if ($action == 'unset') {
$result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity); $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
if ($result < 0) { if ($result < 0) {
print $db->error(); print $db->error();
} }
} }
@ -169,7 +217,7 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty(
print '<td>'; print '<td>';
print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0); print $form->selectarray('ADHERENT_BANK_USE', $arraychoices, $conf->global->ADHERENT_BANK_USE, 0);
if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') { if ($conf->global->ADHERENT_BANK_USE == 'bankdirect' || $conf->global->ADHERENT_BANK_USE == 'bankviainvoice') {
print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>'; print '<br><div style="padding-top: 5px;"><span class="opacitymedium">'.$langs->trans("ABankAccountMustBeDefinedOnPaymentModeSetup").'</span></div>';
} }
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
@ -245,6 +293,137 @@ $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL_
$helptext .= '__YEAR__, __MONTH__, __DAY__'; $helptext .= '__YEAR__, __MONTH__, __DAY__';
form_constantes($constantes, 0, $helptext); form_constantes($constantes, 0, $helptext);
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
// Defini tableau def des modeles
$def = array();
$sql = "SELECT nom";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows) {
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
} else {
dol_print_error($db);
}
print load_fiche_titre($langs->trans("MembersDocModules"), '', '');
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) {
$dir = dol_buildpath($reldir."core/modules/member".$valdir);
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file) {
if (preg_match('/\.class\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 14);
$classname = substr($file, 0, dol_strlen($file) - 10);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) {
print $module->info($langs);
} else {
print $module->description;
}
print '</td>';
// Active
if (in_array($name, $def)) {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
} else {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
// Defaut
print '<td class="center">';
if ($conf->global->MEMBER_ADDON_PDF == $name) {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
}
print '</td>';
print "</tr>\n";
}
}
}
}
}
}
}
}
print '</table>';
print "<br>";
print dol_get_fiche_end(); print dol_get_fiche_end();

View File

@ -95,7 +95,7 @@ if ($action == 'create') {
print '<div name="topofform"></div><br>'; print '<div name="topofform"></div><br>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -107,7 +107,7 @@ if ($action == 'edit' && !empty($attrname)) {
print '<div name="topofform"></div><br>'; print '<div name="topofform"></div><br>';
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
} }
// End of page // End of page

View File

@ -54,22 +54,22 @@ if ($action == 'update') {
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE'); $payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE'); $forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE');
$res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC", $public, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT", $amount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT", $editamount, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE", $payonline, 'chaine', 0, '', $conf->entity);
if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity); if ($forcetype < 0) $res = dolibarr_del_const($db, "MEMBER_NEWFORM_FORCETYPE", $conf->entity);
else { else {
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
} }
if (!$res > 0) $error++; if (!$res > 0) $error++;
if (!$error) { if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
@ -97,8 +97,8 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user'); print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print "\n".'<script type="text/javascript" language="javascript">'; print "\n".'<script type="text/javascript" language="javascript">';
print 'jQuery(document).ready(function () { print 'jQuery(document).ready(function () {
function initemail() function initemail()
{ {
if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\') if (jQuery("#MEMBER_NEWFORM_PAYONLINE").val()==\'-1\')
@ -127,7 +127,7 @@ if ($conf->use_javascript_ajax) {
jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); }); jQuery("#MEMBER_ENABLE_PUBLIC").change(function() { initfields(); });
jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); }); jQuery("#MEMBER_NEWFORM_PAYONLINE").change(function() { initemail(); });
})'; })';
print '</script>'."\n"; print '</script>'."\n";
} }

View File

@ -65,8 +65,8 @@ $result = $object->fetch($id);
if ($result > 0) { if ($result > 0) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$adht = new AdherentType($db); $adht = new AdherentType($db);
$result = $adht->fetch($object->typeid); $result = $adht->fetch($object->typeid);
} }
@ -79,17 +79,17 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook)) {
// Cancel // Cancel
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
header("Location: ".$backtopage); header("Location: ".$backtopage);
exit; exit;
} }
// Purge search criteria // Purge search criteria
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 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
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
} }
@ -136,31 +136,31 @@ if ($object->id > 0) {
print dol_get_fiche_end(); print dol_get_fiche_end();
//print '<div class="tabsAction">'; //print '<div class="tabsAction">';
//print '</div>'; //print '</div>';
$newcardbutton = ''; $newcardbutton = '';
if (!empty($conf->agenda->enabled)) { if (!empty($conf->agenda->enabled)) {
$newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id); $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id);
} }
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
print '<br>'; print '<br>';
$param = '&id='.$id; $param = '&id='.$id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1); print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', '', $newcardbutton, '', 0, 1, 1);
// List of all actions // List of all actions
$filters = array(); $filters = array();
$filters['search_agenda_label'] = $search_agenda_label; $filters['search_agenda_label'] = $search_agenda_label;
// TODO Replace this with same code than into list.php // TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
} }
} }
// End of page // End of page

View File

@ -27,15 +27,15 @@
*/ */
abstract class ActionsAdherentCardCommon abstract class ActionsAdherentCardCommon
{ {
/** /**
* @var DoliDB Database handler. * @var DoliDB Database handler.
*/ */
public $db; public $db;
public $dirmodule; public $dirmodule;
public $targetmodule; public $targetmodule;
public $canvas; public $canvas;
public $card; public $card;
//! Template container //! Template container
public $tpl = array(); public $tpl = array();
@ -54,52 +54,52 @@ abstract class ActionsAdherentCardCommon
/** /**
* Get object * Get object
* *
* @param int $id Object id * @param int $id Object id
* @return object Object loaded * @return object Object loaded
*/ */
public function getObject($id) public function getObject($id)
{ {
//$ret = $this->getInstanceDao(); //$ret = $this->getInstanceDao();
/*if (is_object($this->object) && method_exists($this->object,'fetch')) /*if (is_object($this->object) && method_exists($this->object,'fetch'))
{ {
if (! empty($id)) $this->object->fetch($id); if (! empty($id)) $this->object->fetch($id);
} }
else else
{*/ {*/
$object = new Adherent($this->db); $object = new Adherent($this->db);
if (!empty($id)) $object->fetch($id); if (!empty($id)) $object->fetch($id);
$this->object = $object; $this->object = $object;
//} //}
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Set content of ->tpl array, to use into template * Set content of ->tpl array, to use into template
* *
* @param string $action Type of action * @param string $action Type of action
* @param int $id Id * @param int $id Id
* @return string HTML output * @return string HTML output
*/ */
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs, $user, $canvas; global $conf, $langs, $user, $canvas;
global $form, $formcompany, $objsoc; global $form, $formcompany, $objsoc;
if ($action == 'add' || $action == 'update') $this->assign_post(); if ($action == 'add' || $action == 'update') $this->assign_post();
foreach ($this->object as $key => $value) { foreach ($this->object as $key => $value) {
$this->tpl[$key] = $value; $this->tpl[$key] = $value;
} }
$this->tpl['error'] = $this->error; $this->tpl['error'] = $this->error;
$this->tpl['errors'] = $this->errors; $this->tpl['errors'] = $this->errors;
if ($action == 'create' || $action == 'edit') { if ($action == 'create' || $action == 'edit') {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript"> $this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
jQuery(document).ready(function () { jQuery(document).ready(function () {
jQuery("#selectcountry_id").change(function() { jQuery("#selectcountry_id").change(function() {
@ -111,153 +111,153 @@ abstract class ActionsAdherentCardCommon
</script>'."\n"; </script>'."\n";
} }
if (is_object($objsoc) && $objsoc->id > 0) { if (is_object($objsoc) && $objsoc->id > 0) {
$this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company'] = $objsoc->getNomUrl(1);
$this->tpl['company_id'] = $objsoc->id; $this->tpl['company_id'] = $objsoc->id;
} else { } else {
$this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1); $this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1);
} }
// Civility // Civility
$this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id); $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
// Predefined with third party // Predefined with third party
if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) { if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE')) {
if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address;
if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip;
if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town; if (dol_strlen(trim($this->object->town)) == 0) $this->object->town = $objsoc->town;
if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone; if (dol_strlen(trim($this->object->phone_perso)) == 0) $this->object->phone_perso = $objsoc->phone;
if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile; if (dol_strlen(trim($this->object->phone_mobile)) == 0) $this->object->phone_mobile = $objsoc->phone_mobile;
if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email; if (dol_strlen(trim($this->object->email)) == 0) $this->object->email = $objsoc->email;
} }
// Zip // Zip
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6); $this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
// Town // Town
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id')); $this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id; if (dol_strlen(trim($this->object->country_id)) == 0) $this->object->country_id = $objsoc->country_id;
// Country // Country
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id'); $this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); if ($user->admin) $this->tpl['info_admin'] = info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
// State // State
if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code); if ($this->object->country_id) $this->tpl['select_state'] = $formcompany->select_state($this->object->state_id, $this->object->country_code);
else $this->tpl['select_state'] = $countrynotdefined; else $this->tpl['select_state'] = $countrynotdefined;
// Physical or Moral // Physical or Moral
$selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral")); $selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
$this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0); $this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0);
} }
if ($action == 'view' || $action == 'edit' || $action == 'delete') { if ($action == 'view' || $action == 'edit' || $action == 'delete') {
// Emailing // Emailing
if (!empty($conf->mailing->enabled)) { if (!empty($conf->mailing->enabled)) {
$langs->load("mails"); $langs->load("mails");
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings(); $this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
} }
// Dolibarr user // Dolibarr user
if ($this->object->user_id) { if ($this->object->user_id) {
$dolibarr_user = new User($this->db); $dolibarr_user = new User($this->db);
$result = $dolibarr_user->fetch($this->object->user_id); $result = $dolibarr_user->fetch($this->object->user_id);
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1); $this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
} else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess"); } else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
} }
if ($action == 'view' || $action == 'delete') { if ($action == 'view' || $action == 'delete') {
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id'); $this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
if ($this->object->socid > 0) { if ($this->object->socid > 0) {
$objsoc = new Societe($this->db); $objsoc = new Societe($this->db);
$objsoc->fetch($this->object->socid); $objsoc->fetch($this->object->socid);
$this->tpl['company'] = $objsoc->getNomUrl(1); $this->tpl['company'] = $objsoc->getNomUrl(1);
} else { } else {
$this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty"); $this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty");
} }
$this->tpl['civility'] = $this->object->getCivilityLabel(); $this->tpl['civility'] = $this->object->getCivilityLabel();
$this->tpl['address'] = dol_nl2br($this->object->address); $this->tpl['address'] = dol_nl2br($this->object->address);
$this->tpl['zip'] = ($this->object->zip ? $this->object->zip.'&nbsp;' : ''); $this->tpl['zip'] = ($this->object->zip ? $this->object->zip.'&nbsp;' : '');
$img = picto_from_langcode($this->object->country_code); $img = picto_from_langcode($this->object->country_code);
$this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country; $this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country;
$this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); $this->tpl['phone_perso'] = dol_print_phone($this->object->phone_perso, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
$this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL'); $this->tpl['phone_mobile'] = dol_print_phone($this->object->phone_mobile, $this->object->country_code, 0, $this->object->id, 'AC_TEL');
$this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL'); $this->tpl['email'] = dol_print_email($this->object->email, 0, $this->object->id, 'AC_EMAIL');
$this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy); $this->tpl['visibility'] = $this->object->getmorphylib($this->object->morphy);
$this->tpl['note'] = nl2br($this->object->note); $this->tpl['note'] = nl2br($this->object->note);
} }
if ($action == 'create_user') { if ($action == 'create_user') {
// Full firstname and lastname separated with a dot : firstname.lastname // Full firstname and lastname separated with a dot : firstname.lastname
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
$login = dol_buildlogin($this->object->lastname, $this->object->firstname); $login = dol_buildlogin($this->object->lastname, $this->object->firstname);
$generated_password = getRandomPassword(false); $generated_password = getRandomPassword(false);
$password = $generated_password; $password = $generated_password;
// Create a form array // Create a form array
$formquestion = array( $formquestion = array(
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login), array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password)); array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
$this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no'); $this->tpl['action_create_user'] = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$this->object->id, $langs->trans("CreateDolibarrLogin"), $langs->trans("ConfirmCreateAdherent"), "confirm_create_user", $formquestion, 'no');
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Assign POST values into object * Assign POST values into object
* *
* @return string HTML output * @return string HTML output
*/ */
private function assign_post() private function assign_post()
{ {
// phpcs:enable // phpcs:enable
global $langs, $mysoc; global $langs, $mysoc;
$this->object->old_name = $_POST["old_name"]; $this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"]; $this->object->old_firstname = $_POST["old_firstname"];
$this->object->fk_soc = $_POST["fk_soc"]; $this->object->fk_soc = $_POST["fk_soc"];
$this->object->lastname = $_POST["lastname"]; $this->object->lastname = $_POST["lastname"];
$this->object->firstname = $_POST["firstname"]; $this->object->firstname = $_POST["firstname"];
$this->object->civility_id = $_POST["civility_id"]; $this->object->civility_id = $_POST["civility_id"];
$this->object->address = $_POST["address"]; $this->object->address = $_POST["address"];
$this->object->zip = $_POST["zipcode"]; $this->object->zip = $_POST["zipcode"];
$this->object->town = $_POST["town"]; $this->object->town = $_POST["town"];
$this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id; $this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
$this->object->state_id = $_POST["state_id"]; $this->object->state_id = $_POST["state_id"];
$this->object->phone_perso = $_POST["phone_perso"]; $this->object->phone_perso = $_POST["phone_perso"];
$this->object->phone_mobile = $_POST["phone_mobile"]; $this->object->phone_mobile = $_POST["phone_mobile"];
$this->object->email = $_POST["email"]; $this->object->email = $_POST["email"];
$this->object->note = $_POST["note"]; $this->object->note = $_POST["note"];
$this->object->canvas = $_POST["canvas"]; $this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country // We set country_id, and country_code label of the chosen country
if ($this->object->country_id) { if ($this->object->country_id) {
$sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id; $sql = "SELECT code, label FROM ".MAIN_DB_PREFIX."c_country WHERE rowid = ".$this->object->country_id;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->object->country_code = $obj->code; $this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle; $this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
} }
} }

View File

@ -31,21 +31,21 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.cl
class ActionsAdherentCardDefault extends ActionsAdherentCardCommon class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
{ {
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Handler acces data base * @param DoliDB $db Handler acces data base
* @param string $dirmodule Name of directory of module * @param string $dirmodule Name of directory of module
* @param string $targetmodule Name of directory of module where canvas is stored * @param string $targetmodule Name of directory of module where canvas is stored
* @param string $canvas Name of canvas * @param string $canvas Name of canvas
* @param string $card Name of tab (sub-canvas) * @param string $card Name of tab (sub-canvas)
*/ */
public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
{ {
$this->db = $db; $this->db = $db;
$this->dirmodule = $dirmodule; $this->dirmodule = $dirmodule;
$this->targetmodule = $targetmodule; $this->targetmodule = $targetmodule;
$this->canvas = $canvas; $this->canvas = $canvas;
$this->card = $card; $this->card = $card;
} }
/** /**
@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
return $out; return $out;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Assign custom values for canvas * Assign custom values for canvas
* *
@ -77,47 +77,47 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
*/ */
public function assign_values(&$action, $id) public function assign_values(&$action, $id)
{ {
// phpcs:enable // phpcs:enable
global $limit, $offset, $sortfield, $sortorder; global $limit, $offset, $sortfield, $sortorder;
global $conf, $db, $langs, $user; global $conf, $db, $langs, $user;
global $form; global $form;
$ret = $this->getObject($id); $ret = $this->getObject($id);
parent::assign_values($action, $id); parent::assign_values($action, $id);
$this->tpl['title'] = $this->getTitle($action); $this->tpl['title'] = $this->getTitle($action);
$this->tpl['error'] = $this->error; $this->tpl['error'] = $this->error;
$this->tpl['errors'] = $this->errors; $this->tpl['errors'] = $this->errors;
if ($action == 'view') { if ($action == 'view') {
// Card header // Card header
$head = member_prepare_head($this->object); $head = member_prepare_head($this->object);
$title = $this->getTitle($action); $title = $this->getTitle($action);
$this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent'); $this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
$this->tpl['showend'] = dol_get_fiche_end(); $this->tpl['showend'] = dol_get_fiche_end();
$objsoc = new Societe($db); $objsoc = new Societe($db);
$objsoc->fetch($this->object->socid); $objsoc->fetch($this->object->socid);
$this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1); $this->tpl['actionstodo'] = show_actions_todo($conf, $langs, $db, $objsoc, $this->object, 1);
$this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1); $this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
} else { } else {
// Confirm delete contact // Confirm delete contact
if ($action == 'delete' && $user->rights->adherent->supprimer) { if ($action == 'delete' && $user->rights->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); $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') { if ($action == 'list') {
$this->LoadListDatas($limit, $offset, $sortfield, $sortorder); $this->LoadListDatas($limit, $offset, $sortfield, $sortorder);
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Fetch datas list and save into ->list_datas * Fetch datas list and save into ->list_datas
* *
@ -129,11 +129,11 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
*/ */
public function LoadListDatas($limit, $offset, $sortfield, $sortorder) public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
{ {
// phpcs:enable // phpcs:enable
global $conf, $langs; global $conf, $langs;
//$this->getFieldList(); //$this->getFieldList();
$this->list_datas = array(); $this->list_datas = array();
} }
} }

View File

@ -118,21 +118,21 @@ if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['acti
<?php echo $this->control->tpl['showend']; <?php echo $this->control->tpl['showend'];
if (empty($user->socid)) { if (empty($user->socid)) {
echo '<div class="tabsAction">'; echo '<div class="tabsAction">';
if ($user->rights->adherent->creer) { if ($user->rights->adherent->creer) {
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=edit&amp;canvas='.$canvas.'">'.$langs->trans('Modify').'</a>'; echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=edit&amp;canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
} }
if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) { if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=create_user&amp;canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>'; echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=create_user&amp;canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
} }
if ($user->rights->adherent->supprimer) { if ($user->rights->adherent->supprimer) {
echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=delete&amp;canvas='.$canvas.'">'.$langs->trans('Delete').'</a>'; echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=delete&amp;canvas='.$canvas.'">'.$langs->trans('Delete').'</a>';
} }
echo '</div><br>'; echo '</div><br>';
} }
echo $this->control->tpl['actionstodo']; echo $this->control->tpl['actionstodo'];

View File

@ -6,7 +6,7 @@
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -191,6 +191,9 @@ if (empty($reshook)) {
if ($result < 0) { if ($result < 0) {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans($nuser->error), null, 'errors'); setEventMessages($langs->trans($nuser->error), null, 'errors');
} else {
setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
$action = '';
} }
} else { } else {
setEventMessages($object->error, $object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
@ -218,7 +221,7 @@ if (empty($reshook)) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$birthdate = ''; $birthdate = '';
if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int')) if (GETPOST("birthday", 'int') && GETPOST("birthmonth", 'int') && GETPOST("birthyear", 'int'))
{ {
$birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int')); $birthdate = dol_mktime(12, 0, 0, GETPOST("birthmonth", 'int'), GETPOST("birthday", 'int'), GETPOST("birthyear", 'int'));
} }
@ -1272,7 +1275,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Confirm create user // Confirm create user
if ($action == 'create_user') { if ($action == 'create_user') {
$login = $object->login; $login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
if (empty($login)) { if (empty($login)) {
// Full firstname and name separated with a dot : firstname.name // Full firstname and name separated with a dot : firstname.name
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
@ -1561,7 +1564,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', '');
} else { } else {
if ($object->user_id) { if ($object->user_id) {
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); $linkeduser = new User($db);
$linkeduser->fetch($object->user_id);
print $linkeduser->getNomUrl(-1);
} else { } else {
print $langs->trans("NoDolibarrAccess"); print $langs->trans("NoDolibarrAccess");
} }
@ -1701,13 +1706,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
} }
} }
// Delete
if ($user->rights->adherent->supprimer) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>\n";
} else {
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>";
}
// Action SPIP // Action SPIP
if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) { if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) {
$isinspip = $mailmanspip->is_in_spip($object); $isinspip = $mailmanspip->is_in_spip($object);
@ -1719,6 +1717,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n"; print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$object->id.'&action=add_spip">'.$langs->trans("AddIntoSpip")."</a></div>\n";
} }
} }
// Delete
if ($user->rights->adherent->supprimer) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>\n";
} else {
print '<div class="inline-block divButAction"><font class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans("Delete")."</font></div>";
}
} }
} }
print '</div>'; print '</div>';

View File

@ -56,163 +56,163 @@ $extrafields->fetch_name_optionals_label($object->table_element);
*/ */
if ($mode == 'cardlogin' && empty($foruserlogin)) { if ($mode == 'cardlogin' && empty($foruserlogin)) {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Login"));
} }
if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) { if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
$arrayofmembers = array(); $arrayofmembers = array();
// request taking into account member with up to date subscriptions // request taking into account member with up to date subscriptions
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,"; $sql = "SELECT d.rowid, d.firstname, d.lastname, d.login, d.societe as company, d.datefin,";
$sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,"; $sql .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
$sql .= " t.libelle as type,"; $sql .= " t.libelle as type,";
$sql .= " c.code as country_code, c.label as country"; $sql .= " c.code as country_code, c.label as country";
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) 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 : ''); 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 .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.country = c.rowid";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1"; $sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
$sql .= " AND d.entity IN (".getEntity('adherent').")"; $sql .= " AND d.entity IN (".getEntity('adherent').")";
if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid; if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid;
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'"; if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
$sql .= " ORDER BY d.rowid ASC"; $sql .= " ORDER BY d.rowid ASC";
dol_syslog("Search members", LOG_DEBUG); dol_syslog("Search members", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
if ($objp->country == '-') $objp->country = ''; if ($objp->country == '-') $objp->country = '';
$adherentstatic->id = $objp->rowid; $adherentstatic->id = $objp->rowid;
$adherentstatic->lastname = $objp->lastname; $adherentstatic->lastname = $objp->lastname;
$adherentstatic->firstname = $objp->firstname; $adherentstatic->firstname = $objp->firstname;
// Format extrafield so they can be parsed in function complete_substitutions_array // Format extrafield so they can be parsed in function complete_substitutions_array
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$adherentstatic->array_options = array(); $adherentstatic->array_options = array();
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$tmpkey = 'options_'.$key; $tmpkey = 'options_'.$key;
if (!empty($objp->$tmpkey)) { if (!empty($objp->$tmpkey)) {
$adherentstatic->array_options[$tmpkey] = $objp->$tmpkey; $adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
} }
//if (!empty($objp->$key)) //if (!empty($objp->$key))
// $objp->array_options[$tmpkey] = $objp->$key; // $objp->array_options[$tmpkey] = $objp->$key;
//$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey; //$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey;
} }
} }
// List of values to scan for a replacement // List of values to scan for a replacement
$substitutionarray = array( $substitutionarray = array(
'__ID__'=>$objp->rowid, '__ID__'=>$objp->rowid,
'__LOGIN__'=>$objp->login, '__LOGIN__'=>$objp->login,
'__FIRSTNAME__'=>$objp->firstname, '__FIRSTNAME__'=>$objp->firstname,
'__LASTNAME__'=>$objp->lastname, '__LASTNAME__'=>$objp->lastname,
'__FULLNAME__'=>$adherentstatic->getFullName($langs), '__FULLNAME__'=>$adherentstatic->getFullName($langs),
'__COMPANY__'=>$objp->company, '__COMPANY__'=>$objp->company,
'__ADDRESS__'=>$objp->address, '__ADDRESS__'=>$objp->address,
'__ZIP__'=>$objp->zip, '__ZIP__'=>$objp->zip,
'__TOWN__'=>$objp->town, '__TOWN__'=>$objp->town,
'__COUNTRY__'=>$objp->country, '__COUNTRY__'=>$objp->country,
'__COUNTRY_CODE__'=>$objp->country_code, '__COUNTRY_CODE__'=>$objp->country_code,
'__EMAIL__'=>$objp->email, '__EMAIL__'=>$objp->email,
'__BIRTH__'=>dol_print_date($objp->birth, 'day'), '__BIRTH__'=>dol_print_date($objp->birth, 'day'),
'__TYPE__'=>$objp->type, '__TYPE__'=>$objp->type,
'__YEAR__'=>$year, '__YEAR__'=>$year,
'__MONTH__'=>$month, '__MONTH__'=>$month,
'__DAY__'=>$day, '__DAY__'=>$day,
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/" '__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
); );
complete_substitutions_array($substitutionarray, $langs, $adherentstatic); complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
// For business cards // For business cards
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
$textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray); $textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
$textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray); $textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
$textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray); $textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
$textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray); $textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
if (is_numeric($foruserid) || $foruserlogin) { if (is_numeric($foruserid) || $foruserlogin) {
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; $nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
if ($nb <= 0) $nb = 1; // Protection to avoid empty page if ($nb <= 0) $nb = 1; // Protection to avoid empty page
for ($j = 0; $j < $nb; $j++) { for ($j = 0; $j < $nb; $j++) {
$arrayofmembers[] = array( $arrayofmembers[] = array(
'textleft'=>$textleft, 'textleft'=>$textleft,
'textheader'=>$textheader, 'textheader'=>$textheader,
'textfooter'=>$textfooter, 'textfooter'=>$textfooter,
'textright'=>$textright, 'textright'=>$textright,
'id'=>$objp->rowid, 'id'=>$objp->rowid,
'photo'=>$objp->photo 'photo'=>$objp->photo
); );
} }
} else { } else {
$arrayofmembers[] = array( $arrayofmembers[] = array(
'textleft'=>$textleft, 'textleft'=>$textleft,
'textheader'=>$textheader, 'textheader'=>$textheader,
'textfooter'=>$textfooter, 'textfooter'=>$textfooter,
'textright'=>$textright, 'textright'=>$textright,
'id'=>$objp->rowid, 'id'=>$objp->rowid,
'photo'=>$objp->photo 'photo'=>$objp->photo
); );
} }
} }
// For labels // For labels
if ($mode == 'label') { if ($mode == 'label') {
if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__"; if (empty($conf->global->ADHERENT_ETIQUETTE_TEXT)) $conf->global->ADHERENT_ETIQUETTE_TEXT = "__FULLNAME__\n__ADDRESS__\n__ZIP__ __TOWN__\n__COUNTRY__";
$textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray); $textleft = make_substitutions($conf->global->ADHERENT_ETIQUETTE_TEXT, $substitutionarray);
$textheader = ''; $textheader = '';
$textfooter = ''; $textfooter = '';
$textright = ''; $textright = '';
$arrayofmembers[] = array('textleft'=>$textleft, $arrayofmembers[] = array('textleft'=>$textleft,
'textheader'=>$textheader, 'textheader'=>$textheader,
'textfooter'=>$textfooter, 'textfooter'=>$textfooter,
'textright'=>$textright, 'textright'=>$textright,
'id'=>$objp->rowid, 'id'=>$objp->rowid,
'photo'=>$objp->photo); 'photo'=>$objp->photo);
} }
$i++; $i++;
} }
// Build and output PDF // Build and output PDF
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') { if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
if (!count($arrayofmembers)) { if (!count($arrayofmembers)) {
$mesg = $langs->trans("ErrorRecordNotFound"); $mesg = $langs->trans("ErrorRecordNotFound");
} }
if (empty($model) || $model == '-1') { if (empty($model) || $model == '-1') {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
} }
if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs); if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
} elseif ($mode == 'label') { } elseif ($mode == 'label') {
if (!count($arrayofmembers)) { if (!count($arrayofmembers)) {
$mesg = $langs->trans("ErrorRecordNotFound"); $mesg = $langs->trans("ErrorRecordNotFound");
} }
if (empty($modellabel) || $modellabel == '-1') { if (empty($modellabel) || $modellabel == '-1') {
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
} }
if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs); if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
} }
if ($result <= 0) { if ($result <= 0) {
dol_print_error('', $result); dol_print_error('', $result);
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if (!$mesg) { if (!$mesg) {
$db->close(); $db->close();
exit; exit;
} }
} }

View File

@ -7,7 +7,7 @@
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr> * Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015-2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2015-2020 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net> * Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
@ -60,6 +60,9 @@ class Adherent extends CommonObject
*/ */
public $ismultientitymanaged = 1; public $ismultientitymanaged = 1;
/**
* @var string picto
*/
public $picto = 'member'; public $picto = 'member';
@ -70,13 +73,19 @@ class Adherent extends CommonObject
*/ */
public $login; public $login;
//! Clear password in memory /**
* @var string Clear password in memory
*/
public $pass; public $pass;
//! Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) /**
* @var string Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0)
*/
public $pass_indatabase; public $pass_indatabase;
//! Encrypted password in database (always defined) /**
* @var string Encrypted password in database (always defined)
*/
public $pass_indatabase_crypted; public $pass_indatabase_crypted;
/** /**
@ -169,6 +178,11 @@ class Adherent extends CommonObject
*/ */
public $phone_perso; public $phone_perso;
/**
* @var string Professional Phone number
*/
public $phone_pro;
/** /**
* @var string Mobile phone number * @var string Mobile phone number
*/ */
@ -184,6 +198,9 @@ class Adherent extends CommonObject
*/ */
public $poste; public $poste;
/**
* @var string mor or phy
*/
public $morphy; public $morphy;
public $public; public $public;
@ -191,6 +208,10 @@ class Adherent extends CommonObject
// -1:brouillon, 0:resilie, >=1:valide,paye // -1:brouillon, 0:resilie, >=1:valide,paye
// def in common object // def in common object
//public $status; //public $status;
/**
* @var string photo of member
*/
public $photo; public $photo;
/** /**
@ -209,6 +230,9 @@ class Adherent extends CommonObject
public $datevalid; public $datevalid;
/**
* @var string gender
*/
public $gender; public $gender;
public $birth; public $birth;
@ -258,7 +282,11 @@ class Adherent extends CommonObject
*/ */
public $entity; public $entity;
public $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), /**
* @var array fields
*/
public $fields = array(
'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10),
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20),
'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25),
@ -296,9 +324,10 @@ class Adherent extends CommonObject
'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190), 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190),
'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195), 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195),
'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500, 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500,
'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')),
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)); 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)
);
/** /**
@ -407,7 +436,8 @@ class Adherent extends CommonObject
$infos .= $langs->transnoentities("Public").": ".yn($this->public); $infos .= $langs->transnoentities("Public").": ".yn($this->public);
// Substitutions // Substitutions
$substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), $substitutionarray = array(
'__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(),
'__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''),
'__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''),
'__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs),
@ -422,7 +452,8 @@ class Adherent extends CommonObject
'__PHONE__' => $msgishtml ? dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''), '__PHONE__' => $msgishtml ? dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''),
'__PHONEPRO__' => $msgishtml ? dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''), '__PHONEPRO__' => $msgishtml ? dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''),
'__PHONEMOBILE__' => $msgishtml ? dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : ''), '__PHONEMOBILE__' => $msgishtml ? dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : ''),
'__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '')); '__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '')
);
complete_substitutions_array($substitutionarray, $langs, $this); complete_substitutions_array($substitutionarray, $langs, $this);
@ -589,9 +620,7 @@ class Adherent extends CommonObject
$this->town = ($this->town ? $this->town : $this->town); $this->town = ($this->town ? $this->town : $this->town);
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id); $this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
$this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id); $this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname)); $this->setUpperOrLowerCase();
if (!empty($conf->global->MAIN_ALL_TO_UPPER)) $this->lastname = dol_strtoupper($this->lastname);
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = dol_ucwords(dol_strtolower($this->firstname));
$this->note_public = ($this->note_public ? $this->note_public : $this->note_public); $this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
$this->note_private = ($this->note_private ? $this->note_private : $this->note_private); $this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
@ -1984,7 +2013,8 @@ class Adherent extends CommonObject
} }
$label .= '<div class="centpercent">'; $label .= '<div class="centpercent">';
$label .= '<u>'.$langs->trans("Member").'</u>'; $label .= img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Member").'</u>';
$label .= ' '.$this->getLibStatut(4);
if (!empty($this->ref)) $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref; if (!empty($this->ref)) $label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
if (!empty($this->firstname) || !empty($this->lastname)) $label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs); if (!empty($this->firstname) || !empty($this->lastname)) $label .= '<br><b>'.$langs->trans('Name').':</b> '.$this->getFullName($langs);
if (!empty($this->company)) $label .= '<br><b>'.$langs->trans('Company').':</b> '.$this->company; if (!empty($this->company)) $label .= '<br><b>'.$langs->trans('Company').':</b> '.$this->company;
@ -2276,14 +2306,16 @@ class Adherent extends CommonObject
* Used to build previews or test instances. * Used to build previews or test instances.
* id must be 0 if object instance is a specimen. * id must be 0 if object instance is a specimen.
* *
* @return void * @return int
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $user, $langs; global $user, $langs;
$now = dol_now();
// Initialise parametres // Initialise parametres
$this->id = 0; $this->id = 0;
$this->entity = 1;
$this->specimen = 1; $this->specimen = 1;
$this->civility_id = 0; $this->civility_id = 0;
$this->lastname = 'DOLIBARR'; $this->lastname = 'DOLIBARR';
@ -2300,24 +2332,30 @@ class Adherent extends CommonObject
$this->country = 'France'; $this->country = 'France';
$this->morphy = 'mor'; $this->morphy = 'mor';
$this->email = 'specimen@specimen.com'; $this->email = 'specimen@specimen.com';
$this->socialnetworks = array('skype' => 'skypepseudo', 'twitter' => 'twitterpseudo', 'facebook' => 'facebookpseudo', 'linkedin' => 'linkedinpseudo'); $this->socialnetworks = array(
'skype' => 'skypepseudo',
'twitter' => 'twitterpseudo',
'facebook' => 'facebookpseudo',
'linkedin' => 'linkedinpseudo',
);
$this->phone = '0999999999'; $this->phone = '0999999999';
$this->phone_perso = '0999999998'; $this->phone_perso = '0999999998';
$this->phone_mobile = '0999999997'; $this->phone_mobile = '0999999997';
$this->note_private = 'No comment'; $this->note_public = 'This is a public note';
$this->birth = time(); $this->note_private = 'This is a private note';
$this->birth = $now;
$this->photo = ''; $this->photo = '';
$this->public = 1; $this->public = 1;
$this->statut = 0; $this->statut = 0;
$this->datefin = time(); $this->datefin = $now;
$this->datevalid = time(); $this->datevalid = $now;
$this->typeid = 1; // Id type adherent $this->typeid = 1; // Id type adherent
$this->type = 'Type adherent'; // Libelle type adherent $this->type = 'Type adherent'; // Libelle type adherent
$this->need_subscription = 0; $this->need_subscription = 0;
$this->first_subscription_date = time(); $this->first_subscription_date = $now;
$this->first_subscription_date_start = $this->first_subscription_date; $this->first_subscription_date_start = $this->first_subscription_date;
$this->first_subscription_date_end = dol_time_plus_duree($this->first_subscription_date_start, 1, 'y'); $this->first_subscription_date_end = dol_time_plus_duree($this->first_subscription_date_start, 1, 'y');
$this->first_subscription_amount = 10; $this->first_subscription_amount = 10;
@ -2326,6 +2364,7 @@ class Adherent extends CommonObject
$this->last_subscription_date_start = $this->first_subscription_date; $this->last_subscription_date_start = $this->first_subscription_date;
$this->last_subscription_date_end = dol_time_plus_duree($this->last_subscription_date_start, 1, 'y'); $this->last_subscription_date_end = dol_time_plus_duree($this->last_subscription_date_start, 1, 'y');
$this->last_subscription_amount = 10; $this->last_subscription_amount = 10;
return 1;
} }
@ -2365,6 +2404,7 @@ class Adherent extends CommonObject
global $conf, $langs; global $conf, $langs;
$info = array(); $info = array();
$socialnetworks = getArrayOfSocialNetworks();
$keymodified = false; $keymodified = false;
// Object classes // Object classes
@ -2379,8 +2419,13 @@ class Adherent extends CommonObject
} }
// Possible LDAP KEY (constname => varname) // Possible LDAP KEY (constname => varname)
$ldapkey = array('LDAP_MEMBER_FIELD_FULLNAME' => 'fullname', 'LDAP_MEMBER_FIELD_NAME' => 'lastname', 'LDAP_MEMBER_FIELD_LOGIN' => 'login', 'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login', $ldapkey = array(
'LDAP_MEMBER_FIELD_MAIL' => 'email'); 'LDAP_MEMBER_FIELD_FULLNAME' => 'fullname',
'LDAP_MEMBER_FIELD_NAME' => 'lastname',
'LDAP_MEMBER_FIELD_LOGIN' => 'login',
'LDAP_MEMBER_FIELD_LOGIN_SAMBA' => 'login',
'LDAP_MEMBER_FIELD_MAIL' => 'email'
);
// Member // Member
foreach ($ldapkey as $constname => $varname) { foreach ($ldapkey as $constname => $varname) {
@ -2400,10 +2445,11 @@ class Adherent extends CommonObject
if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip; if ($this->zip && !empty($conf->global->LDAP_MEMBER_FIELD_ZIP)) $info[$conf->global->LDAP_MEMBER_FIELD_ZIP] = $this->zip;
if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town; if ($this->town && !empty($conf->global->LDAP_MEMBER_FIELD_TOWN)) $info[$conf->global->LDAP_MEMBER_FIELD_TOWN] = $this->town;
if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code; if ($this->country_code && !empty($conf->global->LDAP_MEMBER_FIELD_COUNTRY)) $info[$conf->global->LDAP_MEMBER_FIELD_COUNTRY] = $this->country_code;
if ($this->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype; foreach ($socialnetworks as $key => $value) {
if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter; if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) {
if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook; $info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin; }
}
if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone; if ($this->phone && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE] = $this->phone;
if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso; if ($this->phone_perso && !empty($conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO)) $info[$conf->global->LDAP_MEMBER_FIELD_PHONE_PERSO] = $this->phone_perso;
if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile; if ($this->phone_mobile && !empty($conf->global->LDAP_MEMBER_FIELD_MOBILE)) $info[$conf->global->LDAP_MEMBER_FIELD_MOBILE] = $this->phone_mobile;
@ -2416,8 +2462,12 @@ class Adherent extends CommonObject
// When password is modified // When password is modified
if (!empty($this->pass)) { if (!empty($this->pass)) {
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD)) {
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte
}
if (!empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) {
$info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
}
} // Set LDAP password if possible } // Set LDAP password if possible
elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) { if (!empty($conf->global->DATABASE_PWD_ENCRYPTED)) {

View File

@ -85,7 +85,6 @@ class AdherentType extends CommonObject
/** /**
* @var int Subsription required (0 or 1) * @var int Subsription required (0 or 1)
* @since 5.0
*/ */
public $subscription; public $subscription;
@ -95,9 +94,15 @@ class AdherentType extends CommonObject
/** @var integer Can vote */ /** @var integer Can vote */
public $vote; public $vote;
/** @var string Email sent during validation */ /** @var string Email sent during validation of member */
public $mail_valid; public $mail_valid;
/** @var string Email sent after recording a new subscription */
public $mail_subscription = '';
/** @var string Email sent after resiliation */
public $mail_resiliate = '';
/** @var array Array of members */ /** @var array Array of members */
public $members = array(); public $members = array();
@ -116,7 +121,7 @@ class AdherentType extends CommonObject
} }
/** /**
* Load array this->multilangs * Load array this->multilangs
* *
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -151,7 +156,7 @@ class AdherentType extends CommonObject
} }
/** /**
* Update or add a translation for a product * Update or add a translation for this member type
* *
* @param User $user Object user making update * @param User $user Object user making update
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -236,12 +241,11 @@ class AdherentType extends CommonObject
} }
/** /**
* Delete a language for this product * Delete a language for this member type
* *
* @param string $langtodelete Language code to delete * @param string $langtodelete Language code to delete
* @param User $user Object user making delete * @param User $user Object user making delete
* * @return int <0 if KO, >0 if OK
* @return int <0 if KO, >0 if OK
*/ */
public function delMultiLangs($langtodelete, $user) public function delMultiLangs($langtodelete, $user)
{ {
@ -268,9 +272,9 @@ class AdherentType extends CommonObject
} }
/** /**
* Fonction qui permet de creer le status de l'adherent * Function to create the member type
* *
* @param User $user User making creation * @param User $user User making creation
* @param int $notrigger 1=do not execute triggers, 0 otherwise * @param int $notrigger 1=do not execute triggers, 0 otherwise
* @return int >0 if OK, < 0 if KO * @return int >0 if OK, < 0 if KO
*/ */
@ -574,7 +578,7 @@ class AdherentType extends CommonObject
public function getmorphylib($morphy = '') public function getmorphylib($morphy = '')
{ {
global $langs; global $langs;
if ($morphy == 'phy') { return $langs->trans("Physical"); } elseif ($morphy == 'mor') { return $langs->trans("Moral"); } else return $langs->trans("MorPhy"); if ($morphy == 'phy') { return $langs->trans("Physical"); } elseif ($morphy == 'mor') { return $langs->trans("Moral"); } else return $langs->trans("MorAndPhy");
//return $morphy; //return $morphy;
} }
@ -591,7 +595,15 @@ class AdherentType extends CommonObject
global $langs; global $langs;
$result = ''; $result = '';
$label = $langs->trans("ShowTypeCard", $this->label);
$label = '';
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("MemberType").'</u>';
$label .= ' '.$this->getLibStatut(4);
$label .= '<br>'.$langs->trans("Label").': '.$this->label;
if (isset($this->subscription)) {
$label .= '<br>'.$langs->trans("SubscriptionRequired").': '.yn($this->subscription);
}
$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">'; $linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
$linkend = '</a>'; $linkend = '</a>';
@ -707,7 +719,7 @@ class AdherentType extends CommonObject
*/ */
public function initAsSpecimen() public function initAsSpecimen()
{ {
global $conf, $user, $langs; global $user;
// Initialise parametres // Initialise parametres
$this->id = 0; $this->id = 0;
@ -735,8 +747,6 @@ class AdherentType extends CommonObject
*/ */
public function getMailOnValid() public function getMailOnValid()
{ {
global $conf;
if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) { if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) {
return $this->mail_valid; return $this->mail_valid;
} }
@ -751,8 +761,6 @@ class AdherentType extends CommonObject
*/ */
public function getMailOnSubscription() public function getMailOnSubscription()
{ {
global $conf;
// mail_subscription not defined so never used // mail_subscription not defined so never used
if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined
return $this->mail_subscription; return $this->mail_subscription;
@ -768,8 +776,6 @@ class AdherentType extends CommonObject
*/ */
public function getMailOnResiliate() public function getMailOnResiliate()
{ {
global $conf;
// NOTE mail_resiliate not defined so never used // NOTE mail_resiliate not defined so never used
if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
return $this->mail_resiliate; return $this->mail_resiliate;

View File

@ -32,18 +32,18 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
*/ */
class AdherentStats extends Stats class AdherentStats extends Stats
{ {
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element; public $table_element;
public $memberid; public $memberid;
public $socid; public $socid;
public $userid; public $userid;
public $from; public $from;
public $field; public $field;
public $where; public $where;
/** /**
@ -51,15 +51,15 @@ class AdherentStats extends Stats
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party * @param int $socid Id third party
* @param int $userid Id user for filter * @param int $userid Id user for filter
*/ */
public function __construct($db, $socid = 0, $userid = 0) public function __construct($db, $socid = 0, $userid = 0)
{ {
global $user, $conf; global $user, $conf;
$this->db = $db; $this->db = $db;
$this->socid = $socid; $this->socid = $socid;
$this->userid = $userid; $this->userid = $userid;
$object = new Subscription($this->db); $object = new Subscription($this->db);
@ -74,16 +74,16 @@ class AdherentStats extends Stats
if ($this->memberid) { if ($this->memberid) {
$this->where .= " AND m.rowid = ".$this->memberid; $this->where .= " AND m.rowid = ".$this->memberid;
} }
//if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; //if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid;
} }
/** /**
* Return the number of proposition by month for a given year * Return the number of proposition by month for a given year
* *
* @param int $year 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 * @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 nb each month * @return array Array of nb each month
*/ */
public function getNbByMonth($year, $format = 0) public function getNbByMonth($year, $format = 0)
{ {
@ -95,7 +95,7 @@ class AdherentStats extends Stats
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
return $this->_getNbByMonth($year, $sql, $format); return $this->_getNbByMonth($year, $sql, $format);
} }
@ -103,7 +103,7 @@ class AdherentStats extends Stats
/** /**
* Return the number of subscriptions by year * Return the number of subscriptions by year
* *
* @return array Array of nb each year * @return array Array of nb each year
*/ */
public function getNbByYear() public function getNbByYear()
{ {
@ -114,7 +114,7 @@ class AdherentStats extends Stats
//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; //if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
return $this->_getNbByYear($sql); return $this->_getNbByYear($sql);
} }
@ -122,9 +122,9 @@ class AdherentStats extends Stats
/** /**
* Return the number of subscriptions by month for a given year * Return the number of subscriptions by month for a given year
* *
* @param int $year 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 * @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 * @return array Array of amount each month
*/ */
public function getAmountByMonth($year, $format = 0) public function getAmountByMonth($year, $format = 0)
{ {
@ -136,7 +136,7 @@ class AdherentStats extends Stats
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
return $this->_getAmountByMonth($year, $sql, $format); return $this->_getAmountByMonth($year, $sql, $format);
} }
@ -144,8 +144,8 @@ class AdherentStats extends Stats
/** /**
* Return average amount each month * Return average amount each month
* *
* @param int $year Year * @param int $year Year
* @return array Array of average each month * @return array Array of average each month
*/ */
public function getAverageByMonth($year) public function getAverageByMonth($year)
{ {
@ -157,7 +157,7 @@ class AdherentStats extends Stats
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year); $sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
$sql .= " AND ".$this->where; $sql .= " AND ".$this->where;
$sql .= " GROUP BY dm"; $sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC'); $sql .= $this->db->order('dm', 'DESC');
return $this->_getAverageByMonth($year, $sql); return $this->_getAverageByMonth($year, $sql);
} }
@ -177,7 +177,7 @@ class AdherentStats extends Stats
//if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; //if (!$user->rights->societe->client->voir && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE ".$this->where; $sql .= " WHERE ".$this->where;
$sql .= " GROUP BY year"; $sql .= " GROUP BY year";
$sql .= $this->db->order('year', 'DESC'); $sql .= $this->db->order('year', 'DESC');
return $this->_getAllByYear($sql); return $this->_getAllByYear($sql);
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr> /* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2020 Thibault FOUCART<support@ptibogxiv.net> * Copyright (C) 2020 Thibault FOUCART<support@ptibogxiv.net>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,477 +33,481 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
*/ */
class Members extends DolibarrApi class Members extends DolibarrApi
{ {
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'morphy', 'morphy',
'typeid' 'typeid'
); );
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
} }
/** /**
* Get properties of a member object * Get properties of a member object
* *
* Return an array with member informations * Return an array with member informations
* *
* @param int $id ID of member * @param int $id ID of member
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
public function get($id) public function get($id)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($id); if ($id == 0) {
if (!$result) { $result = $member->initAsSpecimen();
throw new RestException(404, 'member not found'); } else {
} $result = $member->fetch($id);
}
if (!$result) {
throw new RestException(404, 'member not found');
}
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) { if (!DolibarrApi::_checkAccessToResource('adherent', $member->id) && $id > 0) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
return $this->_cleanObjectDatas($member); return $this->_cleanObjectDatas($member);
} }
/** /**
* Get properties of a member object by linked thirdparty * Get properties of a member object by linked thirdparty
* *
* Return an array with member informations * Return an array with member informations
* *
* @param int $thirdparty ID of third party * @param int $thirdparty ID of third party
* *
* @return array|mixed Data without useless information * @return Object Data without useless information
* *
* @url GET thirdparty/{thirdparty} * @url GET thirdparty/{thirdparty}
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function getByThirdparty($thirdparty) public function getByThirdparty($thirdparty)
{ {
if (! DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch('', '', $thirdparty); $result = $member->fetch('', '', $thirdparty);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
return $this->_cleanObjectDatas($member); return $this->_cleanObjectDatas($member);
} }
/** /**
* Get properties of a member object by linked thirdparty email * Get properties of a member object by linked thirdparty email
* *
* Return an array with member informations * Return an array with member informations
* *
* @param string $email Email of third party * @param string $email Email of third party
* *
* @return array|mixed Data without useless information * @return Object Data without useless information
* *
* @url GET thirdparty/email/{email} * @url GET thirdparty/email/{email}
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function getByThirdpartyEmail($email) public function getByThirdpartyEmail($email)
{ {
if (! DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$thirdparty = new Societe($this->db); $thirdparty = new Societe($this->db);
$result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); $result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'thirdparty not found'); throw new RestException(404, 'thirdparty not found');
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch('', '', $thirdparty->id); $result = $member->fetch('', '', $thirdparty->id);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
return $this->_cleanObjectDatas($member); return $this->_cleanObjectDatas($member);
} }
/** /**
* Get properties of a member object by linked thirdparty barcode * Get properties of a member object by linked thirdparty barcode
* *
* Return an array with member informations * Return an array with member informations
* *
* @param string $barcode Barcode of third party * @param string $barcode Barcode of third party
* *
* @return array|mixed Data without useless information * @return Object Data without useless information
* *
* @url GET thirdparty/barcode/{barcode} * @url GET thirdparty/barcode/{barcode}
* *
* @throws RestException 401 * @throws RestException 401
* @throws RestException 404 * @throws RestException 404
*/ */
public function getByThirdpartyBarcode($barcode) public function getByThirdpartyBarcode($barcode)
{ {
if (! DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$thirdparty = new Societe($this->db); $thirdparty = new Societe($this->db);
$result = $thirdparty->fetch('', '', '', $barcode); $result = $thirdparty->fetch('', '', '', $barcode);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'thirdparty not found'); throw new RestException(404, 'thirdparty not found');
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch('', '', $thirdparty->id); $result = $member->fetch('', '', $thirdparty->id);
if ( ! $result ) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) { if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
return $this->_cleanObjectDatas($member); return $this->_cleanObjectDatas($member);
} }
/** /**
* List members * List members
* *
* Get a list of members * Get a list of members
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $typeid ID of the type of member * @param string $typeid ID of the type of member
* @param int $category Use this param to filter list by category * @param int $category Use this param to filter list by category
* @param string $sqlfilters Other criteria to filter answers separated by a comma. * @param string $sqlfilters Other criteria to filter answers separated by a comma.
* Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))" * Example: "(t.ref:like:'SO-%') and ((t.date_creation:<:'20160101') or (t.nature:is:NULL))"
* @return array Array of member objects * @return array Array of member objects
* *
* @throws RestException * @throws RestException
*/ */
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
if (!DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as t"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
if ($category > 0) { if ($category > 0) {
$sql .= ", ".MAIN_DB_PREFIX."categorie_member as c"; $sql .= ", ".MAIN_DB_PREFIX."categorie_member as c";
} }
$sql .= ' WHERE t.entity IN ('.getEntity('adherent').')'; $sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
if (!empty($typeid)) { if (!empty($typeid)) {
$sql .= ' AND t.fk_adherent_type='.$typeid; $sql .= ' AND t.fk_adherent_type='.$typeid;
} }
// Select members of given category // Select members of given category
if ($category > 0) { if ($category > 0) {
$sql .= " AND c.fk_categorie = ".$this->db->escape($category); $sql .= " AND c.fk_categorie = ".$this->db->escape($category);
$sql .= " AND c.fk_member = t.rowid "; $sql .= " AND c.fk_member = t.rowid ";
} }
// Add sql filters // Add sql filters
if ($sqlfilters) { if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) { if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$i = 0; $i = 0;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min) { while ($i < $min) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$member = new Adherent($this->db); $member = new Adherent($this->db);
if ($member->fetch($obj->rowid)) { if ($member->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($member); $obj_ret[] = $this->_cleanObjectDatas($member);
} }
$i++; $i++;
} }
} else { } else {
throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror()); throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror());
} }
if (!count($obj_ret)) { if (!count($obj_ret)) {
throw new RestException(404, 'No member found'); throw new RestException(404, 'No member found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create member object * Create member object
* *
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of member * @return int ID of member
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
$member = new Adherent($this->db); $member = new Adherent($this->db);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$member->$field = $value; $member->$field = $value;
} }
if ($member->create(DolibarrApiAccess::$user) < 0) { if ($member->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors)); throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors));
} }
return $member->id; return $member->id;
} }
/** /**
* Update member * Update member
* *
* @param int $id ID of member to update * @param int $id ID of member to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return Object Updated object
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($id); $result = $member->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') continue;
// Process the status separately because it must be updated using // Process the status separately because it must be updated using
// the validate() and resiliate() methods of the class Adherent. // the validate() and resiliate() methods of the class Adherent.
if ($field == 'statut') { if ($field == 'statut') {
if ($value == '0') { if ($value == '0') {
$result = $member->resiliate(DolibarrApiAccess::$user); $result = $member->resiliate(DolibarrApiAccess::$user);
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when resiliating member: '.$member->error); throw new RestException(500, 'Error when resiliating member: '.$member->error);
} }
} elseif ($value == '1') { } elseif ($value == '1') {
$result = $member->validate(DolibarrApiAccess::$user); $result = $member->validate(DolibarrApiAccess::$user);
if ($result < 0) { if ($result < 0) {
throw new RestException(500, 'Error when validating member: '.$member->error); throw new RestException(500, 'Error when validating member: '.$member->error);
} }
} }
} else { } else {
$member->$field = $value; $member->$field = $value;
} }
} }
// If there is no error, update() returns the number of affected rows // If there is no error, update() returns the number of affected rows
// so if the update is a no op, the return value is zero. // so if the update is a no op, the return value is zero.
if ($member->update(DolibarrApiAccess::$user) >= 0) { if ($member->update(DolibarrApiAccess::$user) >= 0) {
return $this->get($id); return $this->get($id);
} else { } else {
throw new RestException(500, $member->error); throw new RestException(500, $member->error);
} }
} }
/** /**
* Delete member * Delete member
* *
* @param int $id member ID * @param int $id member ID
* @return array * @return array
*/ */
public function delete($id) public function delete($id)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->supprimer) { if (!DolibarrApiAccess::$user->rights->adherent->supprimer) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($id); $result = $member->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) { if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if (!$member->delete($member->id, DolibarrApiAccess::$user)) { if (!$member->delete($member->id, DolibarrApiAccess::$user)) {
throw new RestException(401, 'error when deleting member'); throw new RestException(401, 'error when deleting member');
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'member deleted' 'message' => 'member deleted'
) )
); );
} }
/** /**
* Validate fields before creating an object * Validate fields before creating an object
* *
* @param array|null $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
private function _validate($data) private function _validate($data)
{ {
$member = array(); $member = array();
foreach (Members::$FIELDS as $field) { foreach (Members::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$member[$field] = $data[$field]; $member[$field] = $data[$field];
} }
return $member; return $member;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param Object $object Object to clean
* @return array Array of cleaned object properties * @return Object Object with cleaned properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
// phpcs:enable // phpcs:enable
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
// Remove the subscriptions because they are handled as a subresource. // Remove the subscriptions because they are handled as a subresource.
unset($object->subscriptions); unset($object->subscriptions);
unset($object->fk_incoterms); unset($object->fk_incoterms);
unset($object->label_incoterms); unset($object->label_incoterms);
unset($object->location_incoterms); unset($object->location_incoterms);
unset($object->fk_delivery_address); unset($object->fk_delivery_address);
unset($object->shipping_method_id); unset($object->shipping_method_id);
unset($object->total_ht); unset($object->total_ht);
unset($object->total_ttc); unset($object->total_ttc);
unset($object->total_tva); unset($object->total_tva);
unset($object->total_localtax1); unset($object->total_localtax1);
unset($object->total_localtax2); unset($object->total_localtax2);
return $object; return $object;
} }
/** /**
* List subscriptions of a member * List subscriptions of a member
* *
* Get a list of subscriptions * Get a list of subscriptions
* *
* @param int $id ID of member * @param int $id ID of member
* @return array Array of subscription objects * @return array Array of subscription objects
* *
* @throws RestException * @throws RestException
* *
* @url GET {id}/subscriptions * @url GET {id}/subscriptions
*/ */
public function getSubscriptions($id) public function getSubscriptions($id)
{ {
$obj_ret = array(); $obj_ret = array();
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($id); $result = $member->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
$obj_ret = array(); $obj_ret = array();
foreach ($member->subscriptions as $subscription) { foreach ($member->subscriptions as $subscription) {
$obj_ret[] = $this->_cleanObjectDatas($subscription); $obj_ret[] = $this->_cleanObjectDatas($subscription);
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Add a subscription for a member * Add a subscription for a member
* *
* @param int $id ID of member * @param int $id ID of member
* @param int $start_date Start date {@from body} {@type timestamp} * @param int $start_date Start date {@from body} {@type timestamp}
* @param int $end_date End date {@from body} {@type timestamp} * @param int $end_date End date {@from body} {@type timestamp}
* @param float $amount Amount (may be 0) {@from body} * @param float $amount Amount (may be 0) {@from body}
* @param string $label Label {@from body} * @param string $label Label {@from body}
* @return int ID of subscription * @return int ID of subscription
* *
* @url POST {id}/subscriptions * @url POST {id}/subscriptions
*/ */
public function createSubscription($id, $start_date, $end_date, $amount, $label = '') public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
{ {
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
throw new RestException(401); throw new RestException(401);
} }
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($id); $result = $member->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member not found'); throw new RestException(404, 'member not found');
} }
return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date); return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date);
} }
/** /**
* Get categories for a member * Get categories for a member
* *
* @param int $id ID of member * @param int $id ID of member
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* *
* @return mixed * @return mixed
* *
* @url GET {id}/categories * @url GET {id}/categories
*/ */
public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
{ {
if (!DolibarrApiAccess::$user->rights->categorie->lire) { if (!DolibarrApiAccess::$user->rights->categorie->lire) {

View File

@ -27,289 +27,289 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
*/ */
class MembersTypes extends DolibarrApi class MembersTypes extends DolibarrApi
{ {
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'label', 'label',
); );
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
} }
/** /**
* Get properties of a member type object * Get properties of a member type object
* *
* Return an array with member type informations * Return an array with member type informations
* *
* @param int $id ID of member type * @param int $id ID of member type
* @return array|mixed data without useless information * @return array|mixed data without useless information
* *
* @throws RestException * @throws RestException
*/ */
public function get($id) public function get($id)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$membertype = new AdherentType($this->db); $membertype = new AdherentType($this->db);
$result = $membertype->fetch($id); $result = $membertype->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member type not found'); throw new RestException(404, 'member type not found');
} }
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
return $this->_cleanObjectDatas($membertype); return $this->_cleanObjectDatas($membertype);
} }
/** /**
* List members types * List members types
* *
* Get a list of members types * Get a list of members types
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.libelle:like:'SO-%') and (t.subscription:=:'1')"
* @return array Array of member type objects * @return array Array of member type objects
* *
* @throws RestException * @throws RestException
*/ */
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
if (!DolibarrApiAccess::$user->rights->adherent->lire) { if (!DolibarrApiAccess::$user->rights->adherent->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT t.rowid"; $sql = "SELECT t.rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= ' WHERE t.entity IN ('.getEntity('member_type').')'; $sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
// Add sql filters // Add sql filters
if ($sqlfilters) { if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) { if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$i = 0; $i = 0;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
$min = min($num, ($limit <= 0 ? $num : $limit)); $min = min($num, ($limit <= 0 ? $num : $limit));
while ($i < $min) { while ($i < $min) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$membertype = new AdherentType($this->db); $membertype = new AdherentType($this->db);
if ($membertype->fetch($obj->rowid)) { if ($membertype->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($membertype); $obj_ret[] = $this->_cleanObjectDatas($membertype);
} }
$i++; $i++;
} }
} else { } else {
throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror()); throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
} }
if (!count($obj_ret)) { if (!count($obj_ret)) {
throw new RestException(404, 'No member type found'); throw new RestException(404, 'No member type found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create member type object * Create member type object
* *
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of member type * @return int ID of member type
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->configurer) { if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
$membertype = new AdherentType($this->db); $membertype = new AdherentType($this->db);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$membertype->$field = $value; $membertype->$field = $value;
} }
if ($membertype->create(DolibarrApiAccess::$user) < 0) { if ($membertype->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors)); throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
} }
return $membertype->id; return $membertype->id;
} }
/** /**
* Update member type * Update member type
* *
* @param int $id ID of member type to update * @param int $id ID of member type to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return int
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->configurer) { if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401); throw new RestException(401);
} }
$membertype = new AdherentType($this->db); $membertype = new AdherentType($this->db);
$result = $membertype->fetch($id); $result = $membertype->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member type not found'); throw new RestException(404, 'member type not found');
} }
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') continue;
// Process the status separately because it must be updated using // Process the status separately because it must be updated using
// the validate() and resiliate() methods of the class AdherentType. // the validate() and resiliate() methods of the class AdherentType.
$membertype->$field = $value; $membertype->$field = $value;
} }
// If there is no error, update() returns the number of affected rows // If there is no error, update() returns the number of affected rows
// so if the update is a no op, the return value is zero. // so if the update is a no op, the return value is zero.
if ($membertype->update(DolibarrApiAccess::$user) >= 0) { if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
return $this->get($id); return $this->get($id);
} else { } else {
throw new RestException(500, $membertype->error); throw new RestException(500, $membertype->error);
} }
} }
/** /**
* Delete member type * Delete member type
* *
* @param int $id member type ID * @param int $id member type ID
* @return array * @return array
*/ */
public function delete($id) public function delete($id)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->configurer) { if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
throw new RestException(401); throw new RestException(401);
} }
$membertype = new AdherentType($this->db); $membertype = new AdherentType($this->db);
$result = $membertype->fetch($id); $result = $membertype->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'member type not found'); throw new RestException(404, 'member type not found');
} }
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) { if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
} }
if (!$membertype->delete()) { if (!$membertype->delete()) {
throw new RestException(401, 'error when deleting member type'); throw new RestException(401, 'error when deleting member type');
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'member type deleted' 'message' => 'member type deleted'
) )
); );
} }
/** /**
* Validate fields before creating an object * Validate fields before creating an object
* *
* @param array|null $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
private function _validate($data) private function _validate($data)
{ {
$membertype = array(); $membertype = array();
foreach (MembersTypes::$FIELDS as $field) { foreach (MembersTypes::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$membertype[$field] = $data[$field]; $membertype[$field] = $data[$field];
} }
return $membertype; return $membertype;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/** /**
* Clean sensible object datas * Clean sensible object datas
* *
* @param object $object Object to clean * @param Object $object Object to clean
* @return array Array of cleaned object properties * @return Object Object with cleaned properties
*/ */
protected function _cleanObjectDatas($object) protected function _cleanObjectDatas($object)
{ {
// phpcs:enable // phpcs:enable
$object = parent::_cleanObjectDatas($object); $object = parent::_cleanObjectDatas($object);
unset($object->array_options); unset($object->array_options);
unset($object->linkedObjectsIds); unset($object->linkedObjectsIds);
unset($object->context); unset($object->context);
unset($object->canvas); unset($object->canvas);
unset($object->fk_project); unset($object->fk_project);
unset($object->contact); unset($object->contact);
unset($object->contact_id); unset($object->contact_id);
unset($object->thirdparty); unset($object->thirdparty);
unset($object->user); unset($object->user);
unset($object->origin); unset($object->origin);
unset($object->origin_id); unset($object->origin_id);
unset($object->ref_ext); unset($object->ref_ext);
unset($object->country); unset($object->country);
unset($object->country_id); unset($object->country_id);
unset($object->country_code); unset($object->country_code);
unset($object->barcode_type); unset($object->barcode_type);
unset($object->barcode_type_code); unset($object->barcode_type_code);
unset($object->barcode_type_label); unset($object->barcode_type_label);
unset($object->barcode_type_coder); unset($object->barcode_type_coder);
unset($object->mode_reglement_id); unset($object->mode_reglement_id);
unset($object->cond_reglement_id); unset($object->cond_reglement_id);
unset($object->cond_reglement); unset($object->cond_reglement);
unset($object->fk_delivery_address); unset($object->fk_delivery_address);
unset($object->shipping_method_id); unset($object->shipping_method_id);
unset($object->model_pdf); unset($object->model_pdf);
unset($object->fk_account); unset($object->fk_account);
unset($object->note_public); unset($object->note_public);
unset($object->note_private); unset($object->note_private);
unset($object->fk_incoterms); unset($object->fk_incoterms);
unset($object->label_incoterms); unset($object->label_incoterms);
unset($object->location_incoterms); unset($object->location_incoterms);
unset($object->name); unset($object->name);
unset($object->lastname); unset($object->lastname);
unset($object->firstname); unset($object->firstname);
unset($object->civility_id); unset($object->civility_id);
unset($object->total_ht); unset($object->total_ht);
unset($object->total_tva); unset($object->total_tva);
unset($object->total_localtax1); unset($object->total_localtax1);
unset($object->total_localtax2); unset($object->total_localtax2);
unset($object->total_ttc); unset($object->total_ttc);
return $object; return $object;
} }
} }

View File

@ -27,219 +27,219 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
*/ */
class Subscriptions extends DolibarrApi class Subscriptions extends DolibarrApi
{ {
/** /**
* @var array $FIELDS Mandatory fields, checked when create and update object * @var array $FIELDS Mandatory fields, checked when create and update object
*/ */
static $FIELDS = array( static $FIELDS = array(
'fk_adherent', 'fk_adherent',
'dateh', 'dateh',
'datef', 'datef',
'amount', 'amount',
); );
/** /**
* Constructor * Constructor
*/ */
public function __construct() public function __construct()
{ {
global $db, $conf; global $db, $conf;
$this->db = $db; $this->db = $db;
} }
/** /**
* Get properties of a subscription object * Get properties of a subscription object
* *
* Return an array with subscription informations * Return an array with subscription informations
* *
* @param int $id ID of subscription * @param int $id ID of subscription
* @return array|mixed data without useless information * @return Object data without useless information
* *
* @throws RestException * @throws RestException
*/ */
public function get($id) public function get($id)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
throw new RestException(401); throw new RestException(401);
} }
$subscription = new Subscription($this->db); $subscription = new Subscription($this->db);
$result = $subscription->fetch($id); $result = $subscription->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Subscription not found'); throw new RestException(404, 'Subscription not found');
} }
return $this->_cleanObjectDatas($subscription); return $this->_cleanObjectDatas($subscription);
} }
/** /**
* List subscriptions * List subscriptions
* *
* Get a list of subscriptions * Get a list of subscriptions
* *
* @param string $sortfield Sort field * @param string $sortfield Sort field
* @param string $sortorder Sort order * @param string $sortorder Sort order
* @param int $limit Limit for list * @param int $limit Limit for list
* @param int $page Page number * @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')" * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.import_key:<:'20160101')"
* @return array Array of subscription objects * @return array Array of subscription objects
* *
* @throws RestException * @throws RestException
*/ */
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
{ {
global $db, $conf; global $db, $conf;
$obj_ret = array(); $obj_ret = array();
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
throw new RestException(401); throw new RestException(401);
} }
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."subscription as t"; $sql .= " FROM ".MAIN_DB_PREFIX."subscription as t";
$sql .= ' WHERE 1 = 1'; $sql .= ' WHERE 1 = 1';
// Add sql filters // Add sql filters
if ($sqlfilters) { if ($sqlfilters) {
if (!DolibarrApi::_checkFilters($sqlfilters)) { if (!DolibarrApi::_checkFilters($sqlfilters)) {
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
} }
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
} }
$sql .= $this->db->order($sortfield, $sortorder); $sql .= $this->db->order($sortfield, $sortorder);
if ($limit) { if ($limit) {
if ($page < 0) { if ($page < 0) {
$page = 0; $page = 0;
} }
$offset = $limit * $page; $offset = $limit * $page;
$sql .= $this->db->plimit($limit + 1, $offset); $sql .= $this->db->plimit($limit + 1, $offset);
} }
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
$i = 0; $i = 0;
$num = $this->db->num_rows($result); $num = $this->db->num_rows($result);
while ($i < min($limit, $num)) { while ($i < min($limit, $num)) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$subscription = new Subscription($this->db); $subscription = new Subscription($this->db);
if ($subscription->fetch($obj->rowid)) { if ($subscription->fetch($obj->rowid)) {
$obj_ret[] = $this->_cleanObjectDatas($subscription); $obj_ret[] = $this->_cleanObjectDatas($subscription);
} }
$i++; $i++;
} }
} else { } else {
throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror()); throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror());
} }
if (!count($obj_ret)) { if (!count($obj_ret)) {
throw new RestException(404, 'No Subscription found'); throw new RestException(404, 'No Subscription found');
} }
return $obj_ret; return $obj_ret;
} }
/** /**
* Create subscription object * Create subscription object
* *
* @param array $request_data Request data * @param array $request_data Request data
* @return int ID of subscription * @return int ID of subscription
*/ */
public function post($request_data = null) public function post($request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
throw new RestException(401); throw new RestException(401);
} }
// Check mandatory fields // Check mandatory fields
$result = $this->_validate($request_data); $result = $this->_validate($request_data);
$subscription = new Subscription($this->db); $subscription = new Subscription($this->db);
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
$subscription->$field = $value; $subscription->$field = $value;
} }
if ($subscription->create(DolibarrApiAccess::$user) < 0) { if ($subscription->create(DolibarrApiAccess::$user) < 0) {
throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors)); throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors));
} }
return $subscription->id; return $subscription->id;
} }
/** /**
* Update subscription * Update subscription
* *
* @param int $id ID of subscription to update * @param int $id ID of subscription to update
* @param array $request_data Datas * @param array $request_data Datas
* @return int * @return Object
*/ */
public function put($id, $request_data = null) public function put($id, $request_data = null)
{ {
if (!DolibarrApiAccess::$user->rights->adherent->creer) { if (!DolibarrApiAccess::$user->rights->adherent->creer) {
throw new RestException(401); throw new RestException(401);
} }
$subscription = new Subscription($this->db); $subscription = new Subscription($this->db);
$result = $subscription->fetch($id); $result = $subscription->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Subscription not found'); throw new RestException(404, 'Subscription not found');
} }
foreach ($request_data as $field => $value) { foreach ($request_data as $field => $value) {
if ($field == 'id') continue; if ($field == 'id') continue;
$subscription->$field = $value; $subscription->$field = $value;
} }
if ($subscription->update(DolibarrApiAccess::$user) > 0) { if ($subscription->update(DolibarrApiAccess::$user) > 0) {
return $this->get($id); return $this->get($id);
} else { } else {
throw new RestException(500, $subscription->error); throw new RestException(500, $subscription->error);
} }
} }
/** /**
* Delete subscription * Delete subscription
* *
* @param int $id ID of subscription to delete * @param int $id ID of subscription to delete
* @return array * @return array
*/ */
public function delete($id) public function delete($id)
{ {
// The right to delete a subscription comes with the right to create one. // The right to delete a subscription comes with the right to create one.
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
throw new RestException(401); throw new RestException(401);
} }
$subscription = new Subscription($this->db); $subscription = new Subscription($this->db);
$result = $subscription->fetch($id); $result = $subscription->fetch($id);
if (!$result) { if (!$result) {
throw new RestException(404, 'Subscription not found'); throw new RestException(404, 'Subscription not found');
} }
if (!$subscription->delete(DolibarrApiAccess::$user)) { if (!$subscription->delete(DolibarrApiAccess::$user)) {
throw new RestException(401, 'error when deleting subscription'); throw new RestException(401, 'error when deleting subscription');
} }
return array( return array(
'success' => array( 'success' => array(
'code' => 200, 'code' => 200,
'message' => 'subscription deleted' 'message' => 'subscription deleted'
) )
); );
} }
/** /**
* Validate fields before creating an object * Validate fields before creating an object
* *
* @param array|null $data Data to validate * @param array|null $data Data to validate
* @return array * @return array
* *
* @throws RestException * @throws RestException
*/ */
private function _validate($data) private function _validate($data)
{ {
$subscription = array(); $subscription = array();
foreach (Subscriptions::$FIELDS as $field) { foreach (Subscriptions::$FIELDS as $field) {
if (!isset($data[$field])) if (!isset($data[$field]))
throw new RestException(400, "$field field missing"); throw new RestException(400, "$field field missing");
$subscription[$field] = $data[$field]; $subscription[$field] = $data[$field];
} }
return $subscription; return $subscription;
} }
} }

View File

@ -32,435 +32,435 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/ */
class Subscription extends CommonObject class Subscription extends CommonObject
{ {
/** /**
* @var string ID to identify managed object * @var string ID to identify managed object
*/ */
public $element = 'subscription'; public $element = 'subscription';
/** /**
* @var string Name of table without prefix where object is stored * @var string Name of table without prefix where object is stored
*/ */
public $table_element = 'subscription'; public $table_element = 'subscription';
/** /**
* @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table
*/ */
public $ismultientitymanaged = 'fk_adherent@adherent'; public $ismultientitymanaged = 'fk_adherent@adherent';
/** /**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/ */
public $picto = 'payment'; public $picto = 'payment';
/** /**
* Date creation record (datec) * Date creation record (datec)
* *
* @var integer * @var integer
*/ */
public $datec; public $datec;
/** /**
* Date modification record (tms) * Date modification record (tms)
* *
* @var integer * @var integer
*/ */
public $datem; public $datem;
/** /**
* Subscription start date (date subscription) * Subscription start date (date subscription)
* *
* @var integer * @var integer
*/ */
public $dateh; public $dateh;
/** /**
* Subscription end date * Subscription end date
* *
* @var integer * @var integer
*/ */
public $datef; public $datef;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_type; public $fk_type;
public $fk_adherent; public $fk_adherent;
public $amount; public $amount;
/** /**
* @var int ID * @var int ID
*/ */
public $fk_bank; public $fk_bank;
public $fields = array( public $fields = array(
'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10),
'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15),
'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20), 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>20),
'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25), 'fk_adherent' =>array('type'=>'integer', 'label'=>'Member', 'enabled'=>1, 'visible'=>-1, 'position'=>25),
'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30), 'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35), 'datef' =>array('type'=>'datetime', 'label'=>'DateEndSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>35),
'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1), 'subscription' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>-1, 'position'=>40, 'isameasure'=>1),
'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45), 'fk_bank' =>array('type'=>'integer', 'label'=>'BankId', 'enabled'=>1, 'visible'=>-1, 'position'=>45),
'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50), 'note' =>array('type'=>'text', 'label'=>'Note', 'enabled'=>1, 'visible'=>-1, 'position'=>50),
'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'fk_type' =>array('type'=>'integer', 'label'=>'MemberType', 'enabled'=>1, 'visible'=>-1, 'position'=>55),
'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60), 'fk_user_creat' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>60),
'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65), 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
); );
/** /**
* Constructor * Constructor
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
public function __construct($db) public function __construct($db)
{ {
$this->db = $db; $this->db = $db;
} }
/** /**
* Function who permitted cretaion of the subscription * Function who permitted cretaion of the subscription
* *
* @param User $user User that create * @param User $user User that create
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, Id subscription created if OK * @return int <0 if KO, Id subscription created if OK
*/ */
public function create($user, $notrigger = false) public function create($user, $notrigger = false)
{ {
global $langs; global $langs;
$error = 0; $error = 0;
$now = dol_now(); $now = dol_now();
// Check parameters // Check parameters
if ($this->datef <= $this->dateh) { if ($this->datef <= $this->dateh) {
$this->error = $langs->trans("ErrorBadValueForDate"); $this->error = $langs->trans("ErrorBadValueForDate");
return -1; return -1;
} }
if (empty($this->datec)) $this->datec = $now; if (empty($this->datec)) $this->datec = $now;
$this->db->begin(); $this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)";
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($this->fk_adherent); $result = $member->fetch($this->fk_adherent);
if ($this->fk_type == null) { // If type not defined, we use the type of member if ($this->fk_type == null) { // If type not defined, we use the type of member
$type = $member->typeid; $type = $member->typeid;
} else { } else {
$type = $this->fk_type; $type = $this->fk_type;
} }
$sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; $sql .= " VALUES (".$this->fk_adherent.", '".$this->db->escape($type)."', '".$this->db->idate($now)."',";
$sql .= " '".$this->db->idate($this->dateh)."',"; $sql .= " '".$this->db->idate($this->dateh)."',";
$sql .= " '".$this->db->idate($this->datef)."',"; $sql .= " '".$this->db->idate($this->datef)."',";
$sql .= " ".$this->amount.","; $sql .= " ".$this->amount.",";
$sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')"; $sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->errors[] = $this->db->lasterror(); $this->errors[] = $this->db->lasterror();
} }
if (!$error) { if (!$error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
$this->fk_type = $type; $this->fk_type = $type;
} }
if (!$error && !$notrigger) { if (!$error && !$notrigger) {
$this->context = array('member'=>$member); $this->context = array('member' => $member);
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); $result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
if ($result < 0) { $error++; } if ($result < 0) { $error++; }
// End call triggers // End call triggers
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} else { } else {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} }
} }
/** /**
* Method to load a subscription * Method to load a subscription
* *
* @param int $rowid Id subscription * @param int $rowid Id subscription
* @return int <0 if KO, =0 if not found, >0 if OK * @return int <0 if KO, =0 if not found, >0 if OK
*/ */
public function fetch($rowid) public function fetch($rowid)
{ {
$sql = "SELECT rowid, fk_type, fk_adherent, datec,"; $sql = "SELECT rowid, fk_type, fk_adherent, datec,";
$sql .= " tms,"; $sql .= " tms,";
$sql .= " dateadh as dateh,"; $sql .= " dateadh as dateh,";
$sql .= " datef,"; $sql .= " datef,";
$sql .= " subscription, note, fk_bank"; $sql .= " subscription, note, fk_bank";
$sql .= " FROM ".MAIN_DB_PREFIX."subscription"; $sql .= " FROM ".MAIN_DB_PREFIX."subscription";
$sql .= " WHERE rowid=".$rowid; $sql .= " WHERE rowid=".$rowid;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($this->db->num_rows($resql)) { if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->fk_type = $obj->fk_type; $this->fk_type = $obj->fk_type;
$this->fk_adherent = $obj->fk_adherent; $this->fk_adherent = $obj->fk_adherent;
$this->datec = $this->db->jdate($obj->datec); $this->datec = $this->db->jdate($obj->datec);
$this->datem = $this->db->jdate($obj->tms); $this->datem = $this->db->jdate($obj->tms);
$this->dateh = $this->db->jdate($obj->dateh); $this->dateh = $this->db->jdate($obj->dateh);
$this->datef = $this->db->jdate($obj->datef); $this->datef = $this->db->jdate($obj->datef);
$this->amount = $obj->subscription; $this->amount = $obj->subscription;
$this->note = $obj->note; $this->note = $obj->note;
$this->fk_bank = $obj->fk_bank; $this->fk_bank = $obj->fk_bank;
return 1; return 1;
} else { } else {
return 0; return 0;
} }
} else { } else {
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
return -1; return -1;
} }
} }
/** /**
* Update subscription * Update subscription
* *
* @param User $user User who updated * @param User $user User who updated
* @param int $notrigger 0=Disable triggers * @param int $notrigger 0=Disable triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function update($user, $notrigger = 0) public function update($user, $notrigger = 0)
{ {
$error = 0; $error = 0;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
$sql .= " fk_type = ".$this->fk_type.","; $sql .= " fk_type = ".$this->fk_type.",";
$sql .= " fk_adherent = ".$this->fk_adherent.","; $sql .= " fk_adherent = ".$this->fk_adherent.",";
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
$sql .= " subscription = '".price2num($this->amount)."',"; $sql .= " subscription = '".price2num($this->amount)."',";
$sql .= " dateadh='".$this->db->idate($this->dateh)."',"; $sql .= " dateadh='".$this->db->idate($this->dateh)."',";
$sql .= " datef='".$this->db->idate($this->datef)."',"; $sql .= " datef='".$this->db->idate($this->datef)."',";
$sql .= " datec='".$this->db->idate($this->datec)."',"; $sql .= " datec='".$this->db->idate($this->datec)."',";
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($this->fk_adherent); $result = $member->fetch($this->fk_adherent);
$result = $member->update_end_date($user); $result = $member->update_end_date($user);
if (!$error && !$notrigger) { if (!$error && !$notrigger) {
$this->context = array('member'=>$member); $this->context = array('member'=>$member);
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); $result = $this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user);
if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail
// End call triggers // End call triggers
} }
} else { } else {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} else { } else {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} }
} }
/** /**
* Delete a subscription * Delete a subscription
* *
* @param User $user User that delete * @param User $user User that delete
* @param bool $notrigger false=launch triggers after, true=disable triggers * @param bool $notrigger false=launch triggers after, true=disable triggers
* @return int <0 if KO, 0 if not found, >0 if OK * @return int <0 if KO, 0 if not found, >0 if OK
*/ */
public function delete($user, $notrigger = false) public function delete($user, $notrigger = false)
{ {
$error = 0; $error = 0;
// It subscription is linked to a bank transaction, we get it // It subscription is linked to a bank transaction, we get it
if ($this->fk_bank > 0) { if ($this->fk_bank > 0) {
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$accountline = new AccountLine($this->db); $accountline = new AccountLine($this->db);
$result = $accountline->fetch($this->fk_bank); $result = $accountline->fetch($this->fk_bank);
} }
$this->db->begin(); $this->db->begin();
if (!$error) { if (!$error) {
if (!$notrigger) { if (!$notrigger) {
// Call triggers // Call triggers
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); $result = $this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user);
if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
// End call triggers // End call triggers
} }
} }
if (!$error) { if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->affected_rows($resql); $num = $this->db->affected_rows($resql);
if ($num) { if ($num) {
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$member = new Adherent($this->db); $member = new Adherent($this->db);
$result = $member->fetch($this->fk_adherent); $result = $member->fetch($this->fk_adherent);
$result = $member->update_end_date($user); $result = $member->update_end_date($user);
if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined) if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) { // If we found bank account line (this means this->fk_bank defined)
$result = $accountline->delete($user); // Return false if refused because line is conciliated $result = $accountline->delete($user); // Return false if refused because line is conciliated
if ($result > 0) { if ($result > 0) {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} else { } else {
$this->error = $accountline->error; $this->error = $accountline->error;
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
} else { } else {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} else { } else {
$this->db->commit(); $this->db->commit();
return 0; return 0;
} }
} else { } else {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
} }
// Commit or rollback // Commit or rollback
if ($error) { if ($error) {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} else { } else {
$this->db->commit(); $this->db->commit();
return 1; return 1;
} }
} }
/** /**
* Return clicable name (with picto eventually) * Return clicable name (with picto eventually)
* *
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
* @param int $notooltip 1=Disable tooltip * @param int $notooltip 1=Disable tooltip
* @param string $option Page for link ('', 'nolink', ...) * @param string $option Page for link ('', 'nolink', ...)
* @param string $morecss Add more css on link * @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string Chaine avec URL * @return string Chaine avec URL
*/ */
public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1)
{ {
global $langs; global $langs;
$result = ''; $result = '';
$langs->load("members"); $langs->load("members");
$label = $langs->trans("ShowSubscription").': '.$this->ref; $label = $langs->trans("ShowSubscription").': '.$this->ref;
$url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id;
if ($option != 'nolink') { if ($option != 'nolink') {
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
} }
$linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">'; $linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
$linkend = '</a>'; $linkend = '</a>';
$picto = 'payment'; $picto = 'payment';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref; if ($withpicto != 2) $result .= $this->ref;
$result .= $linkend; $result .= $linkend;
return $result; return $result;
} }
/** /**
* Retourne le libelle du statut d'une adhesion * Retourne le libelle du statut d'une adhesion
* *
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Label * @return string Label
*/ */
public function getLibStatut($mode = 0) public function getLibStatut($mode = 0)
{ {
return ''; return '';
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* *
* @param int $status Id status * @param int $status Id status
* @return string Label * @return string Label
*/ */
public function LibStatut($status) public function LibStatut($status)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->load("members"); $langs->load("members");
return ''; return '';
} }
/** /**
* Load information of the subscription object * Load information of the subscription object
* *
* @param int $id Id subscription * @param int $id Id subscription
* @return void * @return void
*/ */
public function info($id) public function info($id)
{ {
$sql = 'SELECT c.rowid, c.datec,'; $sql = 'SELECT c.rowid, c.datec,';
$sql .= ' c.tms as datem'; $sql .= ' c.tms as datem';
$sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; $sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
$sql .= ' WHERE c.rowid = '.$id; $sql .= ' WHERE c.rowid = '.$id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
if ($this->db->num_rows($result)) { if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->datem); $this->date_modification = $this->db->jdate($obj->datem);
} }
$this->db->free($result); $this->db->free($result);
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
} }

View File

@ -37,7 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
$langs->loadLangs(array("companies", "members", "other")); $langs->loadLangs(array("companies", "members", "other"));
$id = GETPOST('id', 'int'); $id = GETPOSTISSET('id') ? GETPOST('id', 'int') : GETPOST('rowid', 'int');
$ref = GETPOST('ref', 'alphanohtml');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
@ -60,7 +61,7 @@ if (!$sortfield) $sortfield = "name";
$form = new Form($db); $form = new Form($db);
$object = new Adherent($db); $object = new Adherent($db);
$membert = new AdherentType($db); $membert = new AdherentType($db);
$result = $object->fetch($id); $result = $object->fetch($id, $ref);
if ($result < 0) { if ($result < 0) {
dol_print_error($db); dol_print_error($db);
exit; exit;
@ -86,7 +87,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Mi
llxHeader("", $title, $helpurl); llxHeader("", $title, $helpurl);
if ($id > 0) { if ($id > 0) {
$result = $membert->fetch($object->typeid); $result = $membert->fetch($object->typeid);
if ($result > 0) { if ($result > 0) {
// Build file list // Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
@ -95,47 +96,47 @@ if ($id > 0) {
$totalsize += $file['size']; $totalsize += $file['size'];
} }
if (!empty($conf->notification->enabled)) if (!empty($conf->notification->enabled))
$langs->load("mails"); $langs->load("mails");
$head = member_prepare_head($object); $head = member_prepare_head($object);
print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user'); print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback); dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
} }
// Type // Type
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n"; print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
// Morphy // Morphy
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
print $form->showphoto('memberphoto',$object); print $form->showphoto('memberphoto',$object);
print '</td>';*/ print '</td>';*/
print '</tr>'; print '</tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
print '</tr>'; print '</tr>';
// Number of Attached Files // Number of Attached Files
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
//Total Size Of Attached Files //Total Size Of Attached Files
@ -157,7 +158,7 @@ if ($id > 0) {
dol_print_error($db); dol_print_error($db);
} }
} else { } else {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("ErrorRecordNotFound"); print $langs->trans("ErrorRecordNotFound");
} }

View File

@ -125,29 +125,29 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
// Search contact/address // Search contact/address
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) { if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
$listofsearchfields['search_member'] = array('text'=>'Member'); $listofsearchfields['search_member'] = array('text'=>'Member');
} }
if (count($listofsearchfields)) { if (count($listofsearchfields)) {
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">'; print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
$i = 0; $i = 0;
foreach ($listofsearchfields as $key => $value) { foreach ($listofsearchfields as $key => $value) {
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>'; if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>'; print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>'; if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} }
} }
@ -158,53 +158,53 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'; print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr><td class="center" colspan="2">'; print '<tr><td class="center" colspan="2">';
$SommeA = 0; $SommeA = 0;
$SommeB = 0; $SommeB = 0;
$SommeC = 0; $SommeC = 0;
$SommeD = 0; $SommeD = 0;
$total = 0; $total = 0;
$dataval = array(); $dataval = array();
$i = 0; $i = 0;
foreach ($AdherentType as $key => $adhtype) { foreach ($AdherentType as $key => $adhtype) {
$dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0); $dataval['draft'][] = array($i, isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0);
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0); $dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0);
$dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0); $dataval['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0);
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0); $dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
$SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0; $SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0;
$SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0; $SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0;
$SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0; $SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0;
$SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0; $SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
$i++; $i++;
} }
$total = $SommeA + $SommeB + $SommeC + $SommeD; $total = $SommeA + $SommeB + $SommeC + $SommeD;
$dataseries = array(); $dataseries = array();
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB)); $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB));
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC)); $dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD)); $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD));
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA)); $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA));
include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph(); $dolgraph = new DolGraph();
$dolgraph->SetData($dataseries); $dolgraph->SetData($dataseries);
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0)); $dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0));
$dolgraph->setShowLegend(2); $dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1); $dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie')); $dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200'); $dolgraph->setHeight('200');
$dolgraph->draw('idgraphstatus'); $dolgraph->draw('idgraphstatus');
print $dolgraph->show($total ? 0 : 1); print $dolgraph->show($total ? 0 : 1);
print '</td></tr>'; print '</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'; print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
print $SommeA + $SommeB + $SommeC + $SommeD; print $SommeA + $SommeB + $SommeC + $SommeD;
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }
print '<br>'; print '<br>';
@ -223,17 +223,17 @@ $sql .= " AND d.rowid = c.fk_adherent";
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$year = dol_print_date($db->jdate($objp->dateh), "%Y"); $year = dol_print_date($db->jdate($objp->dateh), "%Y");
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
$tot += $objp->subscription; $tot += $objp->subscription;
$numb += 1; $numb += 1;
$i++; $i++;
} }
} }
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -258,12 +258,12 @@ foreach ($Total as $key=>$value) {
break; break;
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>"; print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
print "<td class=\"right\">".$Number[$key]."</td>"; print "<td class=\"right\">".$Number[$key]."</td>";
print "<td class=\"right\">".price($value)."</td>"; print "<td class=\"right\">".price($value)."</td>";
print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>"; print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>";
print "</tr>\n"; print "</tr>\n";
$i++; $i++;
} }
// Total // Total
@ -284,10 +284,10 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
*/ */
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql .= " a.gender, a.email, a.photo, a.morphy,"; $sql .= " a.gender, a.email, a.photo, a.morphy,";
$sql .= " a.tms as datem, datefin as date_end_subscription,"; $sql .= " a.tms as datem, a.datefin as date_end_subscription,";
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription"; $sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")";
$sql .= " AND a.fk_adherent_type = ta.rowid"; $sql .= " AND a.fk_adherent_type = ta.rowid";
@ -306,7 +306,7 @@ if ($resql) {
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
$staticmember->id = $obj->rowid; $staticmember->id = $obj->rowid;
$staticmember->ref = $obj->rowid; $staticmember->ref = $obj->rowid;
$staticmember->lastname = $obj->lastname; $staticmember->lastname = $obj->lastname;
@ -315,6 +315,9 @@ if ($resql) {
$staticmember->email = $obj->email; $staticmember->email = $obj->email;
$staticmember->photo = $obj->photo; $staticmember->photo = $obj->photo;
$staticmember->morphy = $obj->morphy; $staticmember->morphy = $obj->morphy;
$staticmember->statut = $obj->status;
$staticmember->need_subscription = $obj->need_subscription;
$staticmember->datefin = $db->jdate($obj->date_end_subscription);
if (!empty($obj->fk_soc)) { if (!empty($obj->fk_soc)) {
$staticmember->fk_soc = $obj->fk_soc; $staticmember->fk_soc = $obj->fk_soc;
$staticmember->fetch_thirdparty(); $staticmember->fetch_thirdparty();
@ -322,12 +325,16 @@ if ($resql) {
} else { } else {
$staticmember->name = $obj->company; $staticmember->name = $obj->company;
} }
$statictype->id = $obj->typeid; $statictype->id = $obj->typeid;
$statictype->label = $obj->label; $statictype->label = $obj->label;
$statictype->subscription = $obj->need_subscription;
print '<tr class="oddeven">';
print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32).'</td>'; print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32).'</td>';
print '<td>'.$statictype->getNomUrl(1, 32).'</td>'; print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>'; print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).'</td>'; print '<td class="right">'.$staticmember->getLibStatut(3).'</td>';
print '</tr>'; print '</tr>';
$i++; $i++;
} }
@ -344,12 +351,14 @@ if ($resql) {
*/ */
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,"; $sql = "SELECT a.rowid, a.statut as status, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
$sql .= " a.gender, a.email, a.photo, a.morphy,"; $sql .= " a.gender, a.email, a.photo, a.morphy,";
$sql .= " a.datefin as date_end_subscription,"; $sql .= " a.datefin as date_end_subscription,";
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription as need_subscription,";
$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription"; $sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " WHERE a.entity IN (".getEntity('adherent').")"; $sql .= " WHERE a.entity IN (".getEntity('adherent').")";
$sql .= " AND a.fk_adherent_type = ta.rowid";
$sql .= " AND c.fk_adherent = a.rowid"; $sql .= " AND c.fk_adherent = a.rowid";
$sql .= $db->order("c.tms", "DESC"); $sql .= $db->order("c.tms", "DESC");
$sql .= $db->plimit($max, 0); $sql .= $db->plimit($max, 0);
@ -366,9 +375,7 @@ if ($resql) {
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
$subscriptionstatic->id = $obj->cid;
$subscriptionstatic->ref = $obj->cid;
$staticmember->id = $obj->rowid; $staticmember->id = $obj->rowid;
$staticmember->ref = $obj->rowid; $staticmember->ref = $obj->rowid;
$staticmember->lastname = $obj->lastname; $staticmember->lastname = $obj->lastname;
@ -377,6 +384,9 @@ if ($resql) {
$staticmember->email = $obj->email; $staticmember->email = $obj->email;
$staticmember->photo = $obj->photo; $staticmember->photo = $obj->photo;
$staticmember->morphy = $obj->morphy; $staticmember->morphy = $obj->morphy;
$staticmember->statut = $obj->status;
$staticmember->need_subscription = $obj->need_subscription;
$staticmember->datefin = $db->jdate($obj->date_end_subscription);
if (!empty($obj->fk_soc)) { if (!empty($obj->fk_soc)) {
$staticmember->fk_soc = $obj->fk_soc; $staticmember->fk_soc = $obj->fk_soc;
$staticmember->fetch_thirdparty(); $staticmember->fetch_thirdparty();
@ -384,6 +394,11 @@ if ($resql) {
} else { } else {
$staticmember->name = $obj->company; $staticmember->name = $obj->company;
} }
$subscriptionstatic->id = $obj->cid;
$subscriptionstatic->ref = $obj->cid;
print '<tr class="oddeven">';
print '<td class="nowraponall">'.$subscriptionstatic->getNomUrl(1).'</td>'; print '<td class="nowraponall">'.$subscriptionstatic->getNomUrl(1).'</td>';
print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>'; print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>';
print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>'; print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';

View File

@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09');
// Protection // Protection
$socid = 0; $socid = 0;
if ($user->socid > 0) { if ($user->socid > 0) {
$socid = $user->socid; $socid = $user->socid;
} }
$object = new Adherent($db); $object = new Adherent($db);
@ -165,24 +165,24 @@ if ($result > 0) {
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
if (empty($dn)) { if (empty($dn)) {
$langs->load("errors"); $langs->load("errors");
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
} else { } else {
$records = $ldap->getAttribute($dn, $search); $records = $ldap->getAttribute($dn, $search);
//print_r($records); //print_r($records);
// Show tree // Show tree
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
if (!is_array($records)) { if (!is_array($records)) {
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} else { } else {
$result = show_ldap_content($records, 0, $records['count'], true); $result = show_ldap_content($records, 0, $records['count'], true);
} }
} else { } else {
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
} }
} }
$ldap->unbind(); $ldap->unbind();
$ldap->close(); $ldap->close();

View File

@ -204,30 +204,30 @@ if (empty($reshook)) {
// Close // Close
if ($massaction == 'close' && $user->rights->adherent->creer) { if ($massaction == 'close' && $user->rights->adherent->creer) {
$tmpmember = new Adherent($db); $tmpmember = new Adherent($db);
$error = 0; $error = 0;
$nbclose = 0; $nbclose = 0;
$db->begin(); $db->begin();
foreach ($toselect as $idtoclose) { foreach ($toselect as $idtoclose) {
$tmpmember->fetch($idtoclose); $tmpmember->fetch($idtoclose);
$result = $tmpmember->resiliate($user); $result = $tmpmember->resiliate($user);
if ($result < 0 && !count($tmpmember->errors)) { if ($result < 0 && !count($tmpmember->errors)) {
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors'); setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
} else { } else {
if ($result > 0) $nbclose++; if ($result > 0) $nbclose++;
} }
} }
if (!$error) { if (!$error) {
setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs'); setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
} }
} }
// Mass actions // Mass actions
@ -409,7 +409,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->adherent->creer) { if ($user->rights->adherent->creer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewMember'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/card.php?action=create');
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
@ -560,7 +560,7 @@ if (!empty($arrayfields['d.email']['checked'])) {
// End of subscription date // End of subscription date
if (!empty($arrayfields['d.datefin']['checked'])) { if (!empty($arrayfields['d.datefin']['checked'])) {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
$selectarray=array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate")); $selectarray = array('-1'=>'', 'withoutsubscription'=>$langs->trans("WithoutSubscription"), 'uptodate'=>$langs->trans("UpToDate"), 'outofdate'=>$langs->trans("OutOfDate"));
print $form->selectarray('search_filter', $selectarray, $search_filter); print $form->selectarray('search_filter', $selectarray, $search_filter);
print '</td>'; print '</td>';
} }

View File

@ -40,8 +40,8 @@ $result = restrictedArea($user, 'adherent', $id);
$object = new Adherent($db); $object = new Adherent($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0) { if ($result > 0) {
$adht = new AdherentType($db); $adht = new AdherentType($db);
$result = $adht->fetch($object->typeid); $result = $adht->fetch($object->typeid);
} }
$permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->adherent->creer; // Used by the include of actions_setnotes.inc.php
@ -75,44 +75,44 @@ if ($id) {
dol_banner_tab($object, 'id', $linkback); dol_banner_tab($object, 'id', $linkback);
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Login // Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) {
print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>'; print '<tr><td class="titlefield">'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$object->login.'&nbsp;</td></tr>';
} }
// Type // Type
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n"; print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
// Morphy // Morphy
print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>'; print '<tr><td class="titlefield">'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib().'</td>';
/*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">'; /*print '<td rowspan="'.$rowspan.'" class="center" valign="middle" width="25%">';
print $form->showphoto('memberphoto',$member); print $form->showphoto('memberphoto',$member);
print '</td>';*/ print '</td>';*/
print '</tr>'; print '</tr>';
// Company // Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>'; print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
// Civility // Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>'; print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</td>';
print '</tr>'; print '</tr>';
print "</table>"; print "</table>";
print '</div>'; print '</div>';
$cssclass = 'titlefield'; $cssclass = 'titlefield';
$permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php $permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print dol_get_fiche_end(); print dol_get_fiche_end();
} }
// End of page // End of page

View File

@ -34,8 +34,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : '';
// Security check // Security check
if ($user->socid > 0) { if ($user->socid > 0) {
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
@ -69,7 +69,7 @@ $sql .= " d.morphy as code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut != -1"; // Not draft $sql .= " AND d.statut != -1"; // Not draft
$sql .= " GROUP BY d.morphy"; $sql .= " GROUP BY d.morphy";
$foundphy = $foundmor = 0; $foundphy = $foundmor = 0;
@ -100,7 +100,7 @@ $sql .= " d.morphy as code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0) $sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0)
$sql .= " GROUP BY d.morphy"; $sql .= " GROUP BY d.morphy";
$foundphy = $foundmor = 0; $foundphy = $foundmor = 0;

View File

@ -35,8 +35,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : '';
// Security check // Security check
if ($user->socid > 0) { if ($user->socid > 0) {
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
@ -68,129 +68,129 @@ print load_fiche_titre($title, '', 'object_group');
dol_mkdir($dir); dol_mkdir($dir);
if ($mode) { if ($mode) {
// Define sql // Define sql
if ($mode == 'memberbycountry') { if ($mode == 'memberbycountry') {
$label = $langs->trans("Country"); $label = $langs->trans("Country");
$tab = 'statscountry'; $tab = 'statscountry';
$data = array(); $data = array();
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut != -1"; $sql .= " AND d.statut != -1";
$sql .= " GROUP BY c.label, c.code"; $sql .= " GROUP BY c.label, c.code";
//print $sql; //print $sql;
} }
if ($mode == 'memberbystate') { if ($mode == 'memberbystate') {
$label = $langs->trans("Country");
$label2 = $langs->trans("State");
$tab = 'statsstate';
$data = array();
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY co.label, co.code, c.nom";
//print $sql;
}
if ($mode == 'memberbyregion') { //
$label = $langs->trans("Country"); $label = $langs->trans("Country");
$label2 = $langs->trans("Region"); //département $label2 = $langs->trans("State");
$tab = 'statsregion'; //onglet $tab = 'statsstate';
$data = array(); //tableau de donnée $data = array();
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; //
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut != -1"; $sql .= " AND d.statut != -1";
$sql .= " GROUP BY co.label, co.code, r.nom"; //+ $sql .= " GROUP BY co.label, co.code, c.nom";
//print $sql; //print $sql;
} }
if ($mode == 'memberbytown') { if ($mode == 'memberbyregion') { //
$label = $langs->trans("Country"); $label = $langs->trans("Country");
$label2 = $langs->trans("Town"); $label2 = $langs->trans("Region"); //département
$tab = 'statstown'; $tab = 'statsregion'; //onglet
$data = array(); $data = array(); //tableau de donnée
$sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid";
$sql .= " AND d.statut != -1"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " GROUP BY c.label, c.code, d.town"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
//print $sql; $sql .= " AND d.statut != -1";
} $sql .= " GROUP BY co.label, co.code, r.nom"; //+
//print $sql;
}
if ($mode == 'memberbytown') {
$label = $langs->trans("Country");
$label2 = $langs->trans("Town");
$tab = 'statstown';
$langsen = new Translate('', $conf); $data = array();
$langsen->setDefaultLang('en_US'); $sql .= "SELECT COUNT(DISTINCT d.rowid) as nb, COUNT(s.rowid) as nbsubscriptions, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2";
$langsen->load("dict"); $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
//print $langsen->trans("Country"."FI");exit; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
$sql .= " AND d.statut != -1";
$sql .= " GROUP BY c.label, c.code, d.town";
//print $sql;
}
// Define $data array $langsen = new Translate('', $conf);
dol_syslog("Count member", LOG_DEBUG); $langsen->setDefaultLang('en_US');
$resql = $db->query($sql); $langsen->load("dict");
if ($resql) { //print $langsen->trans("Country"."FI");exit;
$num = $db->num_rows($resql);
$i = 0; // Define $data array
while ($i < $num) { dol_syslog("Count member", LOG_DEBUG);
$obj = $db->fetch_object($resql); $resql = $db->query($sql);
if ($mode == 'memberbycountry') { if ($resql) {
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), $num = $db->num_rows($resql);
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), $i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
if ($mode == 'memberbycountry') {
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'code'=>$obj->code, 'code'=>$obj->code,
'nb'=>$obj->nb, 'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate), 'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
); );
} }
if ($mode == 'memberbyregion') { //+ if ($mode == 'memberbyregion') { //+
$data[] = array( $data[] = array(
'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
'nb'=>$obj->nb, 'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate), 'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
); );
} }
if ($mode == 'memberbystate') { if ($mode == 'memberbystate') {
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
'nb'=>$obj->nb, 'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate), 'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
); );
} }
if ($mode == 'memberbytown') { if ($mode == 'memberbytown') {
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), $data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))), 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")), 'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
'nb'=>$obj->nb, 'nb'=>$obj->nb,
'lastdate'=>$db->jdate($obj->lastdate), 'lastdate'=>$db->jdate($obj->lastdate),
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
); );
} }
$i++; $i++;
} }
$db->free($resql); $db->free($resql);
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
} }
@ -201,101 +201,101 @@ print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user');
// Print title // Print title
if ($mode && !count($data)) { if ($mode && !count($data)) {
print $langs->trans("NoValidatedMemberYet").'<br>'; print $langs->trans("NoValidatedMemberYet").'<br>';
print '<br>'; print '<br>';
} else { } else {
if ($mode == 'memberbycountry') print '<span class="opacitymedium">'.$langs->trans("MembersByCountryDesc").'</span><br>'; if ($mode == 'memberbycountry') print '<span class="opacitymedium">'.$langs->trans("MembersByCountryDesc").'</span><br>';
elseif ($mode == 'memberbystate') print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>'; elseif ($mode == 'memberbystate') print '<span class="opacitymedium">'.$langs->trans("MembersByStateDesc").'</span><br>';
elseif ($mode == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>'; elseif ($mode == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+ elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
else { else {
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
print '<br>'; print '<br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>'; print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
print '<br>'; print '<br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>'; print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
print '<br>'; print '<br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>'; print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
print '<br>'; //+ print '<br>'; //+
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbyregion">'.$langs->trans("MembersStatisticsByRegion").'</a><br>'; //+ print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbyregion">'.$langs->trans("MembersStatisticsByRegion").'</a><br>'; //+
} }
print '<br>'; print '<br>';
} }
// Show graphics // Show graphics
if (count($arrayjs) && $mode == 'memberbycountry') { if (count($arrayjs) && $mode == 'memberbycountry') {
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; $color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
if (is_readable($color_file)) include_once $color_file; if (is_readable($color_file)) include_once $color_file;
// Assume we've already included the proper headers so just call our script inline // Assume we've already included the proper headers so just call our script inline
// More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR // More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
print "\n<script type='text/javascript'>\n"; print "\n<script type='text/javascript'>\n";
print "google.load('visualization', '1', {'packages': ['geomap']});\n"; print "google.load('visualization', '1', {'packages': ['geomap']});\n";
print "google.setOnLoadCallback(drawMap);\n"; print "google.setOnLoadCallback(drawMap);\n";
print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n"; print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
// Get the total number of rows // Get the total number of rows
print "\tdata.addRows(".count($data).");\n"; print "\tdata.addRows(".count($data).");\n";
print "\tdata.addColumn('string', 'Country');\n"; print "\tdata.addColumn('string', 'Country');\n";
print "\tdata.addColumn('number', 'Number');\n"; print "\tdata.addColumn('number', 'Number');\n";
// loop and dump // loop and dump
$i = 0; $i = 0;
foreach ($data as $val) { foreach ($data as $val) {
$valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster) $valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
//$valcountry=ucfirst($val['label_en']); //$valcountry=ucfirst($val['label_en']);
if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels) if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels)
print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n"; print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n"; print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
// Google's Geomap only supports up to 400 entries // Google's Geomap only supports up to 400 entries
if ($i >= 400) { break; } if ($i >= 400) { break; }
$i++; $i++;
} }
print "\tvar options = {};\n"; print "\tvar options = {};\n";
print "\toptions['dataMode'] = 'regions';\n"; print "\toptions['dataMode'] = 'regions';\n";
print "\toptions['showZoomOut'] = false;\n"; print "\toptions['showZoomOut'] = false;\n";
//print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n"; //print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
print "\toptions['width'] = ".$graphwidth.";\n"; print "\toptions['width'] = ".$graphwidth.";\n";
print "\toptions['height'] = ".$graphheight.";\n"; print "\toptions['height'] = ".$graphheight.";\n";
print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n"; print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n";
print "\tvar container = document.getElementById('".$mode."');\n"; print "\tvar container = document.getElementById('".$mode."');\n";
print "\tvar geomap = new google.visualization.GeoMap(container);\n"; print "\tvar geomap = new google.visualization.GeoMap(container);\n";
print "\tgeomap.draw(data, options);\n"; print "\tgeomap.draw(data, options);\n";
print "};\n"; print "};\n";
print "</script>\n"; print "</script>\n";
// print the div tag that will contain the map // print the div tag that will contain the map
print '<div class="center" id="'.$mode.'"></div>'."\n"; print '<div class="center" id="'.$mode.'"></div>'."\n";
print '<br>'; print '<br>';
} }
if ($mode) { if ($mode) {
// Print array // Print array
print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
print '<table class="liste centpercent">'; print '<table class="liste centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$label.'</td>'; print '<td>'.$label.'</td>';
if ($label2) print '<td class="center">'.$label2.'</td>'; if ($label2) print '<td class="center">'.$label2.'</td>';
print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>'; print '<td class="right">'.$langs->trans("NbOfMembers").' <span class="opacitymedium">('.$langs->trans("AllTime").')</span></td>';
print '<td class="center">'.$langs->trans("LastMemberDate").'</td>'; print '<td class="center">'.$langs->trans("LastMemberDate").'</td>';
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>'; print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
print '</tr>'; print '</tr>';
foreach ($data as $val) { foreach ($data as $val) {
$year = $val['year']; $year = $val['year'];
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$val['label'].'</td>'; print '<td>'.$val['label'].'</td>';
if ($label2) print '<td class="center">'.$val['label2'].'</td>'; if ($label2) print '<td class="center">'.$val['label2'].'</td>';
print '<td class="right">'.$val['nb'].'</td>'; print '<td class="right">'.$val['nb'].'</td>';
print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($val['lastdate'], 'dayhour').'</td>';
print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>'; print '<td class="center">'.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
} }

View File

@ -36,8 +36,8 @@ $socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
// Security check // Security check
if ($user->socid > 0) { if ($user->socid > 0) {
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
$result = restrictedArea($user, 'adherent', '', '', 'cotisation'); $result = restrictedArea($user, 'adherent', '', '', 'cotisation');
@ -79,24 +79,24 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti
$px1 = new DolGraph(); $px1 = new DolGraph();
$mesg = $px1->isGraphKo(); $mesg = $px1->isGraphKo();
if (!$mesg) { if (!$mesg) {
$px1->SetData($data); $px1->SetData($data);
$i = $startyear; $i = $startyear;
while ($i <= $endyear) { while ($i <= $endyear) {
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
$px1->SetLegend($legend); $px1->SetLegend($legend);
$px1->SetMaxValue($px1->GetCeilMaxValue()); $px1->SetMaxValue($px1->GetCeilMaxValue());
$px1->SetMinValue(min(0, $px1->GetFloorMinValue())); $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
$px1->SetWidth($WIDTH); $px1->SetWidth($WIDTH);
$px1->SetHeight($HEIGHT); $px1->SetHeight($HEIGHT);
$px1->SetYLabel($langs->trans("NbOfSubscriptions")); $px1->SetYLabel($langs->trans("NbOfSubscriptions"));
$px1->SetShading(3); $px1->SetShading(3);
$px1->SetHorizTickIncrement(1); $px1->SetHorizTickIncrement(1);
$px1->mode = 'depth'; $px1->mode = 'depth';
$px1->SetTitle($langs->trans("NbOfSubscriptions")); $px1->SetTitle($langs->trans("NbOfSubscriptions"));
$px1->draw($filenamenb, $fileurlnb); $px1->draw($filenamenb, $fileurlnb);
} }
// Build graphic amount of object // Build graphic amount of object
@ -110,24 +110,24 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr
$px2 = new DolGraph(); $px2 = new DolGraph();
$mesg = $px2->isGraphKo(); $mesg = $px2->isGraphKo();
if (!$mesg) { if (!$mesg) {
$px2->SetData($data); $px2->SetData($data);
$i = $startyear; $i = $startyear;
while ($i <= $endyear) { while ($i <= $endyear) {
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
$px2->SetLegend($legend); $px2->SetLegend($legend);
$px2->SetMaxValue($px2->GetCeilMaxValue()); $px2->SetMaxValue($px2->GetCeilMaxValue());
$px2->SetMinValue(min(0, $px2->GetFloorMinValue())); $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
$px2->SetWidth($WIDTH); $px2->SetWidth($WIDTH);
$px2->SetHeight($HEIGHT); $px2->SetHeight($HEIGHT);
$px2->SetYLabel($langs->trans("AmountOfSubscriptions")); $px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
$px2->SetShading(3); $px2->SetShading(3);
$px2->SetHorizTickIncrement(1); $px2->SetHorizTickIncrement(1);
$px2->mode = 'depth'; $px2->mode = 'depth';
$px2->SetTitle($langs->trans("AmountOfSubscriptions")); $px2->SetTitle($langs->trans("AmountOfSubscriptions"));
$px2->draw($filenameamount, $fileurlamount); $px2->draw($filenameamount, $fileurlamount);
} }
@ -171,31 +171,31 @@ print '</tr>';
$oldyear = 0; $oldyear = 0;
foreach ($data as $val) { foreach ($data as $val) {
$year = $val['year']; $year = $val['year'];
while ($oldyear > $year + 1) { // If we have empty year while ($oldyear > $year + 1) { // If we have empty year
$oldyear--; $oldyear--;
print '<tr class="oddeven" height="24">'; print '<tr class="oddeven" height="24">';
print '<td class="center">'; print '<td class="center">';
//print '<a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">'; //print '<a href="month.php?year='.$oldyear.'&amp;mode='.$mode.'">';
print $oldyear; print $oldyear;
//print '</a>'; //print '</a>';
print '</td>'; print '</td>';
print '<td class="right">0</td>'; print '<td class="right">0</td>';
print '<td class="right">0</td>'; print '<td class="right">0</td>';
print '<td class="right">0</td>'; print '<td class="right">0</td>';
print '</tr>'; print '</tr>';
} }
print '<tr class="oddeven" height="24">'; print '<tr class="oddeven" height="24">';
print '<td class="center">'; print '<td class="center">';
//print '<a href="month.php?year='.$year.'">'; //print '<a href="month.php?year='.$year.'">';
print $year; print $year;
//print '</a>'; //print '</a>';
print '</td>'; print '</td>';
print '<td class="right">'.$val['nb'].'</td>'; print '<td class="right">'.$val['nb'].'</td>';
print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
print '</tr>'; print '</tr>';
$oldyear = $year; $oldyear = $year;
} }
print '</table>'; print '</table>';
@ -208,9 +208,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs // Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
if ($mesg) { print $mesg; } else { if ($mesg) { print $mesg; } else {
print $px1->show(); print $px1->show();
print "<br>\n"; print "<br>\n";
print $px2->show(); print $px2->show();
} }
print '</td></tr></table>'; print '</td></tr></table>';

View File

@ -550,100 +550,100 @@ if ($rowid > 0) {
} }
print '</td></tr>'; print '</td></tr>';
print "</table>\n"; print "</table>\n";
print "</div></div></div>\n"; print "</div></div></div>\n";
print '<div style="clear:both"></div>'; print '<div style="clear:both"></div>';
print dol_get_fiche_end(); print dol_get_fiche_end();
print '</form>'; print '</form>';
/* /*
* Action buttons * Action buttons
*/ */
// Button to create a new subscription if member no draft neither resiliated // Button to create a new subscription if member no draft neither resiliated
if ($user->rights->adherent->cotisation->creer) { if ($user->rights->adherent->cotisation->creer) {
if ($action != 'addsubscription' && $action != 'create_thirdparty') { if ($action != 'addsubscription' && $action != 'create_thirdparty') {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>"; if ($object->statut > 0) print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription">'.$langs->trans("AddSubscription")."</a></div>";
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>'; else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
print '</div>'; print '</div>';
} }
} }
/* /*
* List of subscriptions * List of subscriptions
*/ */
if ($action != 'addsubscription' && $action != 'create_thirdparty') { if ($action != 'addsubscription' && $action != 'create_thirdparty') {
$sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,"; $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe, d.fk_adherent_type as type,";
$sql .= " c.rowid as crowid, c.subscription,"; $sql .= " c.rowid as crowid, c.subscription,";
$sql .= " c.datec, c.fk_type as cfk_type,"; $sql .= " c.datec, c.fk_type as cfk_type,";
$sql .= " c.dateadh as dateh,"; $sql .= " c.dateadh as dateh,";
$sql .= " c.datef,"; $sql .= " c.datef,";
$sql .= " c.fk_bank,"; $sql .= " c.fk_bank,";
$sql .= " b.rowid as bid,"; $sql .= " b.rowid as bid,";
$sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code"; $sql .= " ba.rowid as baid, ba.label, ba.bank, ba.ref, ba.account_number, ba.fk_accountancy_journal, ba.number, ba.currency_code";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank = b.rowid";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
$sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid; $sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
$sql .= $db->order($sortfield, $sortorder); $sql .= $db->order($sortfield, $sortorder);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$subscriptionstatic = new Subscription($db); $subscriptionstatic = new Subscription($db);
$num = $db->num_rows($result); $num = $db->num_rows($result);
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder); print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], 'c.rowid', '', $param, '', $sortfield, $sortorder);
print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('DateCreation', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('DateStart', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); print_liste_field_titre('DateEnd', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ');
print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled)) {
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
} }
print "</tr>\n"; print "</tr>\n";
$accountstatic = new Account($db); $accountstatic = new Account($db);
$adh = new Adherent($db); $adh = new Adherent($db);
$adht = new AdherentType($db); $adht = new AdherentType($db);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
$adh->id = $objp->rowid; $adh->id = $objp->rowid;
$adh->typeid = $objp->type; $adh->typeid = $objp->type;
$subscriptionstatic->ref = $objp->crowid; $subscriptionstatic->ref = $objp->crowid;
$subscriptionstatic->id = $objp->crowid; $subscriptionstatic->id = $objp->crowid;
$typeid = $objp->cfk_type; $typeid = $objp->cfk_type;
if ($typeid > 0) { if ($typeid > 0) {
$adht->fetch($typeid); $adht->fetch($typeid);
} }
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>'; print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n";
print '<td class="center">'; print '<td class="center">';
if ($typeid > 0) { if ($typeid > 0) {
print $adht->getNomUrl(1); print $adht->getNomUrl(1);
} }
print '</td>'; print '</td>';
print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->dateh), 'day')."</td>\n";
print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n"; print '<td class="center">'.dol_print_date($db->jdate($objp->datef), 'day')."</td>\n";
print '<td class="right">'.price($objp->subscription).'</td>'; print '<td class="right">'.price($objp->subscription).'</td>';
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled)) {
print '<td class="right">'; print '<td class="right">';
if ($objp->bid) { if ($objp->bid) {
@ -921,123 +921,123 @@ if ($rowid > 0) {
} }
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
} }
print '<br>'; print '<br>';
} }
print '</td></tr>'; print '</td></tr>';
// Bank account // Bank account
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>'; print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
$form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2);
print "</td></tr>\n"; print "</td></tr>\n";
// Payment mode // Payment mode
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>'; print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
$form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2);
print "</td></tr>\n"; print "</td></tr>\n";
// Date of payment // Date of payment
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>'; print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("DatePayment").'</td><td>';
print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1); print $form->selectDate(isset($paymentdate) ? $paymentdate : -1, 'payment', 0, 0, 1, 'subscription', 1, 1);
print "</td></tr>\n"; print "</td></tr>\n";
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero'); print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
print '</td>'; print '</td>';
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>'; print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>';
print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter'); print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
print ' <em>('.$langs->trans("ChequeMaker").')</em>'; print ' <em>('.$langs->trans("ChequeMaker").')</em>';
print '</td>'; print '</td>';
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>'; print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>';
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank'); print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
print ' <em>('.$langs->trans("ChequeBank").')</em>'; print ' <em>('.$langs->trans("ChequeBank").')</em>';
print '</td>'; print '</td>';
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>'; print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>';
} }
} }
print '<tr><td></td><td></td></tr>'; print '<tr><td></td><td></td></tr>';
print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>'; print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>';
print '<td>'; print '<td>';
if (!$object->email) { if (!$object->email) {
print $langs->trans("NoEMail"); print $langs->trans("NoEMail");
} else { } else {
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($object->typeid); $adht->fetch($object->typeid);
// Send subscription email // Send subscription email
$subject = ''; $subject = '';
$msg = ''; $msg = '';
// Send subscription email // Send subscription email
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db); $formmail = new FormMail($db);
// Set output language // Set output language
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
// Load traductions files required by page // Load traductions files required by page
$outputlangs->loadLangs(array("main", "members")); $outputlangs->loadLangs(array("main", "members"));
// Get email content from template // Get email content from template
$arraydefaultmessage = null; $arraydefaultmessage = null;
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION; $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); if (!empty($labeltouse)) $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse);
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
$subject = $arraydefaultmessage->topic; $subject = $arraydefaultmessage->topic;
$msg = $arraydefaultmessage->content; $msg = $arraydefaultmessage->content;
} }
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object);
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs); $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
$tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>'; $tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>';
$helpcontent = ''; $helpcontent = '';
$helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n"; $helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
$helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n"; $helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
$helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n"; $helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
if ($subjecttosend) { if ($subjecttosend) {
$helpcontent .= $subjecttosend."\n"; $helpcontent .= $subjecttosend."\n";
} else { } else {
$langs->load("errors"); $langs->load("errors");
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
} }
$helpcontent .= "<br>"; $helpcontent .= "<br>";
$helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>'; $helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>';
if ($texttosend) { if ($texttosend) {
$helpcontent .= dol_htmlentitiesbr($texttosend)."\n"; $helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
} else { } else {
$langs->load("errors"); $langs->load("errors");
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n"; $helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
} }
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend'); print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
} }
print '</td></tr>'; print '</td></tr>';
print '</tbody>'; print '</tbody>';
print '</table>'; print '</table>';
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div class="center">'; print '<div class="center">';
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">'; print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
print "\n<!-- End form subscription -->\n\n"; print "\n<!-- End form subscription -->\n\n";
} }
//print '</td></tr>'; //print '</td></tr>';
//print '</table>'; //print '</table>';
} else { } else {
$langs->load("errors"); $langs->load("errors");
print $langs->trans("ErrorRecordNotFound"); print $langs->trans("ErrorRecordNotFound");
} }
// End of page // End of page

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2019 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -40,10 +40,13 @@ $object = new Subscription($db);
$errmsg = ''; $errmsg = '';
$action = GETPOST("action", 'alpha'); $action = GETPOST("action", 'alpha');
$rowid = GETPOST("rowid", "int") ?GETPOST("rowid", "int") : GETPOST("id", "int"); $rowid = GETPOST("rowid", "int") ? GETPOST("rowid", "int") : GETPOST("id", "int");
$typeid = GETPOST("typeid", "int"); $typeid = GETPOST("typeid", "int");
$cancel = GETPOST('cancel', 'alpha'); $cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm'); $confirm = GETPOST('confirm');
$note = GETPOST('note', 'alpha');
$typeid = (int) GETPOST('typeid', 'int');
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
if (!$user->rights->adherent->cotisation->lire) if (!$user->rights->adherent->cotisation->lire)
accessforbidden(); accessforbidden();
@ -84,7 +87,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
} else { } else {
$accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$accountline->amount = $_POST["amount"]; $accountline->amount = $amount;
$result = $accountline->update($user); $result = $accountline->update($user);
if ($result < 0) { if ($result < 0) {
$errmsg = $accountline->error; $errmsg = $accountline->error;
@ -96,9 +99,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
// Modify values // Modify values
$object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']); $object->dateh = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
$object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']); $object->datef = dol_mktime($_POST['datesubendhour'], $_POST['datesubendmin'], 0, $_POST['datesubendmonth'], $_POST['datesubendday'], $_POST['datesubendyear']);
$object->fk_type = $_POST["typeid"]; $object->fk_type = $typeid;
$object->note = $_POST["note"]; $object->note = $note;
$object->amount = $_POST["amount"]; $object->amount = $amount;
//print 'datef='.$object->datef.' '.$_POST['datesubendday']; //print 'datef='.$object->datef.' '.$_POST['datesubendday'];
$result = $object->update($user); $result = $object->update($user);
@ -216,18 +219,16 @@ if ($user->rights->adherent->cotisation->creer && $action == 'edit') {
print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>'; print '<input type="text" class="flat" size="60" name="note" value="'.$object->note.'"></td></tr>';
// Bank line // Bank line
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">'; if ($object->fk_bank) {
if ($object->fk_bank) { $bankline = new AccountLine($db);
$bankline = new AccountLine($db); $result = $bankline->fetch($object->fk_bank);
$result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall');
print $bankline->getNomUrl(1, 0, 'showall'); } else {
} else { print $langs->trans("NoneF");
print $langs->trans("NoneF");
}
print '</td></tr>';
} }
print '</td></tr>';
} }
print '</table>'; print '</table>';
@ -316,18 +317,16 @@ if ($rowid && $action != 'edit') {
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>';
// Bank line // Bank line
if (!empty($conf->banque->enabled)) { if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) { print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">'; if ($object->fk_bank) {
if ($object->fk_bank) { $bankline = new AccountLine($db);
$bankline = new AccountLine($db); $result = $bankline->fetch($object->fk_bank);
$result = $bankline->fetch($object->fk_bank); print $bankline->getNomUrl(1, 0, 'showall');
print $bankline->getNomUrl(1, 0, 'showall'); } else {
} else { print $langs->trans("NoneF");
print $langs->trans("NoneF");
}
print '</td></tr>';
} }
print '</td></tr>';
} }
print "</table>\n"; print "</table>\n";

View File

@ -110,22 +110,22 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook)) {
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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 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_type = ""; $search_type = "";
$search_ref = ""; $search_ref = "";
$search_lastname = ""; $search_lastname = "";
$search_firstname = ""; $search_firstname = "";
$search_login = ""; $search_login = "";
$search_note = ""; $search_note = "";
$search_amount = ""; $search_amount = "";
$search_account = ""; $search_account = "";
$toselect = ''; $toselect = '';
$search_array_options = array(); $search_array_options = array();
} }
} }
@ -153,8 +153,8 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = e
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
$sql .= " WHERE d.entity IN (".getEntity('adherent').")"; $sql .= " WHERE d.entity IN (".getEntity('adherent').")";
if (isset($date_select) && $date_select != '') { if (isset($date_select) && $date_select != '') {
$sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'"; $sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
$sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'"; $sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
} }
if ($search_ref) { if ($search_ref) {
if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")"; if (is_numeric($search_ref)) $sql .= " AND (c.rowid = ".$db->escape($search_ref).")";
@ -181,13 +181,13 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records with no order and no limits // Count total nb of records with no order and no limits
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) $nbtotalofrecords = $db->num_rows($resql); if ($resql) $nbtotalofrecords = $db->num_rows($resql);
else dol_print_error($db); else dol_print_error($db);
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// Add limit // Add limit
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
@ -241,7 +241,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = ''; $newcardbutton = '';
if ($user->rights->adherent->cotisation->creer) { if ($user->rights->adherent->cotisation->creer) {
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1'); $newcardbutton .= dolGetButtonTitle($langs->trans('NewSubscription'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/list.php?status=-1,1');
} }
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
@ -409,8 +409,8 @@ while ($i < min($num, $limit)) {
$adherent->typeid = $obj->type; $adherent->typeid = $obj->type;
$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid); $typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
$adht = new AdherentType($db); $adht = new AdherentType($db);
$adht->fetch($typeid); $adht->fetch($typeid);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
@ -419,14 +419,14 @@ while ($i < min($num, $limit)) {
print '<td>'.$subscription->getNomUrl(1).'</td>'; print '<td>'.$subscription->getNomUrl(1).'</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Type // Type
if (!empty($arrayfields['d.fk_type']['checked'])) { if (!empty($arrayfields['d.fk_type']['checked'])) {
print '<td class="nowraponall">'; print '<td class="nowraponall">';
if ($typeid > 0) { if ($typeid > 0) {
print $adht->getNomUrl(1); print $adht->getNomUrl(1);
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
} }
// Lastname // Lastname

View File

@ -33,12 +33,12 @@ $langs->load("members");
$total = 0; $total = 0;
foreach ($linkedObjectBlock as $key => $objectlink) { foreach ($linkedObjectBlock as $key => $objectlink) {
echo '<tr class="oddeven">'; echo '<tr class="oddeven">';
echo '<td>'.$langs->trans("Subscription").'</td>'; echo '<td>'.$langs->trans("Subscription").'</td>';
echo '<td>'.$objectlink->getNomUrl(1).'</td>'; echo '<td>'.$objectlink->getNomUrl(1).'</td>';
echo '<td class="center"></td>'; echo '<td class="center"></td>';
echo '<td class="center">'.dol_print_date($objectlink->dateh, 'day').'</td>'; echo '<td class="center">'.dol_print_date($objectlink->dateh, 'day').'</td>';
echo '<td class="right">'; echo '<td class="right">';
if ($user->rights->adherent->lire) { if ($user->rights->adherent->lire) {
$total = $total + $objectlink->amount; $total = $total + $objectlink->amount;
echo price($objectlink->amount); echo price($objectlink->amount);
@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
echo '</td>'; echo '</td>';
echo '<td class="right"></td>'; echo '<td class="right"></td>';
echo '<td class="right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>'; echo '<td class="right"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key.'">'.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').'</a></td>';
echo '</tr>'; echo '</tr>';
} }
echo "<!-- END PHP TEMPLATE -->\n"; echo "<!-- END PHP TEMPLATE -->\n";

View File

@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<th>'.$langs->trans("Ref").'</th>'; print '<th>'.$langs->trans("Ref").'</th>';
print '<th>'.$langs->trans("Label").'</th>'; print '<th>'.$langs->trans("Label").'</th>';
print '<th class="center">'.$langs->trans("MemberNature").'</th>'; print '<th class="center">'.$langs->trans("MembersNature").'</th>';
print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>'; print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
print '<th class="center">'.$langs->trans("VoteAllowed").'</th>'; print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
print '<th class="center">'.$langs->trans("Status").'</th>'; print '<th class="center">'.$langs->trans("Status").'</th>';
@ -263,6 +263,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
$membertype->ref = $objp->rowid; $membertype->ref = $objp->rowid;
$membertype->label = $objp->rowid; $membertype->label = $objp->rowid;
$membertype->status = $objp->status; $membertype->status = $objp->status;
$membertype->subscription = $objp->subscription;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'; print '<td>';
@ -271,7 +272,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
print '</td>'; print '</td>';
print '<td>'.dol_escape_htmltag($objp->label).'</td>'; print '<td>'.dol_escape_htmltag($objp->label).'</td>';
print '<td class="center">'; print '<td class="center">';
if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy"); if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorAndPhy");
print '</td>'; print '</td>';
print '<td class="center">'.yn($objp->subscription).'</td>'; print '<td class="center">'.yn($objp->subscription).'</td>';
print '<td class="center">'.yn($objp->vote).'</td>'; print '<td class="center">'.yn($objp->vote).'</td>';
@ -321,10 +322,10 @@ if ($action == 'create') {
// Morphy // Morphy
$morphys = array(); $morphys = array();
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorAndPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy'); print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
print "</td></tr>"; print "</td></tr>";
@ -343,12 +344,12 @@ if ($action == 'create') {
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create(); $doleditor->Create();
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%'); $doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';
@ -401,7 +402,7 @@ if ($rowid > 0) {
print '<table class="border centpercent">'; print '<table class="border centpercent">';
// Morphy // Morphy
print '<tr><td>'.$langs->trans("MemberNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>'; print '<tr><td>'.$langs->trans("MembersNature").'</td><td class="valeur" >'.$object->getmorphylib($object->morphy).'</td>';
print '</tr>'; print '</tr>';
print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
@ -614,13 +615,16 @@ if ($rowid > 0) {
$adh = new Adherent($db); $adh = new Adherent($db);
$adh->lastname = $objp->lastname; $adh->lastname = $objp->lastname;
$adh->firstname = $objp->firstname; $adh->firstname = $objp->firstname;
$adh->datefin = $datefin;
$adh->need_subscription = $objp->subscription;
$adh->statut = $objp->status;
// Lastname // Lastname
print '<tr class="oddeven">'; print '<tr class="oddeven">';
if ($objp->company != '') { if ($objp->company != '') {
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n"; print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->company, 12).'</a></td>'."\n";
} else { } else {
print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n"; print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user", 'class="paddingright"').$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
} }
// Login // Login
@ -640,9 +644,9 @@ if ($rowid > 0) {
// EMail // EMail
print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n"; print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
// Statut // Status
print '<td class="nowrap">'; print '<td class="nowrap">';
print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2); print $adh->getLibStatut(2);
print "</td>"; print "</td>";
// Date end subscription // Date end subscription
@ -668,11 +672,10 @@ if ($rowid > 0) {
// Actions // Actions
print '<td class="center">'; print '<td class="center">';
if ($user->rights->adherent->creer) { if ($user->rights->adherent->creer) {
print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>'; print '<a class="editfielda marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
} }
print '&nbsp;';
if ($user->rights->adherent->supprimer) { if ($user->rights->adherent->supprimer) {
print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>'; print '<a class="marginleftonly" href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
} }
print "</td>"; print "</td>";
@ -723,11 +726,11 @@ if ($rowid > 0) {
print '</td></tr>'; print '</td></tr>';
// Morphy // Morphy
$morphys[""] = $langs->trans("MorPhy"); $morphys[""] = $langs->trans("MorAndPhy");
$morphys["phy"] = $langs->trans("Physical"); $morphys["phy"] = $langs->trans("Physical");
$morphys["mor"] = $langs->trans("Moral"); $morphys["mor"] = $langs->trans("Moral");
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>'; print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy); print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy);
print "</td></tr>"; print "</td></tr>";
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>'; print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';

View File

@ -123,7 +123,7 @@ print dol_get_fiche_end();
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
} }
print "</div>\n"; print "</div>\n";
@ -146,27 +146,27 @@ print '</tr>';
$ldap = new Ldap(); $ldap = new Ldap();
$result = $ldap->connect_bind(); $result = $ldap->connect_bind();
if ($result > 0) { if ($result > 0) {
$info = $object->_load_ldap_info(); $info = $object->_load_ldap_info();
$dn = $object->_load_ldap_dn($info, 1); $dn = $object->_load_ldap_dn($info, 1);
$search = "(".$object->_load_ldap_dn($info, 2).")"; $search = "(".$object->_load_ldap_dn($info, 2).")";
$records = $ldap->getAttribute($dn, $search); $records = $ldap->getAttribute($dn, $search);
//print_r($records); //print_r($records);
// Show tree // Show tree
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) { if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
if (!is_array($records)) { if (!is_array($records)) {
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>'; print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
} else { } else {
$result = show_ldap_content($records, 0, $records['count'], true); $result = show_ldap_content($records, 0, $records['count'], true);
} }
} else { } else {
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>'; print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
} }
$ldap->unbind(); $ldap->unbind();
$ldap->close(); $ldap->close();
} else { } else {
setEventMessages($ldap->error, $ldap->errors, 'errors'); setEventMessages($ldap->error, $ldap->errors, 'errors');
} }

View File

@ -154,9 +154,9 @@ $titre = $langs->trans("MemberType".$object->type);
// Calculate $cnt_trans // Calculate $cnt_trans
$cnt_trans = 0; $cnt_trans = 0;
if (!empty($object->multilangs)) { if (!empty($object->multilangs)) {
foreach ($object->multilangs as $key => $value) { foreach ($object->multilangs as $key => $value) {
$cnt_trans++; $cnt_trans++;
} }
} }
@ -179,10 +179,10 @@ print dol_get_fiche_end();
print "\n<div class=\"tabsAction\">\n"; print "\n<div class=\"tabsAction\">\n";
if ($action == '') { if ($action == '') {
if ($user->rights->produit->creer || $user->rights->service->creer) { if ($user->rights->produit->creer || $user->rights->service->creer) {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=add&rowid='.$object->id.'">'.$langs->trans("Add").'</a>';
if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>'; if ($cnt_trans > 0) print '<a class="butAction" href="'.DOL_URL_ROOT.'/adherents/type_translation.php?action=edit&rowid='.$object->id.'">'.$langs->trans("Update").'</a>';
} }
} }
print "\n</div>\n"; print "\n</div>\n";
@ -262,7 +262,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
print '<table class="border centpercent">'; print '<table class="border centpercent">';
print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>'; print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans('Language').'</td><td>';
print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1); print $formadmin->select_language('', 'forcelangprod', 0, $object->multilangs, 1);
print '</td></tr>'; print '</td></tr>';
print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>'; print '<tr><td class="tdtop fieldrequired">'.$langs->trans('Label').'</td><td><input name="libelle" size="40"></td></tr>';
print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>'; print '<tr><td class="tdtop">'.$langs->trans('Description').'</td><td>';

View File

@ -3,6 +3,7 @@
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com> * Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -39,8 +40,7 @@ $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objc
$result = $adherent->fetch($id); $result = $adherent->fetch($id);
if ($result <= 0) if ($result <= 0) {
{
dol_print_error($adherent->error); dol_print_error($adherent->error);
exit; exit;
} }
@ -48,8 +48,7 @@ if ($result <= 0)
$physicalperson = 1; $physicalperson = 1;
$company = new Societe($db); $company = new Societe($db);
if ($adherent->socid) if ($adherent->socid) {
{
$result = $company->fetch($adherent->socid); $result = $company->fetch($adherent->socid);
} }
@ -66,43 +65,41 @@ $v->setPhoneNumber($adherent->phone_pro, "TYPE=WORK;VOICE");
$v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE"); $v->setPhoneNumber($adherent->phone_mobile, "TYPE=CELL;VOICE");
$v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX"); $v->setPhoneNumber($adherent->fax, "TYPE=WORK;FAX");
$country = $adherent->country_code ? $adherent->country : '' ; $country = $adherent->country_code ? $adherent->country : '';
$v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL"); $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK;POSTAL");
$v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK");
$v->setEmail($adherent->email); $v->setEmail($adherent->email);
$v->setNote($adherent->note); $v->setNote($adherent->note_public);
$v->setTitle($adherent->poste); $v->setTitle($adherent->poste);
// Data from linked company // Data from linked company
if ($company->id) if ($company->id) {
{
$v->setURL($company->url, "TYPE=WORK"); $v->setURL($company->url, "TYPE=WORK");
if (! $adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); if (!$adherent->phone_pro) {
if (! $adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
if (! $adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); }
if (!$adherent->fax) {
$v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
}
if (!$adherent->zip) {
$v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL");
}
// when company e-mail is empty, use only adherent e-mail // when company e-mail is empty, use only adherent e-mail
if (empty(trim($company->email))) if (empty(trim($company->email))) {
{
// was set before, don't set twice // was set before, don't set twice
} } elseif (empty(trim($adherent->email))) {
// when adherent e-mail is empty, use only company e-mail // when adherent e-mail is empty, use only company e-mail
elseif (empty(trim($adherent->email)))
{
$v->setEmail($company->email); $v->setEmail($company->email);
} } elseif (strtolower(end(explode("@", $adherent->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) // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second)
elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email))))
{
$v->setEmail($adherent->email); $v->setEmail($adherent->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
$v->setEmail($company->email, 'INTERNET'); $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) // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
else {
$v->setEmail($company->email); $v->setEmail($company->email);
// support by Microsoft Outlook (2019 and possible earlier) // support by Microsoft Outlook (2019 and possible earlier)
@ -110,12 +107,16 @@ if ($company->id)
} }
// Si adherent lie a un tiers non de type "particulier" // Si adherent lie a un tiers non de type "particulier"
if ($adherent->typent_code != 'TE_PRIVATE') $v->setOrg($company->name); if ($company->typent_code != 'TE_PRIVATE') {
$v->setOrg($company->name);
}
} }
// Personal informations // Personal informations
$v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE"); $v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE");
if ($adherent->birthday) $v->setBirthday($adherent->birthday); if ($adherent->birth) {
$v->setBirthday($adherent->birth);
}
$db->close(); $db->close();
@ -124,7 +125,7 @@ $db->close();
$output = $v->getVCard(); $output = $v->getVCard();
$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf" $filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename)); $filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
//$filename = dol_sanitizeFileName($filename); //$filename = dol_sanitizeFileName($filename);

View File

@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda')); $langs->loadLangs(array('admin', 'other', 'agenda'));
@ -86,9 +86,9 @@ if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') |
if ($action == "save" && empty($cancel)) if ($action == "save" && empty($cancel))
{ {
$i = 0; $i = 0;
$db->begin(); $db->begin();
foreach ($triggers as $trigger) foreach ($triggers as $trigger)
{ {
@ -102,13 +102,13 @@ if ($action == "save" && empty($cancel))
} }
if (!$error) if (!$error)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
$db->commit(); $db->commit();
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
$db->rollback(); $db->rollback();
} }
} }

View File

@ -84,9 +84,9 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
} }
@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create') if ($action == 'create')
{ {
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
} }
/* ************************************************************************** */ /* ************************************************************************** */
@ -111,10 +111,10 @@ if ($action == 'create')
/* ************************************************************************** */ /* ************************************************************************** */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname))
{ {
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
} }
// End of page // End of page

View File

@ -54,9 +54,9 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
if ($actionsave) if ($actionsave)
{ {
$db->begin(); $db->begin();
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
$res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity);
$i = 1; $errorsaved = 0; $i = 1; $errorsaved = 0;
@ -103,14 +103,14 @@ if ($actionsave)
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
} }
if (!$error) if (!$error)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
} }
} }
/* /*

View File

@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('admin', 'other', 'agenda', 'users')); $langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
@ -80,49 +80,49 @@ if ($action == 'set')
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
$defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter;
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') // For orders
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();
$commande->thirdparty = $specimenthirdparty; $commande->thirdparty = $specimenthirdparty;
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
setEventMessages($module->error, $module->errors, 'errors'); setEventMessages($module->error, $module->errors, 'errors');
dol_syslog($module->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} else { } else {
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
// Activate a model // Activate a model
@ -135,7 +135,7 @@ elseif ($action == 'setmodel')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
} }
} }
@ -194,115 +194,115 @@ $sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$i = 0; $i = 0;
$num_rows = $db->num_rows($resql); $num_rows = $db->num_rows($resql);
while ($i < $num_rows) while ($i < $num_rows)
{ {
$array = $db->fetch_array($resql); $array = $db->fetch_array($resql);
array_push($def, $array[0]); array_push($def, $array[0]);
$i++; $i++;
} }
} else { } else {
dol_print_error($db); dol_print_error($db);
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{ {
print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); print load_fiche_titre($langs->trans("AgendaModelModule"), '', '');
print '<table class="noborder centpercent">'."\n"; print '<table class="noborder centpercent">'."\n";
print '<tr class="liste_titre">'."\n"; print '<tr class="liste_titre">'."\n";
print '<td width="100">'.$langs->trans("Name").'</td>'."\n"; print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
print '<td>'.$langs->trans("Description").'</td>'."\n"; print '<td>'.$langs->trans("Description").'</td>'."\n";
print '<td class="center" width="60">'.$langs->trans("Status").'</td>'."\n"; print '<td class="center" width="60">'.$langs->trans("Status").'</td>'."\n";
print '<td class="center" width="60">'.$langs->trans("Default").'</td>'."\n"; print '<td class="center" width="60">'.$langs->trans("Default").'</td>'."\n";
print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>'; print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
print '<td class="center" width="40">'.$langs->trans("Preview").'</td>'; print '<td class="center" width="40">'.$langs->trans("Preview").'</td>';
print '</tr>'."\n"; print '</tr>'."\n";
clearstatcache(); clearstatcache();
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$dir = dol_buildpath($reldir."core/modules/action/doc"); $dir = dol_buildpath($reldir."core/modules/action/doc");
if (is_dir($dir)) if (is_dir($dir))
{ {
$handle = opendir($dir); $handle = opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
{ {
$name = substr($file, 4, dol_strlen($file) - 16); $name = substr($file, 4, dol_strlen($file) - 16);
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db, new ActionComm($db)); $module = new $classname($db, new ActionComm($db));
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print "<td>"; print "<td>";
print (empty($module->name) ? $name : $module->name); print (empty($module->name) ? $name : $module->name);
print "</td>\n"; print "</td>\n";
print "<td>\n"; print "<td>\n";
require_once $dir.'/'.$file; require_once $dir.'/'.$file;
$module = new $classname($db, $specimenthirdparty); $module = new $classname($db, $specimenthirdparty);
if (method_exists($module, 'info')) if (method_exists($module, 'info'))
print $module->info($langs); print $module->info($langs);
else print $module->description; else print $module->description;
print "</td>\n"; print "</td>\n";
// Active // Active
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">';
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>'; print '</a>';
} else { } else {
print img_picto($langs->trans("Enabled"), 'switch_on'); print img_picto($langs->trans("Enabled"), 'switch_on');
} }
print "</td>"; print "</td>";
} else { } else {
print '<td class="center">'."\n"; print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>"; print "</td>";
} }
// Default // Default
print '<td class="center">'; print '<td class="center">';
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"), 'on'); print img_picto($langs->trans("Default"), 'on');
} else { } else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'&amp;type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
} }
print '</td>'; print '</td>';
// Info // Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>'; $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1); $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
print '<td class="center">'; print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0); print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"), 'order').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&amp;module='.$name.'">'.img_object($langs->trans("Preview"), 'order').'</a>';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
} }
} }
} }
print '</table><br>'; print '</table><br>';
} }
print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">'; print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
@ -343,13 +343,13 @@ print '</td></tr>'."\n";
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
{ {
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->'; print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n"; print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right nowrap">'."\n"; print '<td class="right nowrap">'."\n";
$formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1); $formactions->select_type_actions($conf->global->AGENDA_USE_EVENT_TYPE_DEFAULT, "AGENDA_USE_EVENT_TYPE_DEFAULT", 'systemauto', 0, 1);
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
// AGENDA_DEFAULT_FILTER_TYPE // AGENDA_DEFAULT_FILTER_TYPE
@ -359,8 +359,8 @@ print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right nowrap">'."\n"; print '<td class="right nowrap">'."\n";
$multiselect = 0; $multiselect = 0;
if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) {
// We use an option here because it adds bugs when used on agenda page "peruser" and "list" // We use an option here because it adds bugs when used on agenda page "peruser" and "list"
$multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE));
} }
$formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect); $formactions->select_type_actions($conf->global->AGENDA_DEFAULT_FILTER_TYPE, "AGENDA_DEFAULT_FILTER_TYPE", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 1, $multiselect);
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -73,49 +73,49 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
if ($action == 'set') if ($action == 'set')
{ {
dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
} elseif ($action == 'specimen') // For orders } elseif ($action == 'specimen') // For orders
{ {
$modele = GETPOST('module', 'alpha'); $modele = GETPOST('module', 'alpha');
$commande = new CommandeFournisseur($db); $commande = new CommandeFournisseur($db);
$commande->initAsSpecimen(); $commande->initAsSpecimen();
$commande->thirdparty = $specimenthirdparty; $commande->thirdparty = $specimenthirdparty;
// Search template files // Search template files
$file = ''; $classname = ''; $filefound = 0; $file = ''; $classname = ''; $filefound = 0;
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) foreach ($dirmodels as $reldir)
{ {
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
if (file_exists($file)) if (file_exists($file))
{ {
$filefound = 1; $filefound = 1;
$classname = "pdf_".$modele; $classname = "pdf_".$modele;
break; break;
} }
} }
if ($filefound) if ($filefound)
{ {
require_once $file; require_once $file;
$module = new $classname($db, $commande); $module = new $classname($db, $commande);
if ($module->write_file($commande, $langs) > 0) if ($module->write_file($commande, $langs) > 0)
{ {
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
return; return;
} else { } else {
setEventMessages($module->error, $module->errors, 'errors'); setEventMessages($module->error, $module->errors, 'errors');
dol_syslog($module->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} else { } else {
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
// Activate a model // Activate a model
@ -128,7 +128,7 @@ elseif ($action == 'setmodel')
$ret = delDocumentModel($value, $type); $ret = delDocumentModel($value, $type);
if ($ret > 0) if ($ret > 0)
{ {
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity);
} }
} }
@ -200,31 +200,31 @@ if ($conf->global->MAIN_FEATURES_LEVEL == 2)
// AGENDA REMINDER BROWSER // AGENDA REMINDER BROWSER
if ($conf->global->MAIN_FEATURES_LEVEL == 2) if ($conf->global->MAIN_FEATURES_LEVEL == 2)
{ {
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n"; print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) { if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
print '</td></tr>'."\n"; print '</td></tr>'."\n";
print '<tr class="oddeven">'."\n"; print '<tr class="oddeven">'."\n";
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n"; print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
print '<td class="center">&nbsp;</td>'."\n"; print '<td class="center">&nbsp;</td>'."\n";
print '<td class="right">'."\n"; print '<td class="right">'."\n";
if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) { if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
} else { } else {
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>'; print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
} }
print '</td></tr>'."\n"; print '</td></tr>'."\n";
} }
} }
print '</table>'; print '</table>';

View File

@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("admin", "other", "agenda")); $langs->loadLangs(array("admin", "other", "agenda"));
@ -41,23 +41,23 @@ $actionsave = GETPOST('save', 'alpha');
// Sauvegardes parametres // Sauvegardes parametres
if ($actionsave) if ($actionsave)
{ {
$i = 0; $i = 0;
$db->begin(); $db->begin();
$i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'MAIN_AGENDA_XCAL_EXPORTKEY', trim(GETPOST('MAIN_AGENDA_XCAL_EXPORTKEY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_PAST_DELAY', trim(GETPOST('MAIN_AGENDA_EXPORT_PAST_DELAY', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity);
$i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity);
if ($i >= 4) if ($i >= 4)
{ {
$db->commit(); $db->commit();
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
$db->rollback(); $db->rollback();
setEventMessages($langs->trans("SaveFailed"), null, 'errors'); setEventMessages($langs->trans("SaveFailed"), null, 'errors');
} }
} }
@ -163,7 +163,7 @@ $urlvcal .= $urlwithroot.'/public/agenda/agendaexport.php?format=vcal'.$getentit
$message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal); $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'vcal', $urlvcal);
$message .= '<br>'; $message .= '<br>';
$urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">'; $urlical = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">';
$urlical .=$urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>'; $urlical .= $urlwithroot.'/public/agenda/agendaexport.php?format=ical&type=event'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : 'KEYNOTDEFINED').'</a>';
$message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical); $message .= img_picto('', 'globe').' '.$langs->trans("WebCalUrlForVCalExport", 'ical/ics', $urlical);
$message .= '<br>'; $message .= '<br>';
$urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">'; $urlrss = '<a href="'.$urlwithroot.'/public/agenda/agendaexport.php?format=rss'.$getentity.'&exportkey='.($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY ?urlencode($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY) : '...').'" target="_blank">';

View File

@ -81,9 +81,9 @@ print dol_get_fiche_end();
// Buttons // Buttons
if ($action != 'create' && $action != 'edit') if ($action != 'create' && $action != 'edit')
{ {
print '<div class="tabsAction">'; print '<div class="tabsAction">';
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>"; print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
print "</div>"; print "</div>";
} }
@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit')
if ($action == 'create') if ($action == 'create')
{ {
print '<br><div id="newattrib"></div>'; print '<br><div id="newattrib"></div>';
print load_fiche_titre($langs->trans('NewAttribute')); print load_fiche_titre($langs->trans('NewAttribute'));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
} }
/* /*
@ -103,10 +103,10 @@ if ($action == 'create')
*/ */
if ($action == 'edit' && !empty($attrname)) if ($action == 'edit' && !empty($attrname))
{ {
print "<br>"; print "<br>";
print load_fiche_titre($langs->trans("FieldEdition", $attrname)); print load_fiche_titre($langs->trans("FieldEdition", $attrname));
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
} }
// End of page // End of page

View File

@ -44,11 +44,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
if ($action == 'setbarcodeproducton') if ($action == 'setbarcodeproducton')
{ {
$barcodenumberingmodule = GETPOST('value', 'alpha'); $barcodenumberingmodule = GETPOST('value', 'alpha');
$res = dolibarr_set_const($db, "BARCODE_PRODUCT_ADDON_NUM", $barcodenumberingmodule, 'chaine', 0, '', $conf->entity); $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)) 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", '020{000000000}', 'chaine', 0, '', $conf->entity);
} }
} elseif ($action == 'setbarcodeproductoff') } elseif ($action == 'setbarcodeproductoff')
{ {
@ -76,45 +76,45 @@ if ($action == 'setcoder')
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
if ($res > 0) if ($res > 0)
{ {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else { } else {
setEventMessages($langs->trans("Error"), null, 'errors'); setEventMessages($langs->trans("Error"), null, 'errors');
} }
} elseif ($action == 'updateengine') } elseif ($action == 'updateengine')
{ {
$sql = "SELECT rowid, coder"; $sql = "SELECT rowid, coder";
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type"; $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
$sql .= " WHERE entity = ".$conf->entity; $sql .= " WHERE entity = ".$conf->entity;
$sql .= " ORDER BY code"; $sql .= " ORDER BY code";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (GETPOST('coder'.$obj->rowid, 'alpha')) if (GETPOST('coder'.$obj->rowid, 'alpha'))
{ {
$coder = GETPOST('coder'.$obj->rowid, 'alpha'); $coder = GETPOST('coder'.$obj->rowid, 'alpha');
$code_id = $obj->rowid; $code_id = $obj->rowid;
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type"; $sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
$sqlp .= " SET coder = '".$db->escape($coder)."'"; $sqlp .= " SET coder = '".$db->escape($coder)."'";
$sqlp .= " WHERE rowid = ".((int) $code_id); $sqlp .= " WHERE rowid = ".((int) $code_id);
$sqlp .= " AND entity = ".$conf->entity; $sqlp .= " AND entity = ".$conf->entity;
$upsql = $db->query($sqlp); $upsql = $db->query($sqlp);
if (!$upsql) dol_print_error($db); if (!$upsql) dol_print_error($db);
} }
$i++; $i++;
} }
} }
} }
@ -142,11 +142,11 @@ $dirbarcode = array_merge(array("/core/modules/barcode/doc/"), $conf->modules_pa
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir)
{ {
$dir = dol_buildpath($reldir); $dir = dol_buildpath($reldir);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) continue;
$handle = @opendir($newdir); $handle = @opendir($newdir);
if (is_resource($handle)) if (is_resource($handle))
@ -190,9 +190,9 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax))
{ {
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">'; print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="updateengine">'; print '<input type="hidden" name="action" value="updateengine">';
} }
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
@ -236,11 +236,11 @@ if ($resql)
foreach ($dirbarcode as $reldir) foreach ($dirbarcode as $reldir)
{ {
$dir = dol_buildpath($reldir, 0); $dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir); $newdir = dol_osencode($dir);
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php) // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
if (!is_dir($newdir)) continue; if (!is_dir($newdir)) continue;
$result = @include_once $newdir.$obj->coder.'.modules.php'; $result = @include_once $newdir.$obj->coder.'.modules.php';
if ($result) break; if ($result) break;
@ -254,7 +254,7 @@ if ($resql)
if ($module->encodingIsSupported($obj->encoding)) if ($module->encodingIsSupported($obj->encoding))
{ {
// Build barcode on disk (not used, this is done to make debug easier) // Build barcode on disk (not used, this is done to make debug easier)
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y'); $result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
// Generate on the fly and output barcode with generator // Generate on the fly and output barcode with generator
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&amp;generator='.urlencode($obj->coder).'&amp;code='.urlencode($obj->example).'&amp;encoding='.urlencode($obj->encoding); $url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&amp;generator='.urlencode($obj->coder).'&amp;code='.urlencode($obj->example).'&amp;encoding='.urlencode($obj->encoding);
//print $url; //print $url;
@ -282,8 +282,8 @@ print "</table>\n";
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax))
{ {
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>'; print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
print '</form>'; print '</form>';
} }
print "<br>"; print "<br>";
@ -371,48 +371,48 @@ if ($conf->product->enabled)
$dir = dol_buildpath($dirroot, 0); $dir = dol_buildpath($dirroot, 0);
$handle = @opendir($dir); $handle = @opendir($dir);
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle)) !== false) while (($file = readdir($handle)) !== false)
{ {
if (preg_match('/^mod_barcode_product_.*php$/', $file)) if (preg_match('/^mod_barcode_product_.*php$/', $file))
{ {
$file = substr($file, 0, dol_strlen($file) - 4); $file = substr($file, 0, dol_strlen($file) - 4);
try { try {
dol_include_once($dirroot.$file.'.php'); dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) } catch (Exception $e)
{ {
dol_syslog($e->getMessage(), LOG_ERR); dol_syslog($e->getMessage(), LOG_ERR);
} }
$modBarCode = new $file(); $modBarCode = new $file();
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n"; print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
print $modBarCode->info($langs); print $modBarCode->info($langs);
print '</td>'; print '</td>';
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n"; print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file")
{ {
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
print img_picto($langs->trans("Activated"), 'switch_on'); print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>'; print '</a></td>';
} else { } else {
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproducto&amp;token='.newToken().'&amp;value='.urlencode($file).'">'; print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproducto&amp;token='.newToken().'&amp;value='.urlencode($file).'">';
print img_picto($langs->trans("Disabled"), 'switch_off'); print img_picto($langs->trans("Disabled"), 'switch_off');
print '</a></td>'; print '</a></td>';
} }
print '<td class="center">'; print '<td class="center">';
$s = $modBarCode->getToolTip($langs, null, -1); $s = $modBarCode->getToolTip($langs, null, -1);
print $form->textwithpicto('', $s, 1); print $form->textwithpicto('', $s, 1);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
} }
} }
closedir($handle); closedir($handle);
} }
} }
print "</table>\n"; print "</table>\n";
} }

Some files were not shown because too many files have changed in this diff Show More