merge from develop
This commit is contained in:
commit
46326d7659
4
.github/workflows/exakat.yml
vendored
4
.github/workflows/exakat.yml
vendored
@ -13,5 +13,5 @@ jobs:
|
||||
- name: Exakat
|
||||
uses: docker://exakat/exakat-ga
|
||||
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_dirs: '/htdocs/includes,/htdocs/build,/htdocs/dev,/htdocs/doc,/htdocs/scripts,/htdocs/test'
|
||||
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,/build,/dev,/doc,/scripts,/test'
|
||||
@ -17,8 +17,10 @@ filter:
|
||||
- build/*
|
||||
- dev/*
|
||||
- doc/*
|
||||
- test/*
|
||||
- documents/*
|
||||
- htdocs/includes/*
|
||||
- node_modules/*
|
||||
- test/*
|
||||
paths:
|
||||
- htdocs/*
|
||||
- scripts/*
|
||||
|
||||
51
.travis.yml
51
.travis.yml
@ -35,10 +35,6 @@ addons:
|
||||
|
||||
php:
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- '7.1'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
- '7.4'
|
||||
- nightly
|
||||
|
||||
@ -112,33 +108,48 @@ install:
|
||||
echo "Updating Composer"
|
||||
rm $TRAVIS_BUILD_DIR/composer.json
|
||||
rm $TRAVIS_BUILD_DIR/composer.lock
|
||||
composer -V
|
||||
composer self-update
|
||||
# To have composer making parallel downloads
|
||||
composer global require hirak/prestissimo
|
||||
composer -n init
|
||||
composer -n config vendor-dir htdocs/includes
|
||||
composer -n config -g vendor-dir htdocs/includes
|
||||
echo
|
||||
|
||||
- |
|
||||
echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION"
|
||||
if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \
|
||||
[ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then
|
||||
if [ "$TRAVIS_PHP_VERSION" = '5.6' ]; then
|
||||
composer -n require phpunit/phpunit ^5 \
|
||||
php-parallel-lint/php-parallel-lint ^1 \
|
||||
php-parallel-lint/php-console-highlighter ^0 \
|
||||
squizlabs/php_codesniffer ^3
|
||||
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
|
||||
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-console-highlighter ^0 \
|
||||
squizlabs/php_codesniffer ^3
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
|
||||
- |
|
||||
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
|
||||
|
||||
|
||||
@ -165,15 +176,20 @@ before_script:
|
||||
|
||||
- |
|
||||
echo "Versions information"
|
||||
echo
|
||||
# Check PHP
|
||||
echo "PHP version"
|
||||
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"
|
||||
which phpcs
|
||||
phpcs --version | head -
|
||||
phpcs -i | head -
|
||||
# Check PHPUnit installation
|
||||
# Check PHPUnit version
|
||||
echo "PHPUnit version"
|
||||
which phpunit
|
||||
phpunit --version | head -
|
||||
@ -287,12 +303,13 @@ script:
|
||||
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
|
||||
set -e
|
||||
# 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" ]; 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
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_PHP_VERSION" = "7.4" ] && [ "$DB" = "mysql" ]; 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
|
||||
set +e
|
||||
echo
|
||||
|
||||
@ -409,7 +426,7 @@ script:
|
||||
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
|
||||
|
||||
# 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 $?
|
||||
cd -
|
||||
set +e
|
||||
|
||||
@ -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)
|
||||
PEAR Mail_MIME 1.8.9 BSD Yes NuSoap dependency
|
||||
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
|
||||
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
|
||||
|
||||
267
ChangeLog
267
ChangeLog
@ -4,152 +4,155 @@ English Dolibarr ChangeLog
|
||||
|
||||
|
||||
***** ChangeLog for 13.0.0 compared to 12.0.0 *****
|
||||
|
||||
For users:
|
||||
----------
|
||||
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: 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: Accountancy - Add chart of sub accounts
|
||||
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 - Move to real ledger, real journals, menu disposition
|
||||
NEW: Accountancy - On transfers, select the periodicity by default
|
||||
NEW: Add 2 rules for emailcollector: Message send/not sent from Dolibarr
|
||||
NEW: Add a counter of number of words of pages in website module
|
||||
NEW: add alert before change thirdparty in takepos
|
||||
NEW: Add a page to list Stock at a given date.
|
||||
NEW: Add a start date to begin binding in accountancy
|
||||
NEW: Add a stat page to list popularity of products on invoices
|
||||
NEW: Add calendar selection for agenda view
|
||||
NEW: add class for ticket edition (pdf or odt)
|
||||
NEW: Add column payment term into list of supplier invoices.
|
||||
NEW: Add column quantity in product margin 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: Accountancy - add chart of sub accounts
|
||||
NEW: Accountancy - add options to disable binding on sales, purchases & expense reports independently of the modules
|
||||
NEW: Accountancy balance - add a menu entry to show subtotal by group
|
||||
NEW: Accountancy - move to real ledger, real journals, menu disposition
|
||||
NEW: Accountancy - on transfers, select the periodicity by default
|
||||
NEW: new currency rate editor
|
||||
NEW: add 2 rules for emailcollector: Message send/not sent from Dolibarr
|
||||
NEW: add a counter of number of words for pages in website module
|
||||
NEW: add alert before changing thirdparty in TakePOS
|
||||
NEW: add a page to list Stock at a given date in the past
|
||||
NEW: add a start date to begin binding in accountancy
|
||||
NEW: add a statistics page to list popularity of products on invoices
|
||||
NEW: add calendar selection for agenda view
|
||||
NEW: Support documents generation for ticket edition (PDF or ODT)
|
||||
NEW: add column payment term into list of supplier invoices
|
||||
NEW: add column quantity in product margin 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: ADDED IMPORT TOOL FOR CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
|
||||
NEW: Added incoterms to substitution array
|
||||
NEW: Add employee in expense report binding page
|
||||
NEW: Add export for various payment
|
||||
NEW: add extra fields labels and values in mail on create ticket
|
||||
NEW: Add extrafields support on ECM module
|
||||
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: added an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
|
||||
NEW: added incoterms data into the substitution array
|
||||
NEW: add employee link in expense report binding page
|
||||
NEW: add export for various payment
|
||||
NEW: add Extrafields labels and values in mail on create ticket
|
||||
NEW: add Extrafields support on ECM module
|
||||
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 formConfirm hook on product page
|
||||
NEW: add free text on each terminal of cash desk
|
||||
NEW: Add function dolButtonToOpenUrlInDialogPopup() to be able to open
|
||||
NEW: Add global search for customer payments and vendor payments
|
||||
NEW: Add global search for miscellaneous payments
|
||||
NEW: Add helper function for table headers with numbers
|
||||
NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open
|
||||
NEW: add global search for customer payments and vendor payments
|
||||
NEW: add global search for miscellaneous payments
|
||||
NEW: add helper function for table headers with numbers
|
||||
NEW: add hooks on stats 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 MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header in email collector
|
||||
NEW: Add Manufacturing Orders into the automatic ECM
|
||||
NEW: add link to edit property from search result of website pages
|
||||
NEW: add link to reset qty on supplier dispatch page
|
||||
NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector
|
||||
NEW: add Manufacturing Orders attached files into the automatic ECM view
|
||||
NEW: add margin info in invoice list
|
||||
NEW: Add mass action to set category on a list of website pages.
|
||||
NEW: Add mass deletion for events
|
||||
NEW: Add __MEMBER_TYPE__ substitution key
|
||||
NEW: Add message in error_log after detection of SQL or script injection
|
||||
NEW: Add module Credit transfer SEPA to manage payment of supplier using
|
||||
NEW: Add more filters on monthly statement list
|
||||
NEW: Add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT
|
||||
NEW: Add option to define a default warehouse at user level
|
||||
NEW: Add option to include products without alert in replenish
|
||||
NEW: add mass action to set category on a list of website pages
|
||||
NEW: add mass deletion for events
|
||||
NEW: add mass deletion for draft invoices
|
||||
NEW: add __MEMBER_TYPE__ substitution key
|
||||
NEW: add a message in error_log after detection of SQL or script injection
|
||||
NEW: add module Credit transfer SEPA to manage payment of supplier using
|
||||
NEW: add more filters on monthly statement list
|
||||
NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT
|
||||
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 param to not show links when output tags
|
||||
NEW: Add PDF document templates for warehouses (list of stock)
|
||||
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 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 param to not show links when output tags
|
||||
NEW: add PDF document templates for warehouses (list of stock)
|
||||
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 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 region in export companies and contacts
|
||||
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 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/Province origin for products
|
||||
NEW: Add the workflow interaction close intervention on closing ticket
|
||||
NEW: Add third order printer to TakePOS
|
||||
NEW: add the workflow interaction close intervention on closing ticket
|
||||
NEW: add third order printer to TakePOS
|
||||
NEW: add tracking number in list and search_all items
|
||||
NEW: add two hooks printFieldListFrom and printFieldSearchParam
|
||||
NEW: Add __TYPE__ substitution key
|
||||
NEW: Add validation of MX domain for emails
|
||||
NEW: add __TYPE__ substitution key
|
||||
NEW: add validation of MX domain for emails
|
||||
NEW: add vcard for aderent and user
|
||||
NEW: add week number for month view in agenda
|
||||
NEW: Algeria data (tva and forme_juridique)
|
||||
NEW: Allow click on all header numbers on commerce area
|
||||
NEW: Allow to reopen interventions (green button)
|
||||
NEW: Allow zero quality on supplier/vendor order line
|
||||
NEW: Appearance tab in TakePOS with more visual parameters
|
||||
NEW: Better currency rate editor
|
||||
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 build vendor invoice from vendor orders
|
||||
NEW: Can change a product in line of recurring invoice or contract
|
||||
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 define date range of validity of a login during creation
|
||||
NEW: Can disable, from edit page, the whole web site
|
||||
NEW: allow click on all header numbers on commerce area
|
||||
NEW: allow to reopen interventions (green button)
|
||||
NEW: allow zero quality on supplier/vendor order line
|
||||
NEW: appearance tab in TakePOS with more visual parameters
|
||||
NEW: better currency rate editor
|
||||
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 build vendor invoice from vendor orders
|
||||
NEW: can change a product in line of recurring invoice or contract
|
||||
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 define date range of validity of a login during creation
|
||||
NEW: can disable, from edit page, the whole web site
|
||||
NEW: can edit and set sales representatives directly on thirdparty card
|
||||
NEW: Can edit the list of sending email profiles.
|
||||
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 container type, language and tags in the list of pages
|
||||
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 import proposals, sales orders, supplier invoices
|
||||
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 container type, language and tags in the list of pages
|
||||
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 import proposals, sales orders, supplier invoices
|
||||
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 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 THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: change thirdparty with barcode scan in takepos
|
||||
NEW: Common behavior for monthly leave list view
|
||||
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 use desired stock of a given warehouse for replenishment
|
||||
NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: change thirdparty with barcode scan in TakePOS
|
||||
NEW: common behavior for monthly leave list view
|
||||
NEW: conf to allow show full arbo in warehouse getnomurl
|
||||
NEW: convert all subscription in datetime
|
||||
NEW: create thirdparty customer from TAKEPOS
|
||||
NEW: Date shipment from order accepts hours
|
||||
NEW: Declinaison price level compatibility
|
||||
NEW: Delayed payment in TakePOS
|
||||
NEW: Development of module Recruitment
|
||||
NEW: display date range if exist in takepos
|
||||
NEW: display resiliate status in takepos for member
|
||||
NEW: create thirdparty customer from TakePOS
|
||||
NEW: date shipment from order accepts hours
|
||||
NEW: declinaison price level compatibility
|
||||
NEW: delayed payment in TakePOS
|
||||
NEW: development of module Recruitment
|
||||
NEW: display date range if exist in TakePOS
|
||||
NEW: display resiliate status in TakePOS for member
|
||||
NEW: display stat for BOM on "object referent"/linked Object product tab
|
||||
NEW: edit and update a ticket
|
||||
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: endpoint getContacts and Clean results
|
||||
NEW: Events in agenda for contact
|
||||
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 product list by country and/or state/province
|
||||
NEW: format tickets sent by mail in public interface
|
||||
NEW: add juridical status for Algeria
|
||||
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 contacts list of a given order
|
||||
NEW: get contacts list of a given order
|
||||
NEW: helper functions for export with phpspreadsheet
|
||||
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: 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: Introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM
|
||||
NEW: Introducing new modal boxes in TakePOS
|
||||
NEW: Keep takepos terminal when login/logout
|
||||
NEW: Link on balance to the ledger
|
||||
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: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM
|
||||
NEW: introducing new modal boxes in TakePOS
|
||||
NEW: keep TakePOS terminal when login/logout
|
||||
NEW: link on balance to the ledger
|
||||
NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector
|
||||
NEW: manage errors on update extra fields in ticket card
|
||||
NEW: mass-actions for the event list view
|
||||
NEW: Module Intracomm report
|
||||
NEW: More filter for "View change logs"
|
||||
NEW: multicurrency total in takepos
|
||||
NEW: more filter for "View change logs"
|
||||
NEW: multicurrency total in TakePOS
|
||||
NEW: multiselect type and date to date filter
|
||||
NEW: Nature of product is now a dictionay
|
||||
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: Priority and transparency from external calendar events
|
||||
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: 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: restrict thirdparty to customer in takepos
|
||||
NEW: Allow to edit "demand reason" field though API
|
||||
NEW: restrict thirdparty to customer in TakePOS
|
||||
NEW: allow to edit "demand reason" field though API
|
||||
NEW: Rule "email to" accept wildcard *
|
||||
NEW: Save filter of the project homepage
|
||||
NEW: Select-able columns on customer invoice paymnet list
|
||||
NEW: Select-able columns on miscellaneous payments + more data columns
|
||||
NEW: Select-able columns on social taxes list
|
||||
NEW: Select-able columns on supplier invoice payment 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 social taxes list
|
||||
NEW: select-able columns on supplier invoice payment list
|
||||
NEW: send context and remove new lines on create ticket
|
||||
NEW: set entity when creating invoice on takepos
|
||||
NEW: Show available stock in TakePOS
|
||||
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 image of user in the combo select of users
|
||||
NEW: Show label on batch card
|
||||
NEW: Show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
|
||||
NEW: show available stock in TakePOS
|
||||
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 image of user in the combo select of users
|
||||
NEW: show label on batch card
|
||||
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 module and permission ids on user/group rights (only admin)
|
||||
NEW: Show place from events on import calender
|
||||
NEW: Show references in contract form on interventions
|
||||
NEW: Show tags and status in search list of website pages
|
||||
NEW: Show user on external calender events (when found)
|
||||
NEW: show module and permission ids on user/group rights (only admin)
|
||||
NEW: show place from events on import calender
|
||||
NEW: show references in contract form on interventions
|
||||
NEW: show tags and status in search list of website pages
|
||||
NEW: show user on external calender events (when found)
|
||||
NEW: subject title with company name instead of application title in ticket message
|
||||
NEW: Support for Samba4 AD
|
||||
NEW: TakePOS connector compatibility with RECEIPT PRINTERS module
|
||||
NEW: TakePOS Gift Receipt
|
||||
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: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late
|
||||
NEW: ticket classification on create from email collector
|
||||
@ -198,16 +201,18 @@ NEW: translate classification labels in ticket
|
||||
NEW: triggers create, modify, delete
|
||||
NEW: VAT for Algeria
|
||||
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: 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: Add clone functionality on miscellaneous payment
|
||||
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
|
||||
|
||||
|
||||
For developers:
|
||||
---------------
|
||||
NEW: Can use dynamic code into the 'enabled' property of DAO fields
|
||||
NEW: API Can update a payment
|
||||
NEW: api get member by thirdparty
|
||||
NEW: API can update a payment
|
||||
NEW: API get member by thirdparty
|
||||
NEW: API get thirdparty by barcode
|
||||
NEW: API get users by email / login
|
||||
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: get state by REST API
|
||||
NEW: get state dictionnary by REST API
|
||||
NEW: Improve Product API for variant products
|
||||
NEW: Oauth SCOPE for Admin SDK
|
||||
NEW: Retrieve discount from invoice from API
|
||||
NEW: improve Product API for variant products
|
||||
NEW: OAuth SCOPE for Admin SDK
|
||||
NEW: retrieve discount from invoice from API
|
||||
NEW: standardizes API thirdparties by email like other object
|
||||
NEW: thirdparty REST API: endpoint to set price level
|
||||
NEW: Use new category API for project list view
|
||||
NEW: Thirdparty REST API: endpoint to set price level
|
||||
NEW: use new category API for project list view
|
||||
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:
|
||||
|
||||
@ -288,6 +294,7 @@ FIX: Visualization rights correction on last modified contacts box
|
||||
FIX: Wrong redirection
|
||||
FIX: Yogosha report 4425 (backport)
|
||||
|
||||
|
||||
***** 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: DebugBar hides content at page bottom
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
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, ...).
|
||||
|
||||

|
||||

|
||||
|
||||
## LICENCE
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||

|
||||

|
||||
|
||||
## LICENSE
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ $dolibarr_main_prod='0';
|
||||
# Examples:
|
||||
# $dolibarr_mailing_limit_sendbycli='0';
|
||||
|
||||
# dolibarr_distrib
|
||||
# dolibarr_main_distrib
|
||||
# A key to identify the distribution used for first installation
|
||||
$dolibarr_distrib = 'deb';
|
||||
$dolibarr_main_distrib = 'debian';
|
||||
|
||||
|
||||
@ -24,6 +24,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='444';
|
||||
$force_install_distrib='debian';
|
||||
|
||||
// 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
|
||||
|
||||
@ -22,6 +22,7 @@ $force_install_databaserootpass='WAMPMYSQLNEWPASSWORD';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='644';
|
||||
$force_install_distrib='doliwamp';
|
||||
|
||||
$force_install_module='';
|
||||
?>
|
||||
@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='444';
|
||||
$force_install_distrib='rpmfedora';
|
||||
|
||||
// Value to overwrite path to use shared libraries/fonts instead of embedded one
|
||||
$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
|
||||
|
||||
@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='444';
|
||||
$force_install_distrib='rpmgeneric';
|
||||
|
||||
// Value to overwrite path to use shared libraries/fonts instead of embedded one
|
||||
// We don't force any external lib with generic package
|
||||
|
||||
@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='444';
|
||||
$force_install_distrib='rpmmandriva';
|
||||
|
||||
// Value to overwrite path to use shared libraries/fonts instead of embedded one
|
||||
$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
|
||||
|
||||
@ -17,6 +17,7 @@ $force_install_databaserootpass='__SUPERUSERPASSWORD__';
|
||||
$force_install_dolibarrlogin='admin';
|
||||
$force_install_nophpinfo='1';
|
||||
$force_install_lockinstall='444';
|
||||
$force_install_distrib='rpmopensuse';
|
||||
|
||||
// Value to overwrite path to use shared libraries/fonts instead of embedded one
|
||||
//$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
|
||||
|
||||
@ -1,10 +1,19 @@
|
||||
# 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/)
|
||||
|
||||
## BUILD INTEGRATION
|
||||
|
||||
## INSTALL ZAPIER COMMAND LINE TOOLS WITH LINK TO ZAPIER ONLINE ACCOUNT
|
||||
|
||||
### 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:
|
||||
|
||||
`cd dev/exemples/zapier`
|
||||
`cd dev/examples/zapier`
|
||||
|
||||
`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.
|
||||
|
||||
`zapier --version`
|
||||
`zapier login`
|
||||
|
||||
This command will set up a .zapierrc file in your home directory.
|
||||
|
||||
### Install the Project
|
||||
|
||||
In zapier exemple directory, run:
|
||||
In zapier example directory, run:
|
||||
|
||||
`cd dev/examples/zapier`
|
||||
|
||||
`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.
|
||||
|
||||
`zapier register` (the first time, choose name for example "Dolibarr")
|
||||
|
||||
`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)
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*jshint esversion: 6 */
|
||||
const testAuth = (z , bundle) => {
|
||||
const url = bundle.authData.url+'/api/index.php/login';
|
||||
const test = (z , bundle) => {
|
||||
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
|
||||
// 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
|
||||
@ -11,67 +11,92 @@ const testAuth = (z , bundle) => {
|
||||
// This method can return any truthy value to indicate the credentials are valid.
|
||||
// Raise an error to show
|
||||
return promise.then((response) => {
|
||||
if (response.status === 401) {
|
||||
throw new Error('The Session Key you supplied is invalid');
|
||||
if (response.status === 400) {
|
||||
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;
|
||||
});
|
||||
};
|
||||
|
||||
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 promise = z.request({
|
||||
method: 'POST',
|
||||
const response = await z.request({
|
||||
url: url,
|
||||
method: 'POST',
|
||||
body: {
|
||||
login: bundle.authData.login,
|
||||
password: bundle.authData.password,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return promise.then((response) => {
|
||||
if (response.status === 401) {
|
||||
throw new Error('The login/password you supplied is invalid');
|
||||
}
|
||||
const json = JSON.parse(response.content);
|
||||
return {
|
||||
sessionKey: json.success.token || 'secret'
|
||||
};
|
||||
});
|
||||
// if (response.status === 401) {
|
||||
// throw new Error('The login/password you supplied is invalid');
|
||||
// }
|
||||
const json = JSON.parse(response.content);
|
||||
return {
|
||||
sessionKey: json.success.token || '',
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
type: 'session',
|
||||
// Define any auth fields your app requires here. The user will be prompted to enter this info when
|
||||
// they connect their account.
|
||||
fields: [
|
||||
{
|
||||
key: 'url',
|
||||
label: 'Url of service',
|
||||
required: true,
|
||||
type: 'string'
|
||||
config: {
|
||||
type: 'session',
|
||||
sessionConfig: {
|
||||
perform: getSessionKey
|
||||
},
|
||||
{
|
||||
key: 'login',
|
||||
label: 'Login',
|
||||
required: true,
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
label: 'Password',
|
||||
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: testAuth,
|
||||
// The method that will exchange the fields provided by the user for session credentials.
|
||||
sessionConfig: {
|
||||
perform: getSessionKey
|
||||
// Define any auth fields your app requires here. The user will be prompted to enter this info when
|
||||
// they connect their account.
|
||||
fields: [
|
||||
{
|
||||
key: 'url',
|
||||
label: 'Url of service without trailing-slash',
|
||||
required: true,
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'login',
|
||||
label: 'Login',
|
||||
required: true,
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'password',
|
||||
label: 'Password',
|
||||
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
|
||||
connectionLabel: '{{login}}'
|
||||
befores: [includeSessionKeyHeader],
|
||||
afters: [sessionRefreshIf401],
|
||||
};
|
||||
|
||||
@ -72,7 +72,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
outputFields: [
|
||||
{key: 'id', label: 'ID'},
|
||||
{key: 'id', type: "integer", label: 'ID'},
|
||||
{key: 'name', label: 'Name'},
|
||||
{key: 'name_alias', label: 'Name alias'},
|
||||
{key: 'address', label: 'Address'},
|
||||
@ -81,8 +81,8 @@ module.exports = {
|
||||
{key: 'phone', label: 'Phone'},
|
||||
{key: 'fax', label: 'Fax'},
|
||||
{key: 'email', label: 'Email'},
|
||||
{key: 'client', label: 'Customer/Prospect 0/1/2/3'},
|
||||
{key: 'fournisseur', label: 'Supplier 0/1'},
|
||||
{key: 'client', type: "integer", label: 'Customer/Prospect 0/1/2/3'},
|
||||
{key: 'fournisseur', type: "integer", label: 'Supplier 0/1'},
|
||||
{key: 'code_client', label: 'Customer code'},
|
||||
{key: 'code_fournisseur', label: 'Supplier code'}
|
||||
]
|
||||
|
||||
@ -1,33 +1,39 @@
|
||||
/*jshint esversion: 6 */
|
||||
const triggerThirdparty = require('./triggers/thirdparty');
|
||||
const triggerOrder = require('./triggers/order');
|
||||
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 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.
|
||||
// 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;
|
||||
};
|
||||
// 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 sessionRefreshIf401 = (response, z, bundle) => {
|
||||
// if (bundle.authData.sessionKey) {
|
||||
// if (response.status === 401) {
|
||||
// throw new z.errors.RefreshAuthError('Session apikey needs refreshing.');
|
||||
// }
|
||||
// }
|
||||
// return response;
|
||||
// };
|
||||
|
||||
// We can roll up all our behaviors in an App.
|
||||
const App = {
|
||||
@ -40,11 +46,11 @@ const App = {
|
||||
|
||||
// beforeRequest & afterResponse are optional hooks into the provided HTTP client
|
||||
beforeRequest: [
|
||||
includeSessionKeyHeader
|
||||
...befores
|
||||
],
|
||||
|
||||
afterResponse: [
|
||||
sessionRefreshIf401
|
||||
...afters
|
||||
],
|
||||
|
||||
// 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!
|
||||
triggers: {
|
||||
[triggerThirdparty.key]: triggerThirdparty,
|
||||
[triggerAction.key]: triggerAction,
|
||||
[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!
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dolibarr",
|
||||
"version": "1.0.0",
|
||||
"version": "1.13.0",
|
||||
"description": "An app for connecting Dolibarr to the Zapier platform.",
|
||||
"repository": "Dolibarr/dolibarr",
|
||||
"homepage": "https://www.dolibarr.org/",
|
||||
@ -15,7 +15,7 @@
|
||||
"npm": ">=5.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"zapier-platform-core": "8.0.1"
|
||||
"zapier-platform-core": "10.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^5.2.0",
|
||||
|
||||
@ -54,13 +54,20 @@ module.exports = {
|
||||
// outputFields: () => { return []; }
|
||||
// Alternatively, a static field definition should be provided, to specify labels for the fields
|
||||
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: 'firstname', label: 'Firstname'},
|
||||
{key: 'directions', label: 'Directions'},
|
||||
{key: 'authorId', label: 'Author ID'},
|
||||
{key: 'style', label: 'Style'}
|
||||
{key: 'authorId', type: "integer", label: 'Author ID'},
|
||||
{
|
||||
key: 'style',
|
||||
label: 'Style'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -10,14 +10,14 @@ const subscribeHook = (z, bundle) => {
|
||||
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 need to complete. You can also register middleware to control this.
|
||||
const options = {
|
||||
url: url,
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
body: data,
|
||||
};
|
||||
|
||||
// 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 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,
|
||||
url: bundle.authData.url + '/api/index.php/zapierapi/hook/' + bundle.subscribeData.id,
|
||||
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.
|
||||
const module = bundle.inputData.module;
|
||||
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)]);
|
||||
@ -100,7 +100,7 @@ module.exports = {
|
||||
noun: 'Action',
|
||||
display: {
|
||||
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.
|
||||
@ -111,6 +111,7 @@ module.exports = {
|
||||
inputFields: [
|
||||
{
|
||||
key: 'action',
|
||||
required: true,
|
||||
type: 'string',
|
||||
helpText: 'Which action of agenda this should trigger on.',
|
||||
choices: {
|
||||
@ -145,12 +146,33 @@ module.exports = {
|
||||
// outputFields: () => { return []; }
|
||||
// Alternatively, a static field definition should be provided, to specify labels for the fields
|
||||
outputFields: [
|
||||
{key: 'id', label: 'ID'},
|
||||
{key: 'createdAt', label: 'Created At'},
|
||||
{key: 'name', label: 'Name'},
|
||||
{key: 'usertodo__name', label: 'UserToDo Name'},
|
||||
{key: 'authorId', label: 'Author ID'},
|
||||
{key: 'action', label: 'Action'}
|
||||
{
|
||||
key: 'id',
|
||||
type: "integer",
|
||||
label: 'ID'
|
||||
},
|
||||
{
|
||||
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'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => {
|
||||
const options = {
|
||||
url: url,
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
body: data,
|
||||
};
|
||||
|
||||
// You may return a promise or a normal data structure from any perform method.
|
||||
@ -90,7 +90,7 @@ module.exports = {
|
||||
noun: 'Order',
|
||||
display: {
|
||||
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.
|
||||
@ -101,6 +101,7 @@ module.exports = {
|
||||
inputFields: [
|
||||
{
|
||||
key: 'action',
|
||||
required: true,
|
||||
type: 'string',
|
||||
helpText: 'Which action of order this should trigger on.',
|
||||
choices: {
|
||||
@ -136,11 +137,11 @@ module.exports = {
|
||||
// outputFields: () => { return []; }
|
||||
// Alternatively, a static field definition should be provided, to specify labels for the fields
|
||||
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: 'directions', label: 'Directions'},
|
||||
{key: 'authorId', label: 'Author ID'},
|
||||
{key: 'authorId', type: "integer", label: 'Author ID'},
|
||||
{key: 'module', label: 'Module'},
|
||||
{key: 'action', label: 'Action'}
|
||||
]
|
||||
|
||||
@ -17,7 +17,7 @@ const subscribeHook = (z, bundle) => {
|
||||
const options = {
|
||||
url: url,
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data)
|
||||
body: data,
|
||||
};
|
||||
|
||||
// You may return a promise or a normal data structure from any perform method.
|
||||
@ -112,7 +112,7 @@ module.exports = {
|
||||
noun: 'Thirdparty',
|
||||
display: {
|
||||
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.
|
||||
@ -123,6 +123,7 @@ module.exports = {
|
||||
inputFields: [
|
||||
{
|
||||
key: 'action',
|
||||
required: true,
|
||||
type: 'string',
|
||||
helpText: 'Which action of thirdparty this should trigger on.',
|
||||
choices: {
|
||||
@ -159,12 +160,12 @@ module.exports = {
|
||||
// outputFields: () => { return []; }
|
||||
// Alternatively, a static field definition should be provided, to specify labels for the fields
|
||||
outputFields: [
|
||||
{key: 'id', label: 'ID'},
|
||||
{key: 'id', type: "integer", label: 'ID'},
|
||||
{key: 'createdAt', label: 'Created At'},
|
||||
{key: 'name', label: 'Name'},
|
||||
{key: 'name_alias', label: 'Name alias'},
|
||||
{key: 'firstname', label: 'Firstame'},
|
||||
{key: 'authorId', label: 'Author ID'},
|
||||
{key: 'firstname', label: 'Firstname'},
|
||||
{key: 'authorId', type: "integer", label: 'Author ID'},
|
||||
{key: 'action', label: 'Action'},
|
||||
{key: 'client', label: 'Customer/Prospect 0/1/2/3'},
|
||||
{key: 'fournisseur', label: 'Supplier 0/1'},
|
||||
|
||||
237
dev/examples/zapier/triggers/ticket.js
Normal file
237
dev/examples/zapier/triggers/ticket.js
Normal 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'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
177
dev/examples/zapier/triggers/user.js
Normal file
177
dev/examples/zapier/triggers/user.js
Normal 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'}
|
||||
]
|
||||
}
|
||||
};
|
||||
@ -1,33 +1,45 @@
|
||||
README (deutsch / german / allemand)
|
||||
--------------------------------
|
||||
------------------------------------
|
||||
|
||||
|
||||
--------------------------------
|
||||
------------------------------------
|
||||
Download / Herunterladen
|
||||
--------------------------------
|
||||
------------------------------------
|
||||
|
||||
* Dolibarr ERP/CRM kann man über die offizielle Dolibarr Website
|
||||
|
||||
https://www.dolibarr.org/downloads
|
||||
oder direkt von Sourceforge
|
||||
|
||||
oder direkt bei Sourceforge
|
||||
|
||||
https://sourceforge.net/projects/dolibarr/files/
|
||||
|
||||
herunterladen.
|
||||
|
||||
|
||||
|
||||
* Die meisten externen Module/Themens sind über den DoliStore verfügbar:
|
||||
https://www.dolistore.com/de/
|
||||
|
||||
|
||||
--------------------------------
|
||||
Installation
|
||||
--------------------------------
|
||||
|
||||
* Für eine kurze Einleitung, schau auf die README Datei im Hauptverzeichnis.
|
||||
------------------------------------
|
||||
Installation / Hilfe
|
||||
------------------------------------
|
||||
|
||||
* Für eine kurze Einleitung schau in die README Datei im Hauptverzeichnis.
|
||||
|
||||
* Umfangreiche Dokumentationen sind im Dolibarr Wiki zu finden:
|
||||
https://wiki.dolibarr.org/index.php/Hauptseite
|
||||
|
||||
* eine Deutsche Community bietet der Dolibarr e.V. unter
|
||||
https://www.dolibarr.de/
|
||||
|
||||
|
||||
|
||||
|
||||
------------------------------------
|
||||
Zusatzmodule
|
||||
------------------------------------
|
||||
|
||||
* Die meisten externen Module/Themen sind über den offiziellen DoliStore verfügbar:
|
||||
|
||||
https://www.dolistore.com/de/
|
||||
|
||||
|
||||
|
||||
|
||||
@ -65,12 +65,12 @@ if (!$sortfield) $sortfield = "aa.account_number";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
|
||||
$arrayfields = array(
|
||||
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
|
||||
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
|
||||
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
|
||||
'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
|
||||
'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
|
||||
'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
|
||||
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
|
||||
'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
|
||||
'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
|
||||
'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
|
||||
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
|
||||
);
|
||||
|
||||
@ -93,24 +93,24 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
|
||||
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
|
||||
{
|
||||
$search_account = "";
|
||||
$search_label = "";
|
||||
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_label = "";
|
||||
$search_labelshort = "";
|
||||
$search_accountparent = "";
|
||||
$search_pcgtype = "";
|
||||
$search_pcgtype = "";
|
||||
$search_array_options = array();
|
||||
}
|
||||
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
|
||||
{
|
||||
if ($chartofaccounts > 0)
|
||||
{
|
||||
}
|
||||
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
|
||||
{
|
||||
if ($chartofaccounts > 0)
|
||||
{
|
||||
// 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 .= ' 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)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'disable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->accountDeactivate($id, $mode);
|
||||
}
|
||||
if ($action == 'disable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->accountDeactivate($id, $mode);
|
||||
}
|
||||
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'enable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->account_activate($id, $mode);
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'enable') {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->account_activate($id, $mode);
|
||||
}
|
||||
$action = 'update';
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -273,9 +273,9 @@ if ($resql)
|
||||
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<!-- Add javascript to reload page when we click "Change plan" -->
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<!-- Add javascript to reload page when we click "Change plan" -->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$("#change_chart").on("click", function (e) {
|
||||
@ -285,7 +285,7 @@ if ($resql)
|
||||
});
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
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="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
|
||||
print $langs->trans("Selectchartofaccounts")." : ";
|
||||
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 .= " 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 .= " WHERE a.active = 1";
|
||||
dol_syslog('accountancy/admin/account.php $sql='.$sql);
|
||||
print $sql;
|
||||
$resqlchart = $db->query($sql);
|
||||
if ($resqlchart) {
|
||||
$numbis = $db->num_rows($resqlchart);
|
||||
$i = 0;
|
||||
while ($i < $numbis) {
|
||||
$obj = $db->fetch_object($resqlchart);
|
||||
print $langs->trans("Selectchartofaccounts")." : ";
|
||||
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 .= " 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 .= " WHERE a.active = 1";
|
||||
dol_syslog('accountancy/admin/account.php $sql='.$sql);
|
||||
print $sql;
|
||||
$resqlchart = $db->query($sql);
|
||||
if ($resqlchart) {
|
||||
$numbis = $db->num_rows($resqlchart);
|
||||
$i = 0;
|
||||
while ($i < $numbis) {
|
||||
$obj = $db->fetch_object($resqlchart);
|
||||
|
||||
print '<option value="'.$obj->rowid.'"';
|
||||
print ($pcgver == $obj->rowid) ? ' selected' : '';
|
||||
print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
|
||||
print '<option value="'.$obj->rowid.'"';
|
||||
print ($pcgver == $obj->rowid) ? ' selected' : '';
|
||||
print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
print "</select>";
|
||||
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")).'">';
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
print "</select>";
|
||||
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 '<br>';
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
$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 = '';
|
||||
$massactionbutton = '';
|
||||
$moreforfilter = '';
|
||||
$massactionbutton = '';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
// Line for search fields
|
||||
print '<tr class="liste_titre_filter">';
|
||||
@ -358,7 +358,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
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.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);
|
||||
@ -422,7 +422,7 @@ if ($resql)
|
||||
print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
|
||||
$accountparent->id = $obj->rowid2;
|
||||
$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 "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
|
||||
@ -472,13 +472,13 @@ if ($id)
|
||||
|
||||
if ($valuetoshow != '') {
|
||||
print '<td class="'.$class.'">';
|
||||
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>';
|
||||
} elseif (!empty($tabhelp[$id][$value])) {
|
||||
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
} else {
|
||||
print $valuetoshow;
|
||||
}
|
||||
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>';
|
||||
} elseif (!empty($tabhelp[$id][$value])) {
|
||||
print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]);
|
||||
} else {
|
||||
print $valuetoshow;
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
|
||||
|
||||
@ -108,16 +108,16 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} elseif ($res < 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = "create";
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
|
||||
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
setEventMessages("RecordCreatedSuccessfully", null, 'mesgs');
|
||||
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
|
||||
@ -158,15 +158,15 @@ if ($action == 'add' && $user->rights->accounting->chartofaccount)
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0) {
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
header("Location: ".$urltogo);
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
header("Location: ".$urltogo);
|
||||
exit();
|
||||
} else {
|
||||
$mesg = $object->error;
|
||||
}
|
||||
} else {
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
header("Location: ".$urltogo);
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
header("Location: ".$urltogo);
|
||||
exit();
|
||||
}
|
||||
} elseif ($action == 'delete' && $user->rights->accounting->chartofaccount) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -39,8 +39,8 @@ $action = GETPOST('action', 'aZ09');
|
||||
|
||||
|
||||
$list_account_main = array(
|
||||
'ACCOUNTING_RESULT_PROFIT',
|
||||
'ACCOUNTING_RESULT_LOSS'
|
||||
'ACCOUNTING_RESULT_PROFIT',
|
||||
'ACCOUNTING_RESULT_LOSS'
|
||||
);
|
||||
|
||||
/*
|
||||
@ -48,17 +48,17 @@ $list_account_main = array(
|
||||
*/
|
||||
|
||||
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 (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
if (!empty($defaultjournal)) {
|
||||
if (!dolibarr_set_const($db, 'ACCOUNTING_CLOSURE_DEFAULT_JOURNAL', $defaultjournal, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
}
|
||||
|
||||
foreach ($list_account_main as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
@ -99,20 +99,20 @@ print '<input type="hidden" name="action" value="update">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
foreach ($list_account_main as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
$keydesc = $key.'_Desc';
|
||||
print '<tr class="oddeven value">';
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
$keydesc = $key.'_Desc';
|
||||
|
||||
$htmltext = $langs->trans($keydesc);
|
||||
print '<td class="fieldrequired" width="50%">';
|
||||
print $form->textwithpicto($label, $htmltext);
|
||||
print '</td>';
|
||||
// Value
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
$htmltext = $langs->trans($keydesc);
|
||||
print '<td class="fieldrequired" width="50%">';
|
||||
print $form->textwithpicto($label, $htmltext);
|
||||
print '</td>';
|
||||
// Value
|
||||
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 '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Journal
|
||||
|
||||
@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09');
|
||||
|
||||
// Parameters ACCOUNTING_EXPORT_*
|
||||
$main_option = array(
|
||||
'ACCOUNTING_EXPORT_PREFIX_SPEC',
|
||||
'ACCOUNTING_EXPORT_PREFIX_SPEC',
|
||||
);
|
||||
|
||||
$configuration = AccountancyExport::getTypeConfig();
|
||||
@ -58,22 +58,22 @@ $listcr = $configuration['cr'];
|
||||
|
||||
|
||||
$model_option = array(
|
||||
'1' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_FORMAT',
|
||||
'param' => $listformat,
|
||||
),
|
||||
'2' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
|
||||
'param' => '',
|
||||
),
|
||||
'3' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_ENDLINE',
|
||||
'param' => $listcr,
|
||||
),
|
||||
'4' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_DATE',
|
||||
'param' => '',
|
||||
),
|
||||
'1' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_FORMAT',
|
||||
'param' => $listformat,
|
||||
),
|
||||
'2' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_SEPARATORCSV',
|
||||
'param' => '',
|
||||
),
|
||||
'3' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_ENDLINE',
|
||||
'param' => $listcr,
|
||||
),
|
||||
'4' => array(
|
||||
'label' => 'ACCOUNTING_EXPORT_DATE',
|
||||
'param' => '',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@ -105,22 +105,22 @@ if ($action == 'update') {
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($listparam[$modelcsv] as $key => $value) {
|
||||
$constante = $key;
|
||||
foreach ($listparam[$modelcsv] as $key => $value) {
|
||||
$constante = $key;
|
||||
|
||||
if (strpos($constante, 'ACCOUNTING') !== false) {
|
||||
$constvalue = GETPOST($key, 'alpha');
|
||||
if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strpos($constante, 'ACCOUNTING') !== false) {
|
||||
$constvalue = GETPOST($key, 'alpha');
|
||||
if (!dolibarr_set_const($db, $constante, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
// reload
|
||||
$configuration = AccountancyExport::getTypeConfig();
|
||||
$listparam = $configuration['param'];
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
// reload
|
||||
$configuration = AccountancyExport::getTypeConfig();
|
||||
$listparam = $configuration['param'];
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
@ -148,36 +148,36 @@ print 'jQuery(document).ready(function () {'."\n";
|
||||
print ' function initfields()'."\n";
|
||||
print ' {'."\n";
|
||||
foreach ($listparam as $key => $param) {
|
||||
print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
|
||||
print ' {'."\n";
|
||||
print ' //console.log("'.$param['label'].'");'."\n";
|
||||
if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
|
||||
}
|
||||
print ' }'."\n";
|
||||
print ' if (jQuery("#ACCOUNTING_EXPORT_MODELCSV").val()=="'.$key.'")'."\n";
|
||||
print ' {'."\n";
|
||||
print ' //console.log("'.$param['label'].'");'."\n";
|
||||
if (empty($param['ACCOUNTING_EXPORT_FORMAT'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$conf->global->ACCOUNTING_EXPORT_FORMAT.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").val("'.$param['ACCOUNTING_EXPORT_FORMAT'].'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_FORMAT").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_SEPARATORCSV'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").val("'.$conf->global->ACCOUNTING_EXPORT_SEPARATORCSV.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_SEPARATORCSV").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_ENDLINE'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_ENDLINE").removeAttr("disabled");'."\n";
|
||||
}
|
||||
if (empty($param['ACCOUNTING_EXPORT_DATE'])) {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").prop("disabled", true);'."\n";
|
||||
} else {
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").val("'.$conf->global->ACCOUNTING_EXPORT_DATE.'");'."\n";
|
||||
print ' jQuery("#ACCOUNTING_EXPORT_DATE").removeAttr("disabled");'."\n";
|
||||
}
|
||||
print ' }'."\n";
|
||||
}
|
||||
print ' }'."\n";
|
||||
print ' initfields();'."\n";
|
||||
@ -262,17 +262,17 @@ if ($num2) {
|
||||
foreach ($model_option as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
$label = $key['label'];
|
||||
// Param
|
||||
$label = $key['label'];
|
||||
print '<td width="50%">'.$langs->trans($label).'</td>';
|
||||
|
||||
// Value
|
||||
print '<td>';
|
||||
if (is_array($key['param'])) {
|
||||
print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
|
||||
} else {
|
||||
print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
|
||||
}
|
||||
print '<td>';
|
||||
if (is_array($key['param'])) {
|
||||
print $form->selectarray($label, $key['param'], $conf->global->$label, 0);
|
||||
} else {
|
||||
print '<input type="text" size="20" id="'.$label.'" name="'.$key['label'].'" value="'.$conf->global->$label.'">';
|
||||
}
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ if ($result)
|
||||
$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');
|
||||
|
||||
@ -420,15 +420,15 @@ if ($id)
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
$class = "left";
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
|
||||
if ($valuetoshow != '') {
|
||||
print '<td class="'.$class.'">';
|
||||
@ -540,14 +540,14 @@ if ($id)
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
$valuetoshow = $langs->trans("NatureOfJournal");
|
||||
}
|
||||
|
||||
// Affiche nom du champ
|
||||
if ($showfield) {
|
||||
@ -594,7 +594,7 @@ if ($id)
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
$langs->load("accountancy");
|
||||
$langs->load("accountancy");
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield = 1;
|
||||
@ -607,7 +607,7 @@ if ($id)
|
||||
$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') {
|
||||
$valuetoshow = $langs->trans($obj->label);
|
||||
}
|
||||
}
|
||||
|
||||
$class = 'tddict';
|
||||
// Show value for field
|
||||
@ -619,15 +619,15 @@ if ($id)
|
||||
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
|
||||
if (isset($obj->code) && $id != 10) {
|
||||
if (($obj->code == '0' || $obj->code == '' || preg_match('/unknown/i', $obj->code))) {
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
} elseif ($obj->code == 'RECEP') {
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
} elseif ($obj->code == 'EF0') {
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
}
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
} elseif ($obj->code == 'RECEP') {
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
} elseif ($obj->code == 'EF0') {
|
||||
$iserasable = 0;
|
||||
$canbedisabled = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$canbemodified = $iserasable;
|
||||
|
||||
@ -42,7 +42,7 @@ if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->bind->write)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// search & action GETPOST
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -100,14 +100,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
// 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
|
||||
{
|
||||
$search_ref = '';
|
||||
$search_label = '';
|
||||
$search_desc = '';
|
||||
$search_ref = '';
|
||||
$search_label = '';
|
||||
$search_desc = '';
|
||||
$search_vat = '';
|
||||
$search_onsell = '';
|
||||
$search_onpurchase = '';
|
||||
$search_current_account = '';
|
||||
$search_current_account_valid = '-1';
|
||||
$search_onsell = '';
|
||||
$search_onpurchase = '';
|
||||
$search_current_account = '';
|
||||
$search_current_account_valid = '-1';
|
||||
}
|
||||
|
||||
// Sales or Purchase mode ?
|
||||
@ -117,8 +117,8 @@ if ($action == 'update') {
|
||||
|
||||
$accounting_product_modes = array(
|
||||
'ACCOUNTANCY_SELL',
|
||||
'ACCOUNTANCY_SELL_INTRA',
|
||||
'ACCOUNTANCY_SELL_EXPORT',
|
||||
'ACCOUNTANCY_SELL_INTRA',
|
||||
'ACCOUNTANCY_SELL_EXPORT',
|
||||
'ACCOUNTANCY_BUY',
|
||||
'ACCOUNTANCY_BUY_INTRA',
|
||||
'ACCOUNTANCY_BUY_EXPORT'
|
||||
@ -172,22 +172,22 @@ if ($action == 'update') {
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
$sql .= " SET accountancy_code_sell = ".$accounting->account_number;
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
$sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
$sql .= " SET accountancy_code_sell_intra = ".$accounting->account_number;
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
$sql .= " SET accountancy_code_sell_export = ".$accounting->account_number;
|
||||
}
|
||||
$sql .= " WHERE rowid = ".((int) $productid);
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
|
||||
if ($db->query($sql))
|
||||
{
|
||||
$ok++;
|
||||
$db->commit();
|
||||
$ok++;
|
||||
$db->commit();
|
||||
} else {
|
||||
$ko++;
|
||||
$db->rollback();
|
||||
$ko++;
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,7 +253,7 @@ $sql .= " aa.rowid as aaid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON";
|
||||
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')
|
||||
{
|
||||
$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').')';
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_buy", $search_current_account);
|
||||
}
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_buy", $search_current_account);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
if (strlen(trim($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);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell", $search_current_account);
|
||||
}
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell", $search_current_account);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
|
||||
}
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell_intra", $search_current_account);
|
||||
}
|
||||
} else {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
|
||||
}
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_sell_export", $search_current_account);
|
||||
}
|
||||
}
|
||||
if ($search_current_account_valid == 'withoutvalidaccount')
|
||||
{
|
||||
@ -301,7 +301,7 @@ if ($search_current_account_valid == 'withoutvalidaccount')
|
||||
}
|
||||
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
|
||||
if (strlen(trim($search_ref))) {
|
||||
@ -324,13 +324,13 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
@ -342,32 +342,32 @@ if ($result)
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
|
||||
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
|
||||
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($search_ref > 0) $param .= "&search_desc=".urlencode($search_ref);
|
||||
if ($search_label > 0) $param .= "&search_desc=".urlencode($search_label);
|
||||
if ($search_desc > 0) $param .= "&search_desc=".urlencode($search_desc);
|
||||
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_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 ($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 ($accounting_product_mode) $param .= '&accounting_product_mode='.urlencode($accounting_product_mode);
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
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 '<span class="opacitymedium">'.$langs->trans("InitAccountancyDesc").'</span><br>';
|
||||
print '<br>';
|
||||
|
||||
// Select mode
|
||||
// Select mode
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Options').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
@ -377,13 +377,13 @@ if ($result)
|
||||
print "</td></tr>\n";
|
||||
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 '<td>'.$langs->trans('OptionModeProductSellIntraDesc');
|
||||
print "</td></tr>\n";
|
||||
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></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 '<td>'.$langs->trans('OptionModeProductSellExportDesc');
|
||||
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 '<td>'.$langs->trans('OptionModeProductSellExportDesc');
|
||||
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 '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
|
||||
if ($mysoc->isInEEC())
|
||||
@ -405,8 +405,8 @@ if ($result)
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$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").'">';
|
||||
//print '<br><div class="center">'.$buttonsave.'</div>';
|
||||
$buttonsave = '<input type="submit" class="button" id="changeaccount" name="changeaccount" value="'.$langs->trans("Save").'">';
|
||||
//print '<br><div class="center">'.$buttonsave.'</div>';
|
||||
|
||||
$texte = $langs->trans("ListOfProductsServices");
|
||||
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_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);
|
||||
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 ');
|
||||
// On sell / On purchase
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell_intra";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell_export";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_buy";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell_intra";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_sell_export";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_buy";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_buy_intra";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
@ -475,8 +475,8 @@ if ($result)
|
||||
$product_static = new Product($db);
|
||||
|
||||
$i = 0;
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// 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_id = $aarowid_prodsell;
|
||||
} 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_id = $aarowid_prodsell_intra;
|
||||
$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;
|
||||
} 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_id = $aarowid_prodsell_export;
|
||||
} else {
|
||||
$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;
|
||||
} else {
|
||||
$compta_prodsell = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : $langs->trans("CodeNotDef"));
|
||||
$compta_prodsell_id = $aarowid_prodsell;
|
||||
}
|
||||
@ -560,11 +560,11 @@ if ($result)
|
||||
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
|
||||
{
|
||||
// TODO ADJUST DESCRIPTION SIZE
|
||||
// print '<td class="left">' . $obj->description . '</td>';
|
||||
// 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;
|
||||
print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>';
|
||||
// TODO ADJUST DESCRIPTION SIZE
|
||||
// print '<td class="left">' . $obj->description . '</td>';
|
||||
// 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;
|
||||
print '<td>'.nl2br(dol_trunc($obj->description, $trunclength)).'</td>';
|
||||
}
|
||||
|
||||
// VAT
|
||||
@ -581,36 +581,36 @@ if ($result)
|
||||
// Current accounting account
|
||||
print '<td class="left">';
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
print length_accountg($obj->accountancy_code_buy);
|
||||
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
print length_accountg($obj->accountancy_code_buy);
|
||||
if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_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"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_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"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
print length_accountg($obj->accountancy_code_sell);
|
||||
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_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"));
|
||||
print length_accountg($obj->accountancy_code_buy_intra);
|
||||
if ($obj->accountancy_code_buy_intra && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_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"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
print length_accountg($obj->accountancy_code_sell);
|
||||
if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_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"));
|
||||
} else {
|
||||
print length_accountg($obj->accountancy_code_sell_export);
|
||||
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
}
|
||||
print length_accountg($obj->accountancy_code_sell_export);
|
||||
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// New account to set
|
||||
$defaultvalue = '';
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
// Accounting account buy
|
||||
// Accounting account buy
|
||||
print '<td class="left">';
|
||||
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
||||
if (empty($defaultvalue)) $defaultvalue = $compta_prodbuy;
|
||||
$codesell = length_accountg($obj->accountancy_code_buy);
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
// Accounting account buy intra (In EEC)
|
||||
@ -620,7 +620,7 @@ if ($result)
|
||||
$codesell = length_accountg($obj->accountancy_code_buy_intra);
|
||||
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
// Accounting account buy export (Out of EEC)
|
||||
@ -630,7 +630,7 @@ if ($result)
|
||||
$codesell = length_accountg($obj->accountancy_code_buy_export);
|
||||
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
// Accounting account sell
|
||||
@ -640,32 +640,32 @@ if ($result)
|
||||
$codesell = length_accountg($obj->accountancy_code_sell);
|
||||
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
// Accounting account sell intra (In EEC)
|
||||
print '<td class="left">';
|
||||
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
||||
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
|
||||
$codesell = length_accountg($obj->accountancy_code_sell_intra);
|
||||
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
||||
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 '</td>';
|
||||
} else {
|
||||
// Accounting account sell export (Out of EEC)
|
||||
print '<td class="left">';
|
||||
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
||||
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
|
||||
$codesell = length_accountg($obj->accountancy_code_sell_export);
|
||||
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 '</td>';
|
||||
}
|
||||
// Accounting account sell intra (In EEC)
|
||||
print '<td class="left">';
|
||||
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
||||
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
|
||||
$codesell = length_accountg($obj->accountancy_code_sell_intra);
|
||||
//var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell);
|
||||
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
|
||||
print '</td>';
|
||||
} else {
|
||||
// Accounting account sell export (Out of EEC)
|
||||
print '<td class="left">';
|
||||
//$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code
|
||||
if (empty($defaultvalue)) $defaultvalue = $compta_prodsell;
|
||||
$codesell = length_accountg($obj->accountancy_code_sell_export);
|
||||
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, 0, 'maxwidth300 maxwidthonsmartphone productforselect');
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Checkbox select
|
||||
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>";
|
||||
$i++;
|
||||
}
|
||||
@ -689,7 +689,17 @@ if ($result)
|
||||
if (atleastoneselected) 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();
|
||||
});
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ $title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
|
||||
llxHeader('', $title);
|
||||
|
||||
// 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 .= " WHERE sa.entity IN (".getEntity('societe').")";
|
||||
$sql .= " AND sa.code_compta <> ''";
|
||||
@ -148,7 +148,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db
|
||||
|
||||
// Supplier
|
||||
$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 .= " AND sa.code_compta_fournisseur <> ''";
|
||||
//print $sql;
|
||||
@ -190,7 +190,7 @@ if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db
|
||||
|
||||
// User
|
||||
$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 .= " AND u.accountancy_code <> ''";
|
||||
//print $sql;
|
||||
@ -287,7 +287,7 @@ if ($resql)
|
||||
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['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"> </td>'; }
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
@ -335,17 +335,17 @@ if ($resql)
|
||||
print '<td class="center">';
|
||||
$s = '';
|
||||
// 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>';
|
||||
}
|
||||
// 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>';
|
||||
}
|
||||
// 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>';
|
||||
}
|
||||
@ -378,17 +378,17 @@ if ($resql)
|
||||
print '<td class="center">';
|
||||
$e = '';
|
||||
// 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>';
|
||||
}
|
||||
// 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>';
|
||||
}
|
||||
// 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>';
|
||||
}
|
||||
|
||||
@ -274,11 +274,11 @@ if ($action != 'export_csv')
|
||||
$sous_total_credit = 0;
|
||||
$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 .= " 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 .= " GROUP BY t.numero_compte";
|
||||
|
||||
@ -292,12 +292,12 @@ if ($action != 'export_csv')
|
||||
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
|
||||
if (!empty($accountingaccountstatic->account_number)) {
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
|
||||
} else {
|
||||
$accounting_account = length_accountg($line->numero_compte);
|
||||
}
|
||||
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
|
||||
if (!empty($accountingaccountstatic->account_number)) {
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
|
||||
} else {
|
||||
$accounting_account = length_accountg($line->numero_compte);
|
||||
}
|
||||
|
||||
$link = '';
|
||||
$total_debit += $line->debit;
|
||||
|
||||
@ -114,12 +114,12 @@ if ($action == "confirm_update") {
|
||||
$object->credit = $credit;
|
||||
|
||||
if (floatval($debit) != 0.0) {
|
||||
$object->montant = $debit; // deprecated
|
||||
$object->montant = $debit; // deprecated
|
||||
$object->amount = $debit;
|
||||
$object->sens = 'D';
|
||||
}
|
||||
if (floatval($credit) != 0.0) {
|
||||
$object->montant = $credit; // deprecated
|
||||
$object->montant = $credit; // deprecated
|
||||
$object->amount = $credit;
|
||||
$object->sens = 'C';
|
||||
}
|
||||
@ -175,13 +175,13 @@ if ($action == "confirm_update") {
|
||||
$object->fk_docdet = (int) GETPOST('fk_docdet', 'int');
|
||||
|
||||
if (floatval($debit) != 0.0) {
|
||||
$object->montant = $debit; // deprecated
|
||||
$object->montant = $debit; // deprecated
|
||||
$object->amount = $debit;
|
||||
$object->sens = 'D';
|
||||
}
|
||||
|
||||
if (floatval($credit) != 0.0) {
|
||||
$object->montant = $credit; // deprecated
|
||||
$object->montant = $credit; // deprecated
|
||||
$object->amount = $credit;
|
||||
$object->sens = 'C';
|
||||
}
|
||||
@ -245,7 +245,7 @@ if ($action == "confirm_update") {
|
||||
$object->journal_label = $journal_label;
|
||||
$object->fk_doc = 0;
|
||||
$object->fk_docdet = 0;
|
||||
$object->montant = 0; // deprecated
|
||||
$object->montant = 0; // deprecated
|
||||
$object->amount = 0;
|
||||
|
||||
$result = $object->createStd($user, 0, $mode);
|
||||
|
||||
@ -151,7 +151,7 @@ $arrayfields = array(
|
||||
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
|
||||
't.date_creation'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0),
|
||||
't.tms'=>array('label'=>$langs->trans("DateModification"), 'checked'=>0),
|
||||
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
|
||||
't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
|
||||
);
|
||||
|
||||
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))
|
||||
{
|
||||
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
|
||||
{
|
||||
$search_mvt_num = '';
|
||||
$search_doc_type = '';
|
||||
$search_doc_ref = '';
|
||||
$search_doc_date = '';
|
||||
$search_accountancy_code = '';
|
||||
$search_accountancy_code_start = '';
|
||||
$search_accountancy_code_end = '';
|
||||
$search_accountancy_aux_code = '';
|
||||
$search_accountancy_aux_code_start = '';
|
||||
$search_accountancy_aux_code_end = '';
|
||||
$search_mvt_label = '';
|
||||
$search_direction = '';
|
||||
$search_ledger_code = '';
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
$search_date_creation_start = '';
|
||||
$search_date_creation_end = '';
|
||||
$search_date_modification_start = '';
|
||||
$search_date_modification_end = '';
|
||||
$search_date_export_start = '';
|
||||
$search_date_export_end = '';
|
||||
$search_debit = '';
|
||||
$search_credit = '';
|
||||
$search_lettering_code = '';
|
||||
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_doc_type = '';
|
||||
$search_doc_ref = '';
|
||||
$search_doc_date = '';
|
||||
$search_accountancy_code = '';
|
||||
$search_accountancy_code_start = '';
|
||||
$search_accountancy_code_end = '';
|
||||
$search_accountancy_aux_code = '';
|
||||
$search_accountancy_aux_code_start = '';
|
||||
$search_accountancy_aux_code_end = '';
|
||||
$search_mvt_label = '';
|
||||
$search_direction = '';
|
||||
$search_ledger_code = '';
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
$search_date_creation_start = '';
|
||||
$search_date_creation_end = '';
|
||||
$search_date_modification_start = '';
|
||||
$search_date_modification_end = '';
|
||||
$search_date_export_start = '';
|
||||
$search_date_export_end = '';
|
||||
$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;
|
||||
$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']);
|
||||
}
|
||||
if (!empty($search_date_end)) {
|
||||
$filter['t.doc_date<='] = $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']);
|
||||
}
|
||||
if (!empty($search_doc_date)) {
|
||||
$filter['t.doc_date'] = $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']);
|
||||
}
|
||||
if (!empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type='.urlencode($search_doc_type);
|
||||
}
|
||||
if (!empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
|
||||
}
|
||||
if (!empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
|
||||
}
|
||||
if (!empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
|
||||
}
|
||||
if (!empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
|
||||
}
|
||||
if (!empty($search_accountancy_aux_code)) {
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
|
||||
}
|
||||
if (!empty($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);
|
||||
}
|
||||
if (!empty($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);
|
||||
}
|
||||
if (!empty($search_mvt_label)) {
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label='.urlencode($search_mvt_label);
|
||||
}
|
||||
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_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num='.urlencode($search_mvt_num);
|
||||
}
|
||||
if (!empty($search_date_creation_start)) {
|
||||
$filter['t.date_creation>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_creation_end)) {
|
||||
$filter['t.date_creation<='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_modification_start)) {
|
||||
$filter['t.tms>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_modification_end)) {
|
||||
$filter['t.tms<='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_export_start)) {
|
||||
$filter['t.date_export>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_export_end)) {
|
||||
$filter['t.date_export<='] = $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']);
|
||||
}
|
||||
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);
|
||||
}
|
||||
// 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;
|
||||
$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']);
|
||||
}
|
||||
if (!empty($search_date_end)) {
|
||||
$filter['t.doc_date<='] = $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']);
|
||||
}
|
||||
if (!empty($search_doc_date)) {
|
||||
$filter['t.doc_date'] = $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']);
|
||||
}
|
||||
if (!empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type='.urlencode($search_doc_type);
|
||||
}
|
||||
if (!empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref='.urlencode($search_doc_ref);
|
||||
}
|
||||
if (!empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code='.urlencode($search_accountancy_code);
|
||||
}
|
||||
if (!empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
|
||||
}
|
||||
if (!empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
|
||||
}
|
||||
if (!empty($search_accountancy_aux_code)) {
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code);
|
||||
}
|
||||
if (!empty($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);
|
||||
}
|
||||
if (!empty($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);
|
||||
}
|
||||
if (!empty($search_mvt_label)) {
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label='.urlencode($search_mvt_label);
|
||||
}
|
||||
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_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num='.urlencode($search_mvt_num);
|
||||
}
|
||||
if (!empty($search_date_creation_start)) {
|
||||
$filter['t.date_creation>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_creation_end)) {
|
||||
$filter['t.date_creation<='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_modification_start)) {
|
||||
$filter['t.tms>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_modification_end)) {
|
||||
$filter['t.tms<='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_export_start)) {
|
||||
$filter['t.date_export>='] = $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']);
|
||||
}
|
||||
if (!empty($search_date_export_end)) {
|
||||
$filter['t.date_export<='] = $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']);
|
||||
}
|
||||
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);
|
||||
@ -475,48 +475,48 @@ if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
// Export files
|
||||
// Export files
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines, $formatexportset);
|
||||
|
||||
if (!empty($accountancyexport->errors))
|
||||
{
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
} else {
|
||||
// Specify as export : update field date_export
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
if (!empty($accountancyexport->errors))
|
||||
{
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
} else {
|
||||
// Specify as export : update field date_export
|
||||
$error = 0;
|
||||
$db->begin();
|
||||
|
||||
if (is_array($object->lines))
|
||||
{
|
||||
foreach ($object->lines as $movement)
|
||||
{
|
||||
$now = dol_now();
|
||||
if (is_array($object->lines))
|
||||
{
|
||||
foreach ($object->lines as $movement)
|
||||
{
|
||||
$now = dol_now();
|
||||
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
|
||||
$sql .= " SET date_export = '".$db->idate($now)."'";
|
||||
$sql .= " WHERE rowid = ".$movement->id;
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
|
||||
$sql .= " SET date_export = '".$db->idate($now)."'";
|
||||
$sql .= " WHERE rowid = ".$movement->id;
|
||||
|
||||
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
dol_syslog("/accountancy/bookeeping/list.php Function export_file Specify movements as exported sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
|
||||
} else {
|
||||
$error++;
|
||||
$db->rollback();
|
||||
setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
|
||||
}
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
|
||||
} else {
|
||||
$error++;
|
||||
$db->rollback();
|
||||
setEventMessages($langs->trans("NotAllExportedMovementsCouldBeRecordedAsExported"), null, 'errors');
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -629,9 +629,9 @@ else $buttonLabel = $langs->trans("ExportList");
|
||||
|
||||
// Button re-export
|
||||
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 {
|
||||
$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>';
|
||||
|
||||
@ -791,14 +791,14 @@ if (!empty($arrayfields['t.tms']['checked']))
|
||||
// Date export
|
||||
if (!empty($arrayfields['t.date_export']['checked']))
|
||||
{
|
||||
print '<td class="liste_titre center">';
|
||||
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 '</div>';
|
||||
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 '</div>';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre center">';
|
||||
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 '</div>';
|
||||
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 '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Action column
|
||||
print '<td class="liste_titre center">';
|
||||
@ -854,7 +854,7 @@ while ($i < min($num, $limit))
|
||||
$line->label_operation = $obj->label_operation;
|
||||
$line->debit = $obj->debit;
|
||||
$line->credit = $obj->credit;
|
||||
$line->montant = $obj->amount; // deprecated
|
||||
$line->montant = $obj->amount; // deprecated
|
||||
$line->amount = $obj->amount;
|
||||
$line->sens = $obj->sens;
|
||||
$line->lettering_code = $obj->lettering_code;
|
||||
@ -893,65 +893,65 @@ while ($i < min($num, $limit))
|
||||
// Document ref
|
||||
if (!empty($arrayfields['t.doc_ref']['checked']))
|
||||
{
|
||||
if ($line->doc_type == 'customer_invoice')
|
||||
{
|
||||
$langs->loadLangs(array('bills'));
|
||||
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';
|
||||
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'));
|
||||
$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';
|
||||
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'));
|
||||
$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';
|
||||
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
|
||||
}
|
||||
$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 '<td class="nowrap">';
|
||||
|
||||
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||
// Picto + Ref
|
||||
print '<td class="nobordernopadding 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>';
|
||||
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";
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
@ -1065,9 +1065,9 @@ 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 '<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>';
|
||||
|
||||
@ -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';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("accountancy"));
|
||||
$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'));
|
||||
@ -138,7 +138,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
|
||||
|
||||
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
|
||||
{
|
||||
@ -172,55 +172,55 @@ if (empty($reshook))
|
||||
|
||||
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');
|
||||
$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');
|
||||
$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');
|
||||
$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.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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$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)) {
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . urlencode($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);
|
||||
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
|
||||
}
|
||||
if (!empty($search_debit)) {
|
||||
$filter['t.debit'] = $search_debit;
|
||||
$param .= '&search_debit=' . urlencode($search_debit);
|
||||
$param .= '&search_debit='.urlencode($search_debit);
|
||||
}
|
||||
if (!empty($search_credit)) {
|
||||
$filter['t.credit'] = $search_credit;
|
||||
$param .= '&search_credit=' . urlencode($search_credit);
|
||||
$param .= '&search_credit='.urlencode($search_credit);
|
||||
}
|
||||
if (!empty($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="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('VueByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss'=>'marginleftonly btnTitleSelected'));
|
||||
|
||||
$newcardbutton .= ' ';
|
||||
|
||||
$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 ($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;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
@ -427,7 +426,7 @@ 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>';
|
||||
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'])) {
|
||||
@ -447,19 +446,19 @@ if (!empty($arrayfields['t.piece_num']['checked']))
|
||||
}
|
||||
// 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>';
|
||||
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>';
|
||||
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>';
|
||||
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>';
|
||||
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']))
|
||||
@ -535,7 +534,7 @@ while ($i < min($num, $limit))
|
||||
$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 )
|
||||
if ($balance > 0)
|
||||
{
|
||||
print '<td class="nowraponall right">';
|
||||
print price($sous_total_debit - $sous_total_credit);
|
||||
@ -666,7 +665,7 @@ while ($i < min($num, $limit))
|
||||
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>';
|
||||
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']++;
|
||||
}
|
||||
|
||||
@ -681,7 +680,7 @@ while ($i < min($num, $limit))
|
||||
|
||||
// Amount credit
|
||||
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['pos'][$totalarray['nbfield']] = 'totalcredit';
|
||||
$totalarray['val']['totalcredit'] += $line->credit;
|
||||
@ -734,7 +733,7 @@ print '</tr>';
|
||||
$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 )
|
||||
if ($balance > 0)
|
||||
{
|
||||
print '<td class="nowraponall right">';
|
||||
print price($sous_total_debit - $sous_total_credit);
|
||||
|
||||
766
htdocs/accountancy/bookkeeping/listbysubaccount.php
Normal file
766
htdocs/accountancy/bookkeeping/listbysubaccount.php
Normal 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 ' <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();
|
||||
@ -195,17 +195,17 @@ dol_syslog("/accountancy/bookkeeping/thirdparty_lettering_customer.php", LOG_DEB
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
|
||||
$param = "&socid=".$socid;
|
||||
$param = "&socid=".$socid;
|
||||
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.'">';
|
||||
|
||||
$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 '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="liste centpercent">'."\n";
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="liste centpercent">'."\n";
|
||||
|
||||
/*
|
||||
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("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("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
||||
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
||||
print "</tr>\n";
|
||||
|
||||
$solde = 0;
|
||||
$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($obj->lettering_code))*/ $solde += ($obj->credit - $obj->debit);
|
||||
|
||||
@ -265,20 +265,20 @@ if ($resql) {
|
||||
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
|
||||
|
||||
// Journal
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
||||
print '<td class="center">'.$journaltoshow.'</td>';
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
||||
print '<td class="center">'.$journaltoshow.'</td>';
|
||||
|
||||
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><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
||||
print img_edit();
|
||||
print '</a></td>'."\n";
|
||||
} else {
|
||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
||||
print '<td></td>';
|
||||
}
|
||||
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><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
||||
print img_edit();
|
||||
print '</a></td>'."\n";
|
||||
} else {
|
||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
||||
print '<td></td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
@ -299,9 +299,9 @@ if ($resql) {
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
||||
print $letteringbutton;
|
||||
print '</div>';
|
||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
||||
print $letteringbutton;
|
||||
print '</div>';
|
||||
|
||||
print "</form>";
|
||||
$db->free($resql);
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* 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
|
||||
* 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');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
$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;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
@ -193,17 +193,17 @@ if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = "&socid=".$socid;
|
||||
$param = "&socid=".$socid;
|
||||
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.'">';
|
||||
|
||||
$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 '<table class="liste centpercent">'."\n";
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="liste centpercent">'."\n";
|
||||
|
||||
/*
|
||||
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("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("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
||||
print_liste_field_titre("", "", "", '', '', "", $sortfield, $sortorder, 'maxwidthsearch center ');
|
||||
print "</tr>\n";
|
||||
|
||||
$solde = 0;
|
||||
@ -261,21 +261,21 @@ if ($resql) {
|
||||
print '<td class="nowrap right">'.price($obj->credit).'</td>';
|
||||
print '<td class="nowrap right">'.price(round($solde, 2)).'</td>';
|
||||
|
||||
// Journal
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
||||
print '<td class="center">'.$journaltoshow.'</td>';
|
||||
// Journal
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
$result = $accountingjournal->fetch('', $obj->code_journal);
|
||||
$journaltoshow = (($result > 0) ? $accountingjournal->getNomUrl(0, 0, 0, '', 0) : $obj->code_journal);
|
||||
print '<td class="center">'.$journaltoshow.'</td>';
|
||||
|
||||
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><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
||||
print img_edit();
|
||||
print '</a></td>'."\n";
|
||||
print '<td><a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$obj->piece_num.'">';
|
||||
print img_edit();
|
||||
print '</a></td>'."\n";
|
||||
} else {
|
||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
||||
print '<td></td>';
|
||||
}
|
||||
print '<td class="center">'.$obj->lettering_code.'</td>';
|
||||
print '<td></td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
@ -296,9 +296,9 @@ if ($resql) {
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
||||
print '<div class="tabsAction tabsActionNoBottom">'."\n";
|
||||
print $letteringbutton;
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print "</form>";
|
||||
$db->free($resql);
|
||||
|
||||
@ -31,10 +31,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
*/
|
||||
class AccountancyCategory // extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error string
|
||||
@ -63,9 +63,9 @@ class AccountancyCategory // extends CommonObject
|
||||
public $rowid;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
* @var int ID
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var string Accountancy code
|
||||
@ -73,11 +73,11 @@ class AccountancyCategory // extends CommonObject
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string Accountancy Category label
|
||||
*/
|
||||
public $label;
|
||||
* @var string Accountancy Category label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @var string Accountancy range account
|
||||
*/
|
||||
public $range_account;
|
||||
@ -381,8 +381,8 @@ class AccountancyCategory // extends CommonObject
|
||||
* @param int $id Id
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function display($id)
|
||||
{
|
||||
public function display($id)
|
||||
{
|
||||
global $conf;
|
||||
$sql = "SELECT t.rowid, t.account_number, t.label";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as t";
|
||||
@ -408,7 +408,7 @@ class AccountancyCategory // extends CommonObject
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function getCptBK($id)
|
||||
{
|
||||
public function getCptBK($id)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT t.numero_compte, t.label_operation, t.doc_ref";
|
||||
@ -457,7 +457,7 @@ class AccountancyCategory // extends CommonObject
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function getAccountsWithNoCategory($id)
|
||||
{
|
||||
global $conf;
|
||||
public function getAccountsWithNoCategory($id)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
|
||||
$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 .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
|
||||
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " AND aa.active = 1";
|
||||
$sql .= " AND aa.entity = ".$conf->entity;
|
||||
$sql .= " GROUP BY aa.account_number, aa.label";
|
||||
$sql .= " ORDER BY aa.account_number, aa.label";
|
||||
$sql = "SELECT aa.account_number as numero_compte, aa.label as label_compte";
|
||||
$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 .= " WHERE (aa.fk_accounting_category != ".$id." OR aa.fk_accounting_category IS NULL)";
|
||||
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " AND aa.active = 1";
|
||||
$sql .= " AND aa.entity = ".$conf->entity;
|
||||
$sql .= " GROUP 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);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$this->lines_cptbk[] = $obj;
|
||||
}
|
||||
}
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->num_rows($resql);
|
||||
if ($num) {
|
||||
while ($obj = $this->db->fetch_object($resql)) {
|
||||
$this->lines_cptbk[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
return $num;
|
||||
} else {
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
|
||||
return $num;
|
||||
} else {
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
dol_syslog(__METHOD__." ".implode(','.$this->errors), LOG_ERR);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function updateAccAcc($id_cat, $cpts = array())
|
||||
{
|
||||
public function updateAccAcc($id_cat, $cpts = array())
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
|
||||
@ -523,7 +523,7 @@ class AccountancyCategory // extends CommonObject
|
||||
$sql .= " AND asy.rowid = ".$conf->global->CHARTOFACCOUNTS;
|
||||
$sql .= " AND aa.active = 1";
|
||||
$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();
|
||||
|
||||
@ -539,13 +539,13 @@ class AccountancyCategory // extends CommonObject
|
||||
$accountincptsadded = array();
|
||||
while ($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$account_number_formated = length_accountg($obj->account_number);
|
||||
if (!empty($accountincptsadded[$account_number_formated])) continue;
|
||||
$account_number_formated = length_accountg($obj->account_number);
|
||||
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;
|
||||
// We found an account number that is in list $cpts of account to add
|
||||
$accountincptsadded[$account_number_formated] = 1;
|
||||
// We found an account number that is in list $cpts of account to add
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account";
|
||||
$sql .= " SET fk_accounting_category=".$id_cat;
|
||||
$sql .= " WHERE rowid=".$obj->rowid;
|
||||
@ -572,7 +572,7 @@ class AccountancyCategory // extends CommonObject
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function deleteCptCat($cpt_id)
|
||||
{
|
||||
public function deleteCptCat($cpt_id)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account as aa";
|
||||
@ -598,7 +598,7 @@ class AccountancyCategory // extends CommonObject
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
if ($error) {
|
||||
foreach ($this->errors as $errmsg) {
|
||||
dol_syslog(__METHOD__." ".$errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||
@ -606,12 +606,12 @@ class AccountancyCategory // extends CommonObject
|
||||
$this->db->rollback();
|
||||
|
||||
return -1 * $error;
|
||||
} else {
|
||||
} else {
|
||||
$this->db->commit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to know all category from accounting account
|
||||
@ -781,7 +781,7 @@ class AccountancyCategory // extends CommonObject
|
||||
'formula' => $obj->formula,
|
||||
'position' => $obj->position,
|
||||
'category_type' => $obj->category_type,
|
||||
'bc' => $obj->sens
|
||||
'bc' => $obj->sens
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ class AccountancyExport
|
||||
public static $EXPORT_TYPE_QUADRATUS = 60;
|
||||
public static $EXPORT_TYPE_WINFIC = 70;
|
||||
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_FEC = 1000;
|
||||
|
||||
@ -111,7 +111,7 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'),
|
||||
self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'),
|
||||
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_LDCOMPTA => $langs->trans('Modelcsv_LDCompta'),
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => $langs->trans('Modelcsv_LDCompta10'),
|
||||
@ -144,9 +144,9 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_COGILOG => 'cogilog',
|
||||
self::$EXPORT_TYPE_AGIRIS => 'agiris',
|
||||
self::$EXPORT_TYPE_OPENCONCERTO => 'openconcerto',
|
||||
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
|
||||
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
|
||||
self::$EXPORT_TYPE_SAGE50_SWISS => 'sage50ch',
|
||||
self::$EXPORT_TYPE_LDCOMPTA => 'ldcompta',
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => 'ldcompta10',
|
||||
self::$EXPORT_TYPE_FEC => 'fec',
|
||||
);
|
||||
|
||||
@ -201,22 +201,22 @@ class AccountancyExport
|
||||
self::$EXPORT_TYPE_AGIRIS => array(
|
||||
'label' => $langs->trans('Modelcsv_agiris'),
|
||||
),
|
||||
self::$EXPORT_TYPE_OPENCONCERTO => array(
|
||||
'label' => $langs->trans('Modelcsv_openconcerto'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_OPENCONCERTO => array(
|
||||
'label' => $langs->trans('Modelcsv_openconcerto'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_SAGE50_SWISS => array(
|
||||
'label' => $langs->trans('Modelcsv_Sage50_Swiss'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_LDCOMPTA => array(
|
||||
'label' => $langs->trans('Modelcsv_LDCompta'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_LDCOMPTA => array(
|
||||
'label' => $langs->trans('Modelcsv_LDCompta'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_LDCOMPTA10 => array(
|
||||
'label' => $langs->trans('Modelcsv_LDCompta10'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
'label' => $langs->trans('Modelcsv_LDCompta10'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'csv',
|
||||
),
|
||||
self::$EXPORT_TYPE_FEC => array(
|
||||
'label' => $langs->trans('Modelcsv_FEC'),
|
||||
'ACCOUNTING_EXPORT_FORMAT' => 'txt',
|
||||
@ -254,7 +254,7 @@ class AccountancyExport
|
||||
$filename = 'general_ledger-'.$this->getFormatCode($formatexportset);
|
||||
$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';
|
||||
|
||||
|
||||
@ -289,21 +289,21 @@ class AccountancyExport
|
||||
case self::$EXPORT_TYPE_AGIRIS :
|
||||
$this->exportAgiris($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_OPENCONCERTO :
|
||||
$this->exportOpenConcerto($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_OPENCONCERTO :
|
||||
$this->exportOpenConcerto($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_SAGE50_SWISS :
|
||||
$this->exportSAGE50SWISS($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_LDCOMPTA :
|
||||
$this->exportLDCompta($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_LDCOMPTA10 :
|
||||
$this->exportLDCompta10($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_FEC :
|
||||
$this->exportFEC($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_LDCOMPTA :
|
||||
$this->exportLDCompta($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_LDCOMPTA10 :
|
||||
$this->exportLDCompta10($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_FEC :
|
||||
$this->exportFEC($TData);
|
||||
break;
|
||||
case self::$EXPORT_TYPE_CHARLEMAGNE :
|
||||
$this->exportCharlemagne($TData);
|
||||
break;
|
||||
@ -386,6 +386,7 @@ class AccountancyExport
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
@ -394,7 +395,7 @@ class AccountancyExport
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
print 'E'.$separator;
|
||||
print length_accountg($line->subledger_account).$separator;
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
@ -599,7 +600,7 @@ class AccountancyExport
|
||||
$Tab['num_compte'] = str_pad(self::trunc($code_compta, 6), 6, '0');
|
||||
|
||||
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);
|
||||
} else {
|
||||
@ -659,10 +660,10 @@ class AccountancyExport
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
if (empty($line->subledger_account)) {
|
||||
print $line->numero_compte.$separator;
|
||||
} else {
|
||||
print $line->subledger_account.$separator;
|
||||
}
|
||||
print $line->numero_compte.$separator;
|
||||
} else {
|
||||
print $line->subledger_account.$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->piece_num, 15, 'right', 'UTF-8', 1).'"'.$separator;
|
||||
@ -714,36 +715,36 @@ class AccountancyExport
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export format : OpenConcerto
|
||||
*
|
||||
* @param array $objectLines data
|
||||
* @return void
|
||||
*/
|
||||
public function exportOpenConcerto($objectLines)
|
||||
{
|
||||
/**
|
||||
* Export format : OpenConcerto
|
||||
*
|
||||
* @param array $objectLines data
|
||||
* @return void
|
||||
*/
|
||||
public function exportOpenConcerto($objectLines)
|
||||
{
|
||||
|
||||
$separator = ';';
|
||||
$end_line = "\n";
|
||||
$separator = ';';
|
||||
$end_line = "\n";
|
||||
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
foreach ($objectLines as $line) {
|
||||
$date = dol_print_date($line->doc_date, '%d/%m/%Y');
|
||||
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
} else {
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
}
|
||||
print $line->doc_ref.$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
print $date.$separator;
|
||||
print $line->code_journal.$separator;
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte).$separator;
|
||||
} else {
|
||||
print length_accounta($line->subledger_account).$separator;
|
||||
}
|
||||
print $line->doc_ref.$separator;
|
||||
print $line->label_operation.$separator;
|
||||
print price($line->debit).$separator;
|
||||
print price($line->credit).$separator;
|
||||
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
print $end_line;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export format : Configurable CSV
|
||||
@ -822,25 +823,25 @@ class AccountancyExport
|
||||
print $line->piece_num.$separator;
|
||||
|
||||
// FEC:EcritureDate
|
||||
print $date_document . $separator;
|
||||
print $date_document.$separator;
|
||||
|
||||
// FEC:CompteNum
|
||||
print $line->numero_compte.$separator;
|
||||
|
||||
// FEC:CompteLib
|
||||
print dol_string_unaccent($line->label_compte) . $separator;
|
||||
print dol_string_unaccent($line->label_compte).$separator;
|
||||
|
||||
// FEC:CompAuxNum
|
||||
print $line->subledger_account.$separator;
|
||||
|
||||
// FEC:CompAuxLib
|
||||
print dol_string_unaccent($line->subledger_label) . $separator;
|
||||
print dol_string_unaccent($line->subledger_label).$separator;
|
||||
|
||||
// FEC:PieceRef
|
||||
print $line->doc_ref.$separator;
|
||||
|
||||
// FEC:PieceDate
|
||||
print dol_string_unaccent($date_creation) . $separator;
|
||||
print dol_string_unaccent($date_creation).$separator;
|
||||
|
||||
// FEC:EcritureLib
|
||||
print $line->label_operation.$separator;
|
||||
@ -858,7 +859,7 @@ class AccountancyExport
|
||||
print $line->date_lettering.$separator;
|
||||
|
||||
// FEC:ValidDate
|
||||
print $date_validation . $separator;
|
||||
print $date_validation.$separator;
|
||||
|
||||
// FEC:Montantdevise
|
||||
print $line->multicurrency_amount.$separator;
|
||||
@ -870,152 +871,152 @@ class AccountancyExport
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export format : SAGE50SWISS
|
||||
*
|
||||
* https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984
|
||||
* http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function exportSAGE50SWISS($objectLines)
|
||||
{
|
||||
// SAGE50SWISS
|
||||
$this->separator = ',';
|
||||
$this->end_line = "\r\n";
|
||||
/**
|
||||
* Export format : SAGE50SWISS
|
||||
*
|
||||
* https://onlinehelp.sageschweiz.ch/default.aspx?tabid=19984
|
||||
* http://media.topal.ch/Public/Schnittstellen/TAF/Specification/Sage50-TAF-format.pdf
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function exportSAGE50SWISS($objectLines)
|
||||
{
|
||||
// SAGE50SWISS
|
||||
$this->separator = ',';
|
||||
$this->end_line = "\r\n";
|
||||
|
||||
// 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 $this->end_line;
|
||||
$thisPieceNum = "";
|
||||
$thisPieceAccountNr = "";
|
||||
$aSize = count($objectLines);
|
||||
foreach ($objectLines as $aIndex=>$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 $this->end_line;
|
||||
$thisPieceNum = "";
|
||||
$thisPieceAccountNr = "";
|
||||
$aSize = count($objectLines);
|
||||
foreach ($objectLines as $aIndex=>$line)
|
||||
{
|
||||
$sammelBuchung = false;
|
||||
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
} elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
} elseif ($aIndex + 1 < $aSize
|
||||
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num
|
||||
&& $aIndex - 1 < $aSize
|
||||
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num
|
||||
)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
}
|
||||
$sammelBuchung = false;
|
||||
if ($aIndex - 2 >= 0 && $objectLines[$aIndex - 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
} elseif ($aIndex + 2 < $aSize && $objectLines[$aIndex + 2]->piece_num == $line->piece_num)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
} elseif ($aIndex + 1 < $aSize
|
||||
&& $objectLines[$aIndex + 1]->piece_num == $line->piece_num
|
||||
&& $aIndex - 1 < $aSize
|
||||
&& $objectLines[$aIndex - 1]->piece_num == $line->piece_num
|
||||
)
|
||||
{
|
||||
$sammelBuchung = true;
|
||||
}
|
||||
|
||||
//Blg
|
||||
print $line->piece_num.$this->separator;
|
||||
//Blg
|
||||
print $line->piece_num.$this->separator;
|
||||
|
||||
// Datum
|
||||
$date = dol_print_date($line->doc_date, '%d.%m.%Y');
|
||||
print $date.$this->separator;
|
||||
// Datum
|
||||
$date = dol_print_date($line->doc_date, '%d.%m.%Y');
|
||||
print $date.$this->separator;
|
||||
|
||||
// Kto
|
||||
print length_accountg($line->numero_compte).$this->separator;
|
||||
// S/H
|
||||
if ($line->sens == 'D')
|
||||
{
|
||||
print 'S'.$this->separator;
|
||||
} else {
|
||||
print 'H'.$this->separator;
|
||||
}
|
||||
//Grp
|
||||
print self::trunc($line->code_journal, 1).$this->separator;
|
||||
// GKto
|
||||
if (empty($line->code_tiers))
|
||||
{
|
||||
if ($line->piece_num == $thisPieceNum)
|
||||
{
|
||||
print length_accounta($thisPieceAccountNr).$this->separator;
|
||||
} else {
|
||||
print "div".$this->separator;
|
||||
}
|
||||
} else {
|
||||
print length_accounta($line->code_tiers).$this->separator;
|
||||
}
|
||||
//SId
|
||||
print $this->separator;
|
||||
//SIdx
|
||||
print "0".$this->separator;
|
||||
//KIdx
|
||||
print "0".$this->separator;
|
||||
//BTyp
|
||||
print "0".$this->separator;
|
||||
// Kto
|
||||
print length_accountg($line->numero_compte).$this->separator;
|
||||
// S/H
|
||||
if ($line->sens == 'D')
|
||||
{
|
||||
print 'S'.$this->separator;
|
||||
} else {
|
||||
print 'H'.$this->separator;
|
||||
}
|
||||
//Grp
|
||||
print self::trunc($line->code_journal, 1).$this->separator;
|
||||
// GKto
|
||||
if (empty($line->code_tiers))
|
||||
{
|
||||
if ($line->piece_num == $thisPieceNum)
|
||||
{
|
||||
print length_accounta($thisPieceAccountNr).$this->separator;
|
||||
} else {
|
||||
print "div".$this->separator;
|
||||
}
|
||||
} else {
|
||||
print length_accounta($line->code_tiers).$this->separator;
|
||||
}
|
||||
//SId
|
||||
print $this->separator;
|
||||
//SIdx
|
||||
print "0".$this->separator;
|
||||
//KIdx
|
||||
print "0".$this->separator;
|
||||
//BTyp
|
||||
print "0".$this->separator;
|
||||
|
||||
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
|
||||
if ($sammelBuchung)
|
||||
{
|
||||
print "2".$this->separator;
|
||||
} else {
|
||||
print "1".$this->separator;
|
||||
}
|
||||
// Code
|
||||
print '""'.$this->separator;
|
||||
// Netto
|
||||
if ($line->montant >= 0)
|
||||
{
|
||||
print $line->montant.$this->separator;
|
||||
} else {
|
||||
print ($line->montant * -1).$this->separator;
|
||||
}
|
||||
// Steuer
|
||||
print "0.00".$this->separator;
|
||||
// FW-Betrag
|
||||
print "0.00".$this->separator;
|
||||
// Tx1
|
||||
$line1 = self::toAnsi($line->label_compte, 29);
|
||||
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
|
||||
{
|
||||
$line1 = "";
|
||||
}
|
||||
$line2 = self::toAnsi($line->doc_ref, 29);
|
||||
if (strlen($line1) == 0)
|
||||
{
|
||||
$line1 = $line2;
|
||||
$line2 = "";
|
||||
}
|
||||
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
|
||||
{
|
||||
$line1 = $line1.' / '.$line2;
|
||||
$line2 = "";
|
||||
}
|
||||
//MTyp 1=Fibu Einzelbuchung 2=Sammebuchung
|
||||
if ($sammelBuchung)
|
||||
{
|
||||
print "2".$this->separator;
|
||||
} else {
|
||||
print "1".$this->separator;
|
||||
}
|
||||
// Code
|
||||
print '""'.$this->separator;
|
||||
// Netto
|
||||
if ($line->montant >= 0)
|
||||
{
|
||||
print $line->montant.$this->separator;
|
||||
} else {
|
||||
print ($line->montant * -1).$this->separator;
|
||||
}
|
||||
// Steuer
|
||||
print "0.00".$this->separator;
|
||||
// FW-Betrag
|
||||
print "0.00".$this->separator;
|
||||
// Tx1
|
||||
$line1 = self::toAnsi($line->label_compte, 29);
|
||||
if ($line1 == "LIQ" || $line1 == "LIQ Beleg ok" || strlen($line1) <= 3)
|
||||
{
|
||||
$line1 = "";
|
||||
}
|
||||
$line2 = self::toAnsi($line->doc_ref, 29);
|
||||
if (strlen($line1) == 0)
|
||||
{
|
||||
$line1 = $line2;
|
||||
$line2 = "";
|
||||
}
|
||||
if (strlen($line1) > 0 && strlen($line2) > 0 && (strlen($line1) + strlen($line2)) < 27)
|
||||
{
|
||||
$line1 = $line1.' / '.$line2;
|
||||
$line2 = "";
|
||||
}
|
||||
|
||||
print '"'.self::toAnsi($line1).'"'.$this->separator;
|
||||
// Tx2
|
||||
print '"'.self::toAnsi($line2).'"'.$this->separator;
|
||||
//PkKey
|
||||
print "0".$this->separator;
|
||||
//OpId
|
||||
print $this->separator;
|
||||
print '"'.self::toAnsi($line1).'"'.$this->separator;
|
||||
// Tx2
|
||||
print '"'.self::toAnsi($line2).'"'.$this->separator;
|
||||
//PkKey
|
||||
print "0".$this->separator;
|
||||
//OpId
|
||||
print $this->separator;
|
||||
|
||||
// Flag
|
||||
print "0";
|
||||
// Flag
|
||||
print "0";
|
||||
|
||||
print $this->end_line;
|
||||
print $this->end_line;
|
||||
|
||||
if ($line->piece_num !== $thisPieceNum)
|
||||
{
|
||||
$thisPieceNum = $line->piece_num;
|
||||
$thisPieceAccountNr = $line->numero_compte;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($line->piece_num !== $thisPieceNum)
|
||||
{
|
||||
$thisPieceNum = $line->piece_num;
|
||||
$thisPieceAccountNr = $line->numero_compte;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export format : LD Compta version 9
|
||||
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Export format : LD Compta version 9
|
||||
* http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW9.pdf
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function exportLDCompta($objectLines)
|
||||
{
|
||||
|
||||
@ -1168,23 +1169,23 @@ class AccountancyExport
|
||||
{
|
||||
$soc = $this->db->fetch_object($resql);
|
||||
|
||||
$address = array('', '', '');
|
||||
if (strpos($soc->address, "\n") !== false) {
|
||||
$address = explode("\n", $soc->address);
|
||||
if (is_array($address) && count($address) > 0) {
|
||||
foreach ($address as $key=>$data) {
|
||||
$address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
|
||||
$address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$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[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
|
||||
}
|
||||
$address = array('', '', '');
|
||||
if (strpos($soc->address, "\n") !== false) {
|
||||
$address = explode("\n", $soc->address);
|
||||
if (is_array($address) && count($address) > 0) {
|
||||
foreach ($address as $key=>$data) {
|
||||
$address[$key] = str_replace(array("\t", "\n", "\r"), "", $data);
|
||||
$address[$key] = dol_trunc($address[$key], 40, 'right', 'UTF-8', 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$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[2] = substr(str_replace(array("\t", "\r"), " ", $soc->address), 82, 40);
|
||||
}
|
||||
|
||||
$type_enregistrement = 'C';
|
||||
//TYPE
|
||||
//TYPE
|
||||
print $type_enregistrement.$separator;
|
||||
//NOCL
|
||||
print $soc->code_client.$separator;
|
||||
@ -1193,15 +1194,15 @@ class AccountancyExport
|
||||
//LIBI
|
||||
print $separator;
|
||||
//TITR
|
||||
print $separator;
|
||||
print $separator;
|
||||
//RSSO
|
||||
print $soc->nom.$separator;
|
||||
//CAD1
|
||||
print $address[0].$separator;
|
||||
print $address[0].$separator;
|
||||
//CAD2
|
||||
print $address[1].$separator;
|
||||
print $address[1].$separator;
|
||||
//CAD3
|
||||
print $address[2].$separator;
|
||||
print $address[2].$separator;
|
||||
//COPO
|
||||
print $soc->zip.$separator;
|
||||
//BUDI
|
||||
@ -1223,7 +1224,7 @@ class AccountancyExport
|
||||
//COMM
|
||||
print $separator;
|
||||
//SIRE
|
||||
print str_replace(" ", "", $soc->siret).$separator;
|
||||
print str_replace(" ", "", $soc->siret).$separator;
|
||||
//RIBP
|
||||
print $separator;
|
||||
//DOBQ
|
||||
@ -1486,15 +1487,15 @@ class AccountancyExport
|
||||
*
|
||||
* @param string $str Original string to encode and optionaly truncate
|
||||
* @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)
|
||||
{
|
||||
{
|
||||
$retVal = dol_string_nohtmltag($str, 1, 'Windows-1251');
|
||||
if ($retVal >= 0 && $size >= 0)
|
||||
{
|
||||
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
|
||||
}
|
||||
return $retVal;
|
||||
if ($retVal >= 0 && $size >= 0)
|
||||
{
|
||||
$retVal = mb_substr($retVal, 0, $size, 'Windows-1251');
|
||||
}
|
||||
return $retVal;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,10 +28,10 @@
|
||||
*/
|
||||
class AccountancySystem
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
/**
|
||||
* @var string Error code (or message)
|
||||
@ -44,13 +44,13 @@ class AccountancySystem
|
||||
public $rowid;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_pcg_version;
|
||||
|
||||
/**
|
||||
* @var string pcg type
|
||||
*/
|
||||
/**
|
||||
* @var string pcg type
|
||||
*/
|
||||
public $pcg_type;
|
||||
|
||||
/**
|
||||
@ -59,18 +59,18 @@ class AccountancySystem
|
||||
public $numero;
|
||||
|
||||
/**
|
||||
* @var string Accountancy System label
|
||||
*/
|
||||
public $label;
|
||||
* @var string Accountancy System label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var string account number
|
||||
*/
|
||||
/**
|
||||
* @var string account number
|
||||
*/
|
||||
public $account_number;
|
||||
|
||||
/**
|
||||
* @var string account parent
|
||||
*/
|
||||
/**
|
||||
* @var string account parent
|
||||
*/
|
||||
public $account_parent;
|
||||
|
||||
/**
|
||||
@ -78,10 +78,10 @@ class AccountancySystem
|
||||
*
|
||||
* @param DoliDB $db handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -93,42 +93,42 @@ class AccountancySystem
|
||||
*/
|
||||
public function fetch($rowid = 0, $ref = '')
|
||||
{
|
||||
global $conf;
|
||||
global $conf;
|
||||
|
||||
if ($rowid > 0 || $ref)
|
||||
{
|
||||
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
|
||||
$sql .= " WHERE";
|
||||
if ($rowid) {
|
||||
$sql .= " a.rowid = ".((int) $rowid);
|
||||
} elseif ($ref) {
|
||||
$sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
|
||||
}
|
||||
if ($rowid > 0 || $ref)
|
||||
{
|
||||
$sql = "SELECT a.rowid, a.pcg_version, a.label, a.active";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
|
||||
$sql .= " WHERE";
|
||||
if ($rowid) {
|
||||
$sql .= " a.rowid = ".((int) $rowid);
|
||||
} elseif ($ref) {
|
||||
$sql .= " a.pcg_version = '".$this->db->escape($ref)."'";
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->rowid = $obj->rowid;
|
||||
$this->pcg_version = $obj->pcg_version;
|
||||
$this->ref = $obj->pcg_version;
|
||||
$this->label = $obj->label;
|
||||
$this->active = $obj->active;
|
||||
if ($obj) {
|
||||
$this->id = $obj->rowid;
|
||||
$this->rowid = $obj->rowid;
|
||||
$this->pcg_version = $obj->pcg_version;
|
||||
$this->ref = $obj->pcg_version;
|
||||
$this->label = $obj->label;
|
||||
$this->active = $obj->active;
|
||||
|
||||
return $this->id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
$this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return $this->id;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error = "Error ".$this->db->lasterror();
|
||||
$this->errors[] = "Error ".$this->db->lasterror();
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@ -138,8 +138,8 @@ class AccountancySystem
|
||||
* @param User $user making insert
|
||||
* @return int if KO, Id of line if OK
|
||||
*/
|
||||
public function create($user)
|
||||
{
|
||||
public function create($user)
|
||||
{
|
||||
$now = dol_now();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."accounting_system";
|
||||
@ -165,6 +165,6 @@ class AccountancySystem
|
||||
dol_syslog($this->error, LOG_ERR);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,35 +74,35 @@ class AccountingAccount extends CommonObject
|
||||
public $rowid;
|
||||
|
||||
/**
|
||||
* Date creation record (datec)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datec;
|
||||
* Date creation record (datec)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datec;
|
||||
|
||||
/**
|
||||
* @var string pcg version
|
||||
*/
|
||||
* @var string pcg version
|
||||
*/
|
||||
public $fk_pcg_version;
|
||||
|
||||
/**
|
||||
* @var string pcg type
|
||||
*/
|
||||
/**
|
||||
* @var string pcg type
|
||||
*/
|
||||
public $pcg_type;
|
||||
|
||||
/**
|
||||
* @var string account number
|
||||
*/
|
||||
/**
|
||||
* @var string account number
|
||||
*/
|
||||
public $account_number;
|
||||
|
||||
/**
|
||||
* @var int ID parent account
|
||||
*/
|
||||
/**
|
||||
* @var int ID parent account
|
||||
*/
|
||||
public $account_parent;
|
||||
|
||||
/**
|
||||
* @var int ID category account
|
||||
*/
|
||||
/**
|
||||
* @var int ID category account
|
||||
*/
|
||||
public $account_category;
|
||||
|
||||
/**
|
||||
@ -110,10 +110,10 @@ class AccountingAccount extends CommonObject
|
||||
*/
|
||||
public $status;
|
||||
|
||||
/**
|
||||
* @var string Label of account
|
||||
*/
|
||||
public $label;
|
||||
/**
|
||||
* @var string Label of account
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var string Label short of account
|
||||
@ -121,19 +121,19 @@ class AccountingAccount extends CommonObject
|
||||
public $labelshort;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_user_author;
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_user_author;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_user_modif;
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_user_modif;
|
||||
|
||||
/**
|
||||
* @var int active (duplicate with status)
|
||||
*/
|
||||
public $active;
|
||||
public $active;
|
||||
|
||||
/**
|
||||
* @var int reconcilable
|
||||
@ -145,13 +145,13 @@ class AccountingAccount extends CommonObject
|
||||
*
|
||||
* @param DoliDB $db Database handle
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
public function __construct($db)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$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
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* @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;
|
||||
|
||||
@ -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).')';
|
||||
}
|
||||
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);
|
||||
@ -229,8 +229,8 @@ class AccountingAccount extends CommonObject
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
public function create($user, $notrigger = 0)
|
||||
{
|
||||
global $conf;
|
||||
$error = 0;
|
||||
$now = dol_now();
|
||||
@ -318,7 +318,7 @@ class AccountingAccount extends CommonObject
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update record
|
||||
@ -366,8 +366,8 @@ class AccountingAccount extends CommonObject
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function checkUsage()
|
||||
{
|
||||
public function checkUsage()
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$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
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
public function delete($user, $notrigger = 0)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$result = $this->checkUsage();
|
||||
@ -436,9 +436,9 @@ class AccountingAccount extends CommonObject
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @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 string $moretitle Add more text to title 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 string $option 'ledger', 'journals', 'accountcard'
|
||||
* @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;
|
||||
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 != 2) $result .= $linkstart.$label_link.$linkend;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on record
|
||||
@ -532,8 +532,8 @@ class AccountingAccount extends CommonObject
|
||||
* @param int $id of record
|
||||
* @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 .= ' FROM '.MAIN_DB_PREFIX.'accounting_account as a';
|
||||
$sql .= ' WHERE a.rowid = '.$id;
|
||||
@ -568,18 +568,18 @@ class AccountingAccount extends CommonObject
|
||||
* Deactivate an account (for status active or status reconcilable)
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function accountDeactivate($id, $mode = 0)
|
||||
{
|
||||
public function accountDeactivate($id, $mode = 0)
|
||||
{
|
||||
$result = $this->checkUsage();
|
||||
|
||||
$fieldtouse = 'active';
|
||||
if ($mode == 1)
|
||||
{
|
||||
if ($mode == 1)
|
||||
{
|
||||
$fieldtouse = 'reconcilable';
|
||||
}
|
||||
}
|
||||
|
||||
if ($result > 0) {
|
||||
$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
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
public function account_activate($id, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
public function account_activate($id, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
$this->db->begin();
|
||||
|
||||
if ($mode == 0)
|
||||
{
|
||||
$fieldtouse = 'active';
|
||||
} elseif ($mode == 1)
|
||||
{
|
||||
$fieldtouse = 'reconcilable';
|
||||
}
|
||||
if ($mode == 0)
|
||||
{
|
||||
$fieldtouse = 'active';
|
||||
} elseif ($mode == 1)
|
||||
{
|
||||
$fieldtouse = 'reconcilable';
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_account ";
|
||||
$sql .= "SET ".$fieldtouse." = '1'";
|
||||
@ -631,15 +631,15 @@ class AccountingAccount extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::account_activate ".$fieldtouse." sql=".$sql, LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -653,7 +653,7 @@ class AccountingAccount extends CommonObject
|
||||
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
|
||||
*
|
||||
@ -663,7 +663,7 @@ class AccountingAccount extends CommonObject
|
||||
*/
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
$langs->loadLangs(array("users"));
|
||||
|
||||
|
||||
@ -56,29 +56,29 @@ class AccountingJournal extends CommonObject
|
||||
*/
|
||||
public $rowid;
|
||||
|
||||
/**
|
||||
* @var string Accounting journal code
|
||||
*/
|
||||
/**
|
||||
* @var string Accounting journal code
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* @var string Accounting Journal label
|
||||
*/
|
||||
public $label;
|
||||
* @var string Accounting Journal label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
|
||||
*/
|
||||
public $nature;
|
||||
/**
|
||||
* @var int 1:various operations, 2:sale, 3:purchase, 4:bank, 5:expense-report, 8:inventory, 9: has-new
|
||||
*/
|
||||
public $nature;
|
||||
|
||||
/**
|
||||
* @var int is active or not
|
||||
*/
|
||||
/**
|
||||
* @var int is active or not
|
||||
*/
|
||||
public $active;
|
||||
|
||||
/**
|
||||
* @var array array of lines
|
||||
*/
|
||||
/**
|
||||
* @var array array of lines
|
||||
*/
|
||||
public $lines;
|
||||
|
||||
/**
|
||||
@ -86,10 +86,10 @@ class AccountingJournal extends CommonObject
|
||||
*
|
||||
* @param DoliDB $db Database handle
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an object from database
|
||||
@ -155,8 +155,8 @@ class AccountingJournal extends CommonObject
|
||||
*
|
||||
* @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 .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
|
||||
// Manage filter
|
||||
@ -284,7 +284,7 @@ class AccountingJournal extends CommonObject
|
||||
return $this->LibType($this->nature, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return type of an accounting journal
|
||||
*
|
||||
@ -294,7 +294,7 @@ class AccountingJournal extends CommonObject
|
||||
*/
|
||||
public function LibType($nature, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
$langs->loadLangs(array("accountancy"));
|
||||
|
||||
@ -768,10 +768,11 @@ class BookKeeping extends CommonObject
|
||||
* @param int $offset offset limit
|
||||
* @param array $filter filter array
|
||||
* @param string $filtermode filter mode (AND or OR)
|
||||
* @param int $option option (0: general account or 1: subaccount)
|
||||
*
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
public function 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;
|
||||
|
||||
@ -836,7 +837,13 @@ class BookKeeping extends CommonObject
|
||||
$sql .= ' AND '.implode(' '.$filtermode.' ', $sqlwhere);
|
||||
}
|
||||
// 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)) {
|
||||
$sql .= ', '.$sortfield.' '.$sortorder;
|
||||
}
|
||||
|
||||
@ -63,24 +63,24 @@ $year_current = $year_start;
|
||||
|
||||
if ($action == 'validate')
|
||||
{
|
||||
$now = dol_now();
|
||||
$now = dol_now();
|
||||
|
||||
// Update database
|
||||
$db->begin();
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
|
||||
$sql .= " SET b.date_validated = '".$db->idate($now)."'";
|
||||
$sql .= ' WHERE b.date_validated IS NULL';
|
||||
// Update database
|
||||
$db->begin();
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
|
||||
$sql .= " SET b.date_validated = '".$db->idate($now)."'";
|
||||
$sql .= ' WHERE b.date_validated IS NULL';
|
||||
|
||||
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql1) {
|
||||
$error++;
|
||||
$db->rollback();
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
} else {
|
||||
$db->commit();
|
||||
}
|
||||
// End clean database
|
||||
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql1) {
|
||||
$error++;
|
||||
$db->rollback();
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
} else {
|
||||
$db->commit();
|
||||
}
|
||||
// End clean database
|
||||
}
|
||||
|
||||
|
||||
@ -135,8 +135,8 @@ if ($resql) {
|
||||
while ($row = $db->fetch_row($resql)) {
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
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 '</td>';
|
||||
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
print '</td>';
|
||||
}
|
||||
print '<td class="valigntop"><b>'.$row[13].'</b></td>';
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
|
||||
$sql .= " SET fk_code_ventilation = ".$codeventil;
|
||||
@ -60,12 +60,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
|
||||
if (!$resql) {
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
|
||||
@ -357,12 +357,6 @@ if ($result) {
|
||||
|
||||
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>';
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
@ -285,12 +285,6 @@ if ($result) {
|
||||
|
||||
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>';
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
@ -45,14 +45,14 @@ $hookmanager->initHooks(array('accountancyindex'));
|
||||
|
||||
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';
|
||||
$zone = GETPOST('areacode', 'aZ09');
|
||||
$userid = GETPOST('userid', 'int');
|
||||
$boxorder = GETPOST('boxorder', 'aZ09');
|
||||
$boxorder .= GETPOST('boxcombo', 'aZ09');
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
|
||||
$zone = GETPOST('areacode', 'aZ09');
|
||||
$userid = GETPOST('userid', 'int');
|
||||
$boxorder = GETPOST('boxorder', 'aZ09');
|
||||
$boxorder .= GETPOST('boxcombo', 'aZ09');
|
||||
|
||||
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
|
||||
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
|
||||
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
|
||||
if ($result > 0) setEventMessages($langs->trans("BoxAdded"), null);
|
||||
}
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@ llxHeader('', $langs->trans("AccountancyArea"));
|
||||
|
||||
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 = '';
|
||||
|
||||
if (!$helpisexpanded)
|
||||
@ -92,9 +92,9 @@ if ($conf->accounting->enabled)
|
||||
|
||||
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 "<br>\n";
|
||||
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
|
||||
print '<div class="'.($helpisexpanded ? '' : 'hideobject').'" id="idfaq">'; // hideobject is to start hidden
|
||||
print "<br>\n";
|
||||
print '<span class="opacitymedium">'.$langs->trans("AccountancyAreaDescIntro")."</span><br>\n";
|
||||
print "<br>\n"; print "<br>\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))
|
||||
{
|
||||
$textlink = '<a href="'.DOL_URL_ROOT.'/admin/dict.php?id=7&from=accountancy"><strong>'.$langs->transnoentitiesnoconv("Setup").' - '.$langs->transnoentitiesnoconv("MenuTaxAccounts").'</strong></a>';
|
||||
$step++;
|
||||
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
|
||||
print "<br>\n";
|
||||
$step++;
|
||||
print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink);
|
||||
print "<br>\n";
|
||||
}
|
||||
/*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.
|
||||
{
|
||||
$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 "<br>\n";
|
||||
$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 "<br>\n";
|
||||
}
|
||||
/*
|
||||
if (! empty($conf->loan->enabled))
|
||||
@ -177,7 +177,7 @@ if ($conf->accounting->enabled)
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Step A - E
|
||||
// Step A - E
|
||||
|
||||
print "<br>\n";
|
||||
print load_fiche_titre('<span class="fa fa-calendar"></span> '.$langs->trans("AccountancyAreaDescActionFreq"), '', '');
|
||||
@ -199,7 +199,7 @@ if ($conf->accounting->enabled)
|
||||
{
|
||||
$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 "<br>\n";
|
||||
print "<br>\n";
|
||||
}
|
||||
|
||||
$step++;
|
||||
@ -214,36 +214,36 @@ if ($conf->accounting->enabled)
|
||||
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
print '<div class="fichecenter fichecenterbis">';
|
||||
print '<div class="fichecenter fichecenterbis">';
|
||||
|
||||
/*
|
||||
/*
|
||||
* 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 .= "\n";
|
||||
$boxlist .= '</div>';
|
||||
$boxlist .= "\n";
|
||||
|
||||
$boxlist .= '</div>';
|
||||
$boxlist .= '</div>';
|
||||
|
||||
|
||||
print $boxlist;
|
||||
print $boxlist;
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
} 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";
|
||||
}
|
||||
|
||||
@ -394,9 +394,9 @@ if ($result) {
|
||||
$tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
|
||||
$paymentvariousstatic->fetch($paymentvariousstatic->id);
|
||||
$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
|
||||
$tabpay[$obj->rowid]["account_various"] = $account_various;
|
||||
$tabtp[$obj->rowid][$account_subledger] += $obj->amount;
|
||||
$account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word
|
||||
$tabpay[$obj->rowid]["account_various"] = $account_various;
|
||||
$tabtp[$obj->rowid][$account_subledger] += $obj->amount;
|
||||
} elseif ($links[$key]['type'] == 'payment_loan') {
|
||||
$paymentloanstatic->id = $links[$key]['url_id'];
|
||||
$paymentloanstatic->ref = $links[$key]['url_id'];
|
||||
@ -668,7 +668,7 @@ if (!$error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
} elseif ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = $k;
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $tabpay[$key]["account_various"];
|
||||
|
||||
$accountingaccount->fetch(null, $bookkeeping->numero_compte, true);
|
||||
@ -854,7 +854,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["type_payment"].'"'.$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 '"'.$reflabel.'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
@ -882,7 +882,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$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') {
|
||||
print '"'.$conf->global->ACCOUNTING_ACCOUNT_SUPPLIER.'"'.$sep;
|
||||
} elseif ($tabtype[$key] == 'payment') {
|
||||
@ -892,7 +892,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
} elseif ($tabtype[$key] == 'payment_salary') {
|
||||
print '"'.$conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT.'"'.$sep;
|
||||
} 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 '"'.$reflabel.'"'.$sep;
|
||||
@ -915,7 +915,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"'.$date.'"'.$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_accounta($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE).'"'.$sep;
|
||||
print "".$sep;
|
||||
print '"'.$reflabel.'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
@ -954,8 +954,8 @@ if (empty($action) || $action == 'view') {
|
||||
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
|
||||
$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 .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$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);
|
||||
|
||||
$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 (($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == "") || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-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").'" />';
|
||||
|| ($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").'" />';
|
||||
} else {
|
||||
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>';
|
||||
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>';
|
||||
}
|
||||
|
||||
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] == 'member') $account_ledger = $conf->global->ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT;
|
||||
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 ($tabtype[$key] == 'unknown')
|
||||
|
||||
@ -110,11 +110,11 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
|
||||
// Already in bookkeeping or not
|
||||
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')
|
||||
{
|
||||
$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";
|
||||
|
||||
@ -370,8 +370,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -433,48 +433,48 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print "\n";
|
||||
|
||||
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->name = $tabuser[$key]['name'];
|
||||
$userstatic->id = $tabuser[$key]['id'];
|
||||
$userstatic->name = $tabuser[$key]['name'];
|
||||
|
||||
// Fees
|
||||
foreach ($tabht[$key] as $k => $mt) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
if ($mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
foreach ($tabtva[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// Fees
|
||||
foreach ($tabht[$key] as $k => $mt) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingaccount->fetch(null, $k, true);
|
||||
if ($mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($accountingaccount->label, 32).'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
// VAT
|
||||
foreach ($tabtva[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($langs->trans("VAT")).'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($userstatic->name).'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"';
|
||||
}
|
||||
print "\n";
|
||||
// Third party
|
||||
foreach ($tabttc[$key] as $k => $mt) {
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.dol_trunc($userstatic->name).'"'.$sep;
|
||||
print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
|
||||
print '"'.($mt >= 0 ? price($mt) : '').'"';
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,8 +489,8 @@ if (empty($action) || $action == 'view') {
|
||||
$description .= $langs->trans("DescJournalOnlyBindedVisible").'<br>';
|
||||
|
||||
$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 .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$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);
|
||||
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
|
||||
@ -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 '""'.$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 '"'.($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"));
|
||||
$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 = $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);
|
||||
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ if ($in_bookkeeping == 'already')
|
||||
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 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";
|
||||
//print $sql;
|
||||
@ -621,18 +621,18 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
|
||||
foreach ($arrayofvat[$key] as $k => $mt) {
|
||||
if ($mt) {
|
||||
print '"'.$key.'"'.$sep;
|
||||
print '"'.$date.'"'.$sep;
|
||||
print '"'.$val["ref"].'"'.$sep;
|
||||
print '"'.utf8_decode(dol_trunc($companystatic->name, 32)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
|
||||
print '""'.$sep;
|
||||
print '"'.$langs->trans("VAT").' - '.$def_tva[$key].' %"'.$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 '"'.$journal.'"';
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["ref"] . '"' . $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 '""' . $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 '"' . ($mt < 0 ? price(-$mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -658,8 +658,8 @@ if (empty($action) || $action == 'view') {
|
||||
}
|
||||
|
||||
$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 .= ' - '.$langs->trans("JournalizationInLedgerStatus").' '.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
|
||||
$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);
|
||||
|
||||
$varlink = 'id_journal='.$id_journal;
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
|
||||
{
|
||||
if (!$cancel)
|
||||
{
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
if ($codeventil < 0) $codeventil = 0;
|
||||
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."facture_fourn_det";
|
||||
$sql .= " SET fk_code_ventilation = ".$codeventil;
|
||||
@ -64,12 +64,12 @@ if ($action == 'ventil' && $user->rights->accounting->bind->write)
|
||||
if (!$resql) {
|
||||
setEventMessages($db->lasterror(), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
|
||||
if ($backtopage)
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
header("Location: ./lines.php");
|
||||
|
||||
@ -358,12 +358,6 @@ if ($result) {
|
||||
|
||||
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>';
|
||||
|
||||
$moreforfilter = '';
|
||||
|
||||
@ -7,7 +7,8 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* 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
|
||||
* 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();
|
||||
|
||||
|
||||
$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');
|
||||
|
||||
@ -48,29 +54,71 @@ $action = GETPOST('action', 'aZ09');
|
||||
* Actions
|
||||
*/
|
||||
|
||||
//
|
||||
if ($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();
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
if ($action == 'set_default') {
|
||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||
$res = true;
|
||||
} elseif ($action == 'del_default') {
|
||||
$ret = delDocumentModel($value, $type);
|
||||
if ($ret > 0) {
|
||||
if ($conf->global->MEMBER_ADDON_PDF_ODT == "$value") {
|
||||
dolibarr_del_const($db, 'MEMBER_ADDON_PDF_ODT', $conf->entity);
|
||||
}
|
||||
}
|
||||
$res = true;
|
||||
} elseif ($action == 'setdoc') {
|
||||
// Set default model
|
||||
if (dolibarr_set_const($db, "MEMBER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) {
|
||||
// La constante qui a ete lue en avant du nouveau set
|
||||
// on passe donc par une variable pour avoir un affichage coherent
|
||||
$conf->global->MEMBER_ADDON_PDF_ODT = $value;
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -86,7 +134,7 @@ if ($action == 'update' || $action == 'add') {
|
||||
|
||||
$consttype = GETPOST('consttype', 'alpha');
|
||||
$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++;
|
||||
|
||||
@ -99,18 +147,18 @@ if ($action == 'update' || $action == 'add') {
|
||||
|
||||
// Action to enable of a submodule of the adherent module
|
||||
if ($action == 'set') {
|
||||
$result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
|
||||
if ($result < 0) {
|
||||
print $db->error();
|
||||
}
|
||||
$result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
|
||||
if ($result < 0) {
|
||||
print $db->error();
|
||||
}
|
||||
}
|
||||
|
||||
// Action to disable a submodule of the adherent module
|
||||
if ($action == 'unset') {
|
||||
$result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
|
||||
if ($result < 0) {
|
||||
print $db->error();
|
||||
}
|
||||
$result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
|
||||
if ($result < 0) {
|
||||
print $db->error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -169,7 +217,7 @@ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty(
|
||||
print '<td>';
|
||||
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') {
|
||||
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 "</tr>\n";
|
||||
@ -245,6 +293,137 @@ $helptext .= '__COMPANY__, __ADDRESS__, __ZIP__, __TOWN__, __COUNTRY__, __EMAIL_
|
||||
$helptext .= '__YEAR__, __MONTH__, __DAY__';
|
||||
|
||||
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&token='.newToken().'&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&token='.newToken().'&value='.$name.'&scandir='.$module->scandir.'&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&token='.newToken().'&value='.$name.'&scandir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
if ($module->type == 'pdf') {
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
}
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
$htmltooltip .= '<br>'.$langs->trans("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();
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ if ($action == 'create') {
|
||||
print '<div name="topofform"></div><br>';
|
||||
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 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
|
||||
|
||||
@ -54,22 +54,22 @@ if ($action == 'update') {
|
||||
$payonline = GETPOST('MEMBER_NEWFORM_PAYONLINE');
|
||||
$forcetype = GETPOST('MEMBER_NEWFORM_FORCETYPE');
|
||||
|
||||
$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_EDITAMOUNT", $editamount, '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);
|
||||
else {
|
||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, '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_EDITAMOUNT", $editamount, '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);
|
||||
else {
|
||||
$res = dolibarr_set_const($db, "MEMBER_NEWFORM_FORCETYPE", $forcetype, 'chaine', 0, '', $conf->entity);
|
||||
}
|
||||
|
||||
if (!$res > 0) $error++;
|
||||
if (!$res > 0) $error++;
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
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');
|
||||
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
print "\n".'<script type="text/javascript" language="javascript">';
|
||||
print 'jQuery(document).ready(function () {
|
||||
function initemail()
|
||||
{
|
||||
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_NEWFORM_PAYONLINE").change(function() { initemail(); });
|
||||
})';
|
||||
print '</script>'."\n";
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -65,8 +65,8 @@ $result = $object->fetch($id);
|
||||
if ($result > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$adht = new AdherentType($db);
|
||||
$result = $adht->fetch($object->typeid);
|
||||
$adht = new AdherentType($db);
|
||||
$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 (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -136,31 +136,31 @@ if ($object->id > 0) {
|
||||
print dol_get_fiche_end();
|
||||
|
||||
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
|
||||
|
||||
$newcardbutton = '';
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
print '<br>';
|
||||
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
|
||||
print '<br>';
|
||||
|
||||
$param = '&id='.$id;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||
$param = '&id='.$id;
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
||||
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
|
||||
$filters = array();
|
||||
$filters['search_agenda_label'] = $search_agenda_label;
|
||||
// List of all actions
|
||||
$filters = array();
|
||||
$filters['search_agenda_label'] = $search_agenda_label;
|
||||
|
||||
// TODO Replace this with same code than into list.php
|
||||
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
// TODO Replace this with same code than into list.php
|
||||
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@ -27,15 +27,15 @@
|
||||
*/
|
||||
abstract class ActionsAdherentCardCommon
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
/**
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
public $dirmodule;
|
||||
public $targetmodule;
|
||||
public $canvas;
|
||||
public $card;
|
||||
public $dirmodule;
|
||||
public $targetmodule;
|
||||
public $canvas;
|
||||
public $card;
|
||||
|
||||
//! Template container
|
||||
public $tpl = array();
|
||||
@ -54,52 +54,52 @@ abstract class ActionsAdherentCardCommon
|
||||
|
||||
|
||||
/**
|
||||
* Get object
|
||||
* Get object
|
||||
*
|
||||
* @param int $id Object id
|
||||
* @return object Object loaded
|
||||
*/
|
||||
public function getObject($id)
|
||||
{
|
||||
//$ret = $this->getInstanceDao();
|
||||
* @param int $id Object id
|
||||
* @return object Object loaded
|
||||
*/
|
||||
public function getObject($id)
|
||||
{
|
||||
//$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);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
$object = new Adherent($this->db);
|
||||
if (!empty($id)) $object->fetch($id);
|
||||
$this->object = $object;
|
||||
//}
|
||||
}
|
||||
$object = new Adherent($this->db);
|
||||
if (!empty($id)) $object->fetch($id);
|
||||
$this->object = $object;
|
||||
//}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set content of ->tpl array, to use into template
|
||||
*
|
||||
* @param string $action Type of action
|
||||
* @param int $id Id
|
||||
* @return string HTML output
|
||||
*/
|
||||
public function assign_values(&$action, $id)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $user, $canvas;
|
||||
global $form, $formcompany, $objsoc;
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Set content of ->tpl array, to use into template
|
||||
*
|
||||
* @param string $action Type of action
|
||||
* @param int $id Id
|
||||
* @return string HTML output
|
||||
*/
|
||||
public function assign_values(&$action, $id)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs, $user, $canvas;
|
||||
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) {
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
foreach ($this->object as $key => $value) {
|
||||
$this->tpl[$key] = $value;
|
||||
}
|
||||
|
||||
$this->tpl['error'] = $this->error;
|
||||
$this->tpl['errors'] = $this->errors;
|
||||
$this->tpl['error'] = $this->error;
|
||||
$this->tpl['errors'] = $this->errors;
|
||||
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
if ($action == 'create' || $action == 'edit') {
|
||||
if ($conf->use_javascript_ajax) {
|
||||
$this->tpl['ajax_selectcountry'] = "\n".'<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function () {
|
||||
jQuery("#selectcountry_id").change(function() {
|
||||
@ -111,153 +111,153 @@ abstract class ActionsAdherentCardCommon
|
||||
</script>'."\n";
|
||||
}
|
||||
|
||||
if (is_object($objsoc) && $objsoc->id > 0) {
|
||||
$this->tpl['company'] = $objsoc->getNomUrl(1);
|
||||
$this->tpl['company_id'] = $objsoc->id;
|
||||
} else {
|
||||
$this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1);
|
||||
}
|
||||
if (is_object($objsoc) && $objsoc->id > 0) {
|
||||
$this->tpl['company'] = $objsoc->getNomUrl(1);
|
||||
$this->tpl['company_id'] = $objsoc->id;
|
||||
} else {
|
||||
$this->tpl['company'] = $form->select_company($this->object->socid, 'socid', '', 1);
|
||||
}
|
||||
|
||||
// Civility
|
||||
$this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
|
||||
// Civility
|
||||
$this->tpl['select_civility'] = $formcompany->select_civility($this->object->civility_id);
|
||||
|
||||
// Predefined with third party
|
||||
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->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->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->email)) == 0) $this->object->email = $objsoc->email;
|
||||
}
|
||||
// Predefined with third party
|
||||
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->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->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->email)) == 0) $this->object->email = $objsoc->email;
|
||||
}
|
||||
|
||||
// Zip
|
||||
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
|
||||
// Zip
|
||||
$this->tpl['select_zip'] = $formcompany->select_ziptown($this->object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
|
||||
|
||||
// Town
|
||||
$this->tpl['select_town'] = $formcompany->select_ziptown($this->object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
||||
// Town
|
||||
$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
|
||||
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
||||
$countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
|
||||
// Country
|
||||
$this->tpl['select_country'] = $form->select_country($this->object->country_id, 'country_id');
|
||||
$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
|
||||
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;
|
||||
// State
|
||||
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;
|
||||
|
||||
// Physical or Moral
|
||||
$selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
|
||||
$this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0);
|
||||
}
|
||||
// Physical or Moral
|
||||
$selectarray = array('0'=>$langs->trans("Physical"), '1'=>$langs->trans("Moral"));
|
||||
$this->tpl['select_morphy'] = $form->selectarray('morphy', $selectarray, $this->object->morphy, 0);
|
||||
}
|
||||
|
||||
if ($action == 'view' || $action == 'edit' || $action == 'delete') {
|
||||
// Emailing
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
if ($action == 'view' || $action == 'edit' || $action == 'delete') {
|
||||
// Emailing
|
||||
if (!empty($conf->mailing->enabled)) {
|
||||
$langs->load("mails");
|
||||
$this->tpl['nb_emailing'] = $this->object->getNbOfEMailings();
|
||||
}
|
||||
|
||||
// Dolibarr user
|
||||
if ($this->object->user_id) {
|
||||
// Dolibarr user
|
||||
if ($this->object->user_id) {
|
||||
$dolibarr_user = new User($this->db);
|
||||
$result = $dolibarr_user->fetch($this->object->user_id);
|
||||
$this->tpl['dolibarr_user'] = $dolibarr_user->getLoginUrl(1);
|
||||
} else $this->tpl['dolibarr_user'] = $langs->trans("NoDolibarrAccess");
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'view' || $action == 'delete') {
|
||||
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
|
||||
if ($action == 'view' || $action == 'delete') {
|
||||
$this->tpl['showrefnav'] = $form->showrefnav($this->object, 'id');
|
||||
|
||||
if ($this->object->socid > 0) {
|
||||
$objsoc = new Societe($this->db);
|
||||
if ($this->object->socid > 0) {
|
||||
$objsoc = new Societe($this->db);
|
||||
|
||||
$objsoc->fetch($this->object->socid);
|
||||
$this->tpl['company'] = $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$this->tpl['company'] = $langs->trans("AdherentNotLinkedToThirdParty");
|
||||
}
|
||||
$objsoc->fetch($this->object->socid);
|
||||
$this->tpl['company'] = $objsoc->getNomUrl(1);
|
||||
} else {
|
||||
$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.' ' : '');
|
||||
$this->tpl['zip'] = ($this->object->zip ? $this->object->zip.' ' : '');
|
||||
|
||||
$img = picto_from_langcode($this->object->country_code);
|
||||
$this->tpl['country'] = ($img ? $img.' ' : '').$this->object->country;
|
||||
$img = picto_from_langcode($this->object->country_code);
|
||||
$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_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['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['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') {
|
||||
// Full firstname and lastname separated with a dot : firstname.lastname
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
|
||||
if ($action == 'create_user') {
|
||||
// Full firstname and lastname separated with a dot : firstname.lastname
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||
$login = dol_buildlogin($this->object->lastname, $this->object->firstname);
|
||||
|
||||
$generated_password = getRandomPassword(false);
|
||||
$password = $generated_password;
|
||||
$generated_password = getRandomPassword(false);
|
||||
$password = $generated_password;
|
||||
|
||||
// Create a form array
|
||||
$formquestion = array(
|
||||
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
|
||||
array('label' => $langs->trans("Password"), 'type' => 'text', 'name' => 'password', 'value' => $password));
|
||||
// Create a form array
|
||||
$formquestion = array(
|
||||
array('label' => $langs->trans("LoginToCreate"), 'type' => 'text', 'name' => 'login', 'value' => $login),
|
||||
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
|
||||
/**
|
||||
* Assign POST values into object
|
||||
*
|
||||
* @return string HTML output
|
||||
*/
|
||||
private function assign_post()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $mysoc;
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Assign POST values into object
|
||||
*
|
||||
* @return string HTML output
|
||||
*/
|
||||
private function assign_post()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $mysoc;
|
||||
|
||||
$this->object->old_name = $_POST["old_name"];
|
||||
$this->object->old_firstname = $_POST["old_firstname"];
|
||||
$this->object->old_name = $_POST["old_name"];
|
||||
$this->object->old_firstname = $_POST["old_firstname"];
|
||||
|
||||
$this->object->fk_soc = $_POST["fk_soc"];
|
||||
$this->object->lastname = $_POST["lastname"];
|
||||
$this->object->firstname = $_POST["firstname"];
|
||||
$this->object->civility_id = $_POST["civility_id"];
|
||||
$this->object->address = $_POST["address"];
|
||||
$this->object->zip = $_POST["zipcode"];
|
||||
$this->object->town = $_POST["town"];
|
||||
$this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
|
||||
$this->object->state_id = $_POST["state_id"];
|
||||
$this->object->phone_perso = $_POST["phone_perso"];
|
||||
$this->object->phone_mobile = $_POST["phone_mobile"];
|
||||
$this->object->email = $_POST["email"];
|
||||
$this->object->note = $_POST["note"];
|
||||
$this->object->canvas = $_POST["canvas"];
|
||||
$this->object->fk_soc = $_POST["fk_soc"];
|
||||
$this->object->lastname = $_POST["lastname"];
|
||||
$this->object->firstname = $_POST["firstname"];
|
||||
$this->object->civility_id = $_POST["civility_id"];
|
||||
$this->object->address = $_POST["address"];
|
||||
$this->object->zip = $_POST["zipcode"];
|
||||
$this->object->town = $_POST["town"];
|
||||
$this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
|
||||
$this->object->state_id = $_POST["state_id"];
|
||||
$this->object->phone_perso = $_POST["phone_perso"];
|
||||
$this->object->phone_mobile = $_POST["phone_mobile"];
|
||||
$this->object->email = $_POST["email"];
|
||||
$this->object->note = $_POST["note"];
|
||||
$this->object->canvas = $_POST["canvas"];
|
||||
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($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);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
// We set country_id, and country_code label of the chosen country
|
||||
if ($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);
|
||||
if ($resql) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->object->country_code = $obj->code;
|
||||
$this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle;
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->object->country_code = $obj->code;
|
||||
$this->object->country = $langs->trans("Country".$obj->code) ? $langs->trans("Country".$obj->code) : $obj->libelle;
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,21 +31,21 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/canvas/actions_adherentcard_common.cl
|
||||
class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Handler acces data base
|
||||
* @param string $dirmodule Name of directory of module
|
||||
* @param string $targetmodule Name of directory of module where canvas is stored
|
||||
* @param string $canvas Name of canvas
|
||||
* @param string $card Name of tab (sub-canvas)
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Handler acces data base
|
||||
* @param string $dirmodule Name of directory of module
|
||||
* @param string $targetmodule Name of directory of module where canvas is stored
|
||||
* @param string $canvas Name of canvas
|
||||
* @param string $card Name of tab (sub-canvas)
|
||||
*/
|
||||
public function __construct($db, $dirmodule, $targetmodule, $canvas, $card)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->dirmodule = $dirmodule;
|
||||
$this->targetmodule = $targetmodule;
|
||||
$this->canvas = $canvas;
|
||||
$this->card = $card;
|
||||
$this->db = $db;
|
||||
$this->dirmodule = $dirmodule;
|
||||
$this->targetmodule = $targetmodule;
|
||||
$this->canvas = $canvas;
|
||||
$this->card = $card;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
||||
return $out;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Assign custom values for canvas
|
||||
*
|
||||
@ -77,47 +77,47 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
||||
*/
|
||||
public function assign_values(&$action, $id)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $limit, $offset, $sortfield, $sortorder;
|
||||
global $conf, $db, $langs, $user;
|
||||
global $form;
|
||||
|
||||
$ret = $this->getObject($id);
|
||||
|
||||
parent::assign_values($action, $id);
|
||||
parent::assign_values($action, $id);
|
||||
|
||||
$this->tpl['title'] = $this->getTitle($action);
|
||||
$this->tpl['error'] = $this->error;
|
||||
$this->tpl['errors'] = $this->errors;
|
||||
$this->tpl['title'] = $this->getTitle($action);
|
||||
$this->tpl['error'] = $this->error;
|
||||
$this->tpl['errors'] = $this->errors;
|
||||
|
||||
if ($action == 'view') {
|
||||
// Card header
|
||||
$head = member_prepare_head($this->object);
|
||||
$title = $this->getTitle($action);
|
||||
// Card header
|
||||
$head = member_prepare_head($this->object);
|
||||
$title = $this->getTitle($action);
|
||||
|
||||
$this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
|
||||
$this->tpl['showend'] = dol_get_fiche_end();
|
||||
$this->tpl['showhead'] = dol_get_fiche_head($head, 'card', $title, 0, 'adherent');
|
||||
$this->tpl['showend'] = dol_get_fiche_end();
|
||||
|
||||
$objsoc = new Societe($db);
|
||||
$objsoc->fetch($this->object->socid);
|
||||
$objsoc = new Societe($db);
|
||||
$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);
|
||||
} else {
|
||||
$this->tpl['actionsdone'] = show_actions_done($conf, $langs, $db, $objsoc, $this->object, 1);
|
||||
} else {
|
||||
// Confirm delete contact
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
*
|
||||
@ -129,11 +129,11 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon
|
||||
*/
|
||||
public function LoadListDatas($limit, $offset, $sortfield, $sortorder)
|
||||
{
|
||||
// phpcs:enable
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
|
||||
//$this->getFieldList();
|
||||
//$this->getFieldList();
|
||||
|
||||
$this->list_datas = array();
|
||||
$this->list_datas = array();
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,21 +118,21 @@ if (!empty($this->control->tpl['action_delete'])) echo $this->control->tpl['acti
|
||||
<?php echo $this->control->tpl['showend'];
|
||||
|
||||
if (empty($user->socid)) {
|
||||
echo '<div class="tabsAction">';
|
||||
echo '<div class="tabsAction">';
|
||||
|
||||
if ($user->rights->adherent->creer) {
|
||||
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=edit&canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
if ($user->rights->adherent->creer) {
|
||||
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=edit&canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
|
||||
if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
|
||||
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=create_user&canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||
}
|
||||
if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
|
||||
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=create_user&canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||
}
|
||||
|
||||
if ($user->rights->adherent->supprimer) {
|
||||
echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&canvas='.$canvas.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
if ($user->rights->adherent->supprimer) {
|
||||
echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&canvas='.$canvas.'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
|
||||
echo '</div><br>';
|
||||
echo '</div><br>';
|
||||
}
|
||||
|
||||
echo $this->control->tpl['actionstodo'];
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -191,6 +191,9 @@ if (empty($reshook)) {
|
||||
if ($result < 0) {
|
||||
$langs->load("errors");
|
||||
setEventMessages($langs->trans($nuser->error), null, 'errors');
|
||||
} else {
|
||||
setEventMessages($langs->trans("NewUserCreated", $nuser->login), null, 'mesgs');
|
||||
$action = '';
|
||||
}
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -218,7 +221,7 @@ if (empty($reshook)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$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'));
|
||||
}
|
||||
@ -1272,7 +1275,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
|
||||
// Confirm create user
|
||||
if ($action == 'create_user') {
|
||||
$login = $object->login;
|
||||
$login = (GETPOSTISSET('login') ? GETPOST('login', 'alphanohtml') : $object->login);
|
||||
if (empty($login)) {
|
||||
// Full firstname and name separated with a dot : firstname.name
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
@ -1561,7 +1564,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', '');
|
||||
} else {
|
||||
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 {
|
||||
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
|
||||
if (!empty($conf->mailmanspip->enabled) && !empty($conf->global->ADHERENT_USE_SPIP)) {
|
||||
$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";
|
||||
}
|
||||
}
|
||||
|
||||
// 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>';
|
||||
|
||||
@ -56,163 +56,163 @@ $extrafields->fetch_name_optionals_label($object->table_element);
|
||||
*/
|
||||
|
||||
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) {
|
||||
$arrayofmembers = array();
|
||||
$arrayofmembers = array();
|
||||
|
||||
// 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 .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
|
||||
$sql .= " t.libelle as type,";
|
||||
$sql .= " c.code as country_code, c.label as country";
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label']))
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
$sql .= " 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";
|
||||
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 .= " AND d.entity IN (".getEntity('adherent').")";
|
||||
if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid;
|
||||
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
|
||||
$sql .= " ORDER BY d.rowid ASC";
|
||||
// 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 .= " d.address, d.zip, d.town, d.country, d.birth, d.email, d.photo,";
|
||||
$sql .= " t.libelle as type,";
|
||||
$sql .= " c.code as country_code, c.label as country";
|
||||
// Add fields from extrafields
|
||||
if (!empty($extrafields->attributes[$object->table_element]['label']))
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : '');
|
||||
$sql .= " 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";
|
||||
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 .= " AND d.entity IN (".getEntity('adherent').")";
|
||||
if (is_numeric($foruserid)) $sql .= " AND d.rowid=".$foruserid;
|
||||
if ($foruserlogin) $sql .= " AND d.login='".$db->escape($foruserlogin)."'";
|
||||
$sql .= " ORDER BY d.rowid ASC";
|
||||
|
||||
dol_syslog("Search members", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
dol_syslog("Search members", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
if ($objp->country == '-') $objp->country = '';
|
||||
if ($objp->country == '-') $objp->country = '';
|
||||
|
||||
$adherentstatic->id = $objp->rowid;
|
||||
$adherentstatic->lastname = $objp->lastname;
|
||||
$adherentstatic->firstname = $objp->firstname;
|
||||
$adherentstatic->id = $objp->rowid;
|
||||
$adherentstatic->lastname = $objp->lastname;
|
||||
$adherentstatic->firstname = $objp->firstname;
|
||||
|
||||
// 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'])) {
|
||||
$adherentstatic->array_options = array();
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$tmpkey = 'options_'.$key;
|
||||
if (!empty($objp->$tmpkey)) {
|
||||
$adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
|
||||
}
|
||||
//if (!empty($objp->$key))
|
||||
// $objp->array_options[$tmpkey] = $objp->$key;
|
||||
//$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey;
|
||||
}
|
||||
}
|
||||
// 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'])) {
|
||||
$adherentstatic->array_options = array();
|
||||
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
|
||||
$tmpkey = 'options_'.$key;
|
||||
if (!empty($objp->$tmpkey)) {
|
||||
$adherentstatic->array_options[$tmpkey] = $objp->$tmpkey;
|
||||
}
|
||||
//if (!empty($objp->$key))
|
||||
// $objp->array_options[$tmpkey] = $objp->$key;
|
||||
//$objp->array_options[$tmpkey] = $extrafields->showOutputField($key, $objp->$tmpkey, '', 1); //$objp->$tmpkey;
|
||||
}
|
||||
}
|
||||
|
||||
// List of values to scan for a replacement
|
||||
$substitutionarray = array(
|
||||
'__ID__'=>$objp->rowid,
|
||||
'__LOGIN__'=>$objp->login,
|
||||
'__FIRSTNAME__'=>$objp->firstname,
|
||||
'__LASTNAME__'=>$objp->lastname,
|
||||
'__FULLNAME__'=>$adherentstatic->getFullName($langs),
|
||||
'__COMPANY__'=>$objp->company,
|
||||
'__ADDRESS__'=>$objp->address,
|
||||
'__ZIP__'=>$objp->zip,
|
||||
'__TOWN__'=>$objp->town,
|
||||
'__COUNTRY__'=>$objp->country,
|
||||
'__COUNTRY_CODE__'=>$objp->country_code,
|
||||
'__EMAIL__'=>$objp->email,
|
||||
'__BIRTH__'=>dol_print_date($objp->birth, 'day'),
|
||||
'__TYPE__'=>$objp->type,
|
||||
'__YEAR__'=>$year,
|
||||
'__MONTH__'=>$month,
|
||||
'__DAY__'=>$day,
|
||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
|
||||
// List of values to scan for a replacement
|
||||
$substitutionarray = array(
|
||||
'__ID__'=>$objp->rowid,
|
||||
'__LOGIN__'=>$objp->login,
|
||||
'__FIRSTNAME__'=>$objp->firstname,
|
||||
'__LASTNAME__'=>$objp->lastname,
|
||||
'__FULLNAME__'=>$adherentstatic->getFullName($langs),
|
||||
'__COMPANY__'=>$objp->company,
|
||||
'__ADDRESS__'=>$objp->address,
|
||||
'__ZIP__'=>$objp->zip,
|
||||
'__TOWN__'=>$objp->town,
|
||||
'__COUNTRY__'=>$objp->country,
|
||||
'__COUNTRY_CODE__'=>$objp->country_code,
|
||||
'__EMAIL__'=>$objp->email,
|
||||
'__BIRTH__'=>dol_print_date($objp->birth, 'day'),
|
||||
'__TYPE__'=>$objp->type,
|
||||
'__YEAR__'=>$year,
|
||||
'__MONTH__'=>$month,
|
||||
'__DAY__'=>$day,
|
||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
|
||||
|
||||
// For business cards
|
||||
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
|
||||
$textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
|
||||
$textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
|
||||
$textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
|
||||
$textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
|
||||
// For business cards
|
||||
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
|
||||
$textleft = make_substitutions($conf->global->ADHERENT_CARD_TEXT, $substitutionarray);
|
||||
$textheader = make_substitutions($conf->global->ADHERENT_CARD_HEADER_TEXT, $substitutionarray);
|
||||
$textfooter = make_substitutions($conf->global->ADHERENT_CARD_FOOTER_TEXT, $substitutionarray);
|
||||
$textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
|
||||
|
||||
if (is_numeric($foruserid) || $foruserlogin) {
|
||||
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
|
||||
if ($nb <= 0) $nb = 1; // Protection to avoid empty page
|
||||
if (is_numeric($foruserid) || $foruserlogin) {
|
||||
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
|
||||
if ($nb <= 0) $nb = 1; // Protection to avoid empty page
|
||||
|
||||
for ($j = 0; $j < $nb; $j++) {
|
||||
$arrayofmembers[] = array(
|
||||
'textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$arrayofmembers[] = array(
|
||||
'textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo
|
||||
);
|
||||
}
|
||||
}
|
||||
for ($j = 0; $j < $nb; $j++) {
|
||||
$arrayofmembers[] = array(
|
||||
'textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$arrayofmembers[] = array(
|
||||
'textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// For labels
|
||||
if ($mode == 'label') {
|
||||
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);
|
||||
$textheader = '';
|
||||
$textfooter = '';
|
||||
$textright = '';
|
||||
// For labels
|
||||
if ($mode == 'label') {
|
||||
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);
|
||||
$textheader = '';
|
||||
$textfooter = '';
|
||||
$textright = '';
|
||||
|
||||
$arrayofmembers[] = array('textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo);
|
||||
}
|
||||
$arrayofmembers[] = array('textleft'=>$textleft,
|
||||
'textheader'=>$textheader,
|
||||
'textfooter'=>$textfooter,
|
||||
'textright'=>$textright,
|
||||
'id'=>$objp->rowid,
|
||||
'photo'=>$objp->photo);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Build and output PDF
|
||||
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($model) || $model == '-1') {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
||||
}
|
||||
if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
|
||||
} elseif ($mode == 'label') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($modellabel) || $modellabel == '-1') {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
||||
}
|
||||
if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
|
||||
}
|
||||
// Build and output PDF
|
||||
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($model) || $model == '-1') {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
||||
}
|
||||
if (!$mesg) $result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
|
||||
} elseif ($mode == 'label') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($modellabel) || $modellabel == '-1') {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE"));
|
||||
}
|
||||
if (!$mesg) $result = doc_label_pdf_create($db, $arrayofmembers, $modellabel, $outputlangs);
|
||||
}
|
||||
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', $result);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
if ($result <= 0) {
|
||||
dol_print_error('', $result);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
if (!$mesg) {
|
||||
$db->close();
|
||||
exit;
|
||||
}
|
||||
if (!$mesg) {
|
||||
$db->close();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2014-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* 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) 2016 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
|
||||
@ -60,6 +60,9 @@ class Adherent extends CommonObject
|
||||
*/
|
||||
public $ismultientitymanaged = 1;
|
||||
|
||||
/**
|
||||
* @var string picto
|
||||
*/
|
||||
public $picto = 'member';
|
||||
|
||||
|
||||
@ -70,13 +73,19 @@ class Adherent extends CommonObject
|
||||
*/
|
||||
public $login;
|
||||
|
||||
//! Clear password in memory
|
||||
/**
|
||||
* @var string Clear password in memory
|
||||
*/
|
||||
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;
|
||||
|
||||
//! Encrypted password in database (always defined)
|
||||
/**
|
||||
* @var string Encrypted password in database (always defined)
|
||||
*/
|
||||
public $pass_indatabase_crypted;
|
||||
|
||||
/**
|
||||
@ -169,6 +178,11 @@ class Adherent extends CommonObject
|
||||
*/
|
||||
public $phone_perso;
|
||||
|
||||
/**
|
||||
* @var string Professional Phone number
|
||||
*/
|
||||
public $phone_pro;
|
||||
|
||||
/**
|
||||
* @var string Mobile phone number
|
||||
*/
|
||||
@ -184,6 +198,9 @@ class Adherent extends CommonObject
|
||||
*/
|
||||
public $poste;
|
||||
|
||||
/**
|
||||
* @var string mor or phy
|
||||
*/
|
||||
public $morphy;
|
||||
|
||||
public $public;
|
||||
@ -191,6 +208,10 @@ class Adherent extends CommonObject
|
||||
// -1:brouillon, 0:resilie, >=1:valide,paye
|
||||
// def in common object
|
||||
//public $status;
|
||||
|
||||
/**
|
||||
* @var string photo of member
|
||||
*/
|
||||
public $photo;
|
||||
|
||||
/**
|
||||
@ -209,6 +230,9 @@ class Adherent extends CommonObject
|
||||
|
||||
public $datevalid;
|
||||
|
||||
/**
|
||||
* @var string gender
|
||||
*/
|
||||
public $gender;
|
||||
|
||||
public $birth;
|
||||
@ -258,7 +282,11 @@ class Adherent extends CommonObject
|
||||
*/
|
||||
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),
|
||||
'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),
|
||||
@ -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),
|
||||
'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,
|
||||
'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),
|
||||
'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);
|
||||
|
||||
// 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 : ''),
|
||||
'__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''),
|
||||
'__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 : ''),
|
||||
'__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 : ''),
|
||||
'__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);
|
||||
|
||||
@ -589,9 +620,7 @@ class Adherent extends CommonObject
|
||||
$this->town = ($this->town ? $this->town : $this->town);
|
||||
$this->country_id = ($this->country_id > 0 ? $this->country_id : $this->country_id);
|
||||
$this->state_id = ($this->state_id > 0 ? $this->state_id : $this->state_id);
|
||||
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname = dol_ucwords(dol_strtolower($this->lastname));
|
||||
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->setUpperOrLowerCase();
|
||||
$this->note_public = ($this->note_public ? $this->note_public : $this->note_public);
|
||||
$this->note_private = ($this->note_private ? $this->note_private : $this->note_private);
|
||||
|
||||
@ -1984,7 +2013,8 @@ class Adherent extends CommonObject
|
||||
}
|
||||
|
||||
$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->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;
|
||||
@ -2276,14 +2306,16 @@ class Adherent extends CommonObject
|
||||
* Used to build previews or test instances.
|
||||
* id must be 0 if object instance is a specimen.
|
||||
*
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
global $user, $langs;
|
||||
$now = dol_now();
|
||||
|
||||
// Initialise parametres
|
||||
$this->id = 0;
|
||||
$this->entity = 1;
|
||||
$this->specimen = 1;
|
||||
$this->civility_id = 0;
|
||||
$this->lastname = 'DOLIBARR';
|
||||
@ -2300,24 +2332,30 @@ class Adherent extends CommonObject
|
||||
$this->country = 'France';
|
||||
$this->morphy = 'mor';
|
||||
$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_perso = '0999999998';
|
||||
$this->phone_mobile = '0999999997';
|
||||
$this->note_private = 'No comment';
|
||||
$this->birth = time();
|
||||
$this->note_public = 'This is a public note';
|
||||
$this->note_private = 'This is a private note';
|
||||
$this->birth = $now;
|
||||
$this->photo = '';
|
||||
$this->public = 1;
|
||||
$this->statut = 0;
|
||||
|
||||
$this->datefin = time();
|
||||
$this->datevalid = time();
|
||||
$this->datefin = $now;
|
||||
$this->datevalid = $now;
|
||||
|
||||
$this->typeid = 1; // Id type adherent
|
||||
$this->type = 'Type adherent'; // Libelle type adherent
|
||||
$this->need_subscription = 0;
|
||||
|
||||
$this->first_subscription_date = time();
|
||||
$this->first_subscription_date = $now;
|
||||
$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_amount = 10;
|
||||
@ -2326,6 +2364,7 @@ class Adherent extends CommonObject
|
||||
$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_amount = 10;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -2365,6 +2404,7 @@ class Adherent extends CommonObject
|
||||
global $conf, $langs;
|
||||
|
||||
$info = array();
|
||||
$socialnetworks = getArrayOfSocialNetworks();
|
||||
$keymodified = false;
|
||||
|
||||
// Object classes
|
||||
@ -2379,8 +2419,13 @@ class Adherent extends CommonObject
|
||||
}
|
||||
|
||||
// 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',
|
||||
'LDAP_MEMBER_FIELD_MAIL' => 'email');
|
||||
$ldapkey = array(
|
||||
'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
|
||||
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->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->skype && !empty($conf->global->LDAP_MEMBER_FIELD_SKYPE)) $info[$conf->global->LDAP_MEMBER_FIELD_SKYPE] = $this->skype;
|
||||
if ($this->twitter && !empty($conf->global->LDAP_MEMBER_FIELD_TWITTER)) $info[$conf->global->LDAP_MEMBER_FIELD_TWITTER] = $this->twitter;
|
||||
if ($this->facebook && !empty($conf->global->LDAP_MEMBER_FIELD_FACEBOOK)) $info[$conf->global->LDAP_MEMBER_FIELD_FACEBOOK] = $this->facebook;
|
||||
if ($this->linkedin && !empty($conf->global->LDAP_MEMBER_FIELD_LINKEDIN)) $info[$conf->global->LDAP_MEMBER_FIELD_LINKEDIN] = $this->linkedin;
|
||||
foreach ($socialnetworks as $key => $value) {
|
||||
if ($this->socialnetworks[$value['label']] && !empty($conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])})) {
|
||||
$info[$conf->global->{'LDAP_MEMBER_FIELD_'.strtoupper($value['label'])}] = $this->socialnetworks[$value['label']];
|
||||
}
|
||||
}
|
||||
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_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
|
||||
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_CRYPTED)) $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption)
|
||||
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_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
|
||||
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)) {
|
||||
|
||||
@ -85,7 +85,6 @@ class AdherentType extends CommonObject
|
||||
|
||||
/**
|
||||
* @var int Subsription required (0 or 1)
|
||||
* @since 5.0
|
||||
*/
|
||||
public $subscription;
|
||||
|
||||
@ -95,9 +94,15 @@ class AdherentType extends CommonObject
|
||||
/** @var integer Can vote */
|
||||
public $vote;
|
||||
|
||||
/** @var string Email sent during validation */
|
||||
/** @var string Email sent during validation of member */
|
||||
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 */
|
||||
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
|
||||
*/
|
||||
@ -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
|
||||
* @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 User $user Object user making delete
|
||||
*
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param string $langtodelete Language code to delete
|
||||
* @param User $user Object user making delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
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
|
||||
* @return int >0 if OK, < 0 if KO
|
||||
*/
|
||||
@ -574,7 +578,7 @@ class AdherentType extends CommonObject
|
||||
public function getmorphylib($morphy = '')
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -591,7 +595,15 @@ class AdherentType extends CommonObject
|
||||
global $langs;
|
||||
|
||||
$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">';
|
||||
$linkend = '</a>';
|
||||
@ -707,7 +719,7 @@ class AdherentType extends CommonObject
|
||||
*/
|
||||
public function initAsSpecimen()
|
||||
{
|
||||
global $conf, $user, $langs;
|
||||
global $user;
|
||||
|
||||
// Initialise parametres
|
||||
$this->id = 0;
|
||||
@ -735,8 +747,6 @@ class AdherentType extends CommonObject
|
||||
*/
|
||||
public function getMailOnValid()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (!empty($this->mail_valid) && trim(dol_htmlentitiesbr_decode($this->mail_valid))) {
|
||||
return $this->mail_valid;
|
||||
}
|
||||
@ -751,8 +761,6 @@ class AdherentType extends CommonObject
|
||||
*/
|
||||
public function getMailOnSubscription()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// mail_subscription not defined so never used
|
||||
if (!empty($this->mail_subscription) && trim(dol_htmlentitiesbr_decode($this->mail_subscription))) { // Property not yet defined
|
||||
return $this->mail_subscription;
|
||||
@ -768,8 +776,6 @@ class AdherentType extends CommonObject
|
||||
*/
|
||||
public function getMailOnResiliate()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// NOTE mail_resiliate not defined so never used
|
||||
if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) { // Property not yet defined
|
||||
return $this->mail_resiliate;
|
||||
|
||||
@ -32,18 +32,18 @@ include_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
*/
|
||||
class AdherentStats extends Stats
|
||||
{
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element;
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element;
|
||||
|
||||
public $memberid;
|
||||
public $socid;
|
||||
public $userid;
|
||||
public $memberid;
|
||||
public $socid;
|
||||
public $userid;
|
||||
|
||||
public $from;
|
||||
public $field;
|
||||
public $where;
|
||||
public $from;
|
||||
public $field;
|
||||
public $where;
|
||||
|
||||
|
||||
/**
|
||||
@ -51,15 +51,15 @@ class AdherentStats extends Stats
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @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)
|
||||
{
|
||||
global $user, $conf;
|
||||
|
||||
$this->db = $db;
|
||||
$this->socid = $socid;
|
||||
$this->userid = $userid;
|
||||
$this->socid = $socid;
|
||||
$this->userid = $userid;
|
||||
|
||||
$object = new Subscription($this->db);
|
||||
|
||||
@ -74,16 +74,16 @@ class AdherentStats extends Stats
|
||||
if ($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
|
||||
*
|
||||
* @param int $year Year
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array Array of nb each month
|
||||
* @param int $year Year
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array Array of nb each month
|
||||
*/
|
||||
public function getNbByMonth($year, $format = 0)
|
||||
{
|
||||
@ -95,7 +95,7 @@ class AdherentStats extends Stats
|
||||
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
return $this->_getNbByMonth($year, $sql, $format);
|
||||
}
|
||||
@ -103,7 +103,7 @@ class AdherentStats extends Stats
|
||||
/**
|
||||
* Return the number of subscriptions by year
|
||||
*
|
||||
* @return array Array of nb each year
|
||||
* @return array Array of nb each year
|
||||
*/
|
||||
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";
|
||||
$sql .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
return $this->_getNbByYear($sql);
|
||||
}
|
||||
@ -122,9 +122,9 @@ class AdherentStats extends Stats
|
||||
/**
|
||||
* Return the number of subscriptions by month for a given year
|
||||
*
|
||||
* @param int $year Year
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array Array of amount each month
|
||||
* @param int $year Year
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array Array of amount each month
|
||||
*/
|
||||
public function getAmountByMonth($year, $format = 0)
|
||||
{
|
||||
@ -136,7 +136,7 @@ class AdherentStats extends Stats
|
||||
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
return $this->_getAmountByMonth($year, $sql, $format);
|
||||
}
|
||||
@ -144,8 +144,8 @@ class AdherentStats extends Stats
|
||||
/**
|
||||
* Return average amount each month
|
||||
*
|
||||
* @param int $year Year
|
||||
* @return array Array of average each month
|
||||
* @param int $year Year
|
||||
* @return array Array of average each month
|
||||
*/
|
||||
public function getAverageByMonth($year)
|
||||
{
|
||||
@ -157,7 +157,7 @@ class AdherentStats extends Stats
|
||||
$sql .= " WHERE date_format(p.dateadh,'%Y') = ".((int) $year);
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
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";
|
||||
$sql .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY year";
|
||||
$sql .= $this->db->order('year', 'DESC');
|
||||
$sql .= $this->db->order('year', 'DESC');
|
||||
|
||||
return $this->_getAllByYear($sql);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* 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
|
||||
* 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
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'morphy',
|
||||
'typeid'
|
||||
);
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'morphy',
|
||||
'typeid'
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a member object
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a member object
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
if ($id == 0) {
|
||||
$result = $member->initAsSpecimen();
|
||||
} else {
|
||||
$result = $member->fetch($id);
|
||||
}
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id) && $id > 0) {
|
||||
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
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param int $thirdparty ID of third party
|
||||
*
|
||||
* @return array|mixed Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/{thirdparty}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdparty($thirdparty)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a member object by linked thirdparty
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param int $thirdparty ID of third party
|
||||
*
|
||||
* @return Object Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/{thirdparty}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdparty($thirdparty)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
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
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param string $email Email of third party
|
||||
*
|
||||
* @return array|mixed Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/email/{email}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdpartyEmail($email)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a member object by linked thirdparty email
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param string $email Email of third party
|
||||
*
|
||||
* @return Object Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/email/{email}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdpartyEmail($email)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$thirdparty = new Societe($this->db);
|
||||
$result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'thirdparty not found');
|
||||
}
|
||||
$thirdparty = new Societe($this->db);
|
||||
$result = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'thirdparty not found');
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty->id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty->id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
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
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param string $barcode Barcode of third party
|
||||
*
|
||||
* @return array|mixed Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/barcode/{barcode}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdpartyBarcode($barcode)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a member object by linked thirdparty barcode
|
||||
*
|
||||
* Return an array with member informations
|
||||
*
|
||||
* @param string $barcode Barcode of third party
|
||||
*
|
||||
* @return Object Data without useless information
|
||||
*
|
||||
* @url GET thirdparty/barcode/{barcode}
|
||||
*
|
||||
* @throws RestException 401
|
||||
* @throws RestException 404
|
||||
*/
|
||||
public function getByThirdpartyBarcode($barcode)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$thirdparty = new Societe($this->db);
|
||||
$result = $thirdparty->fetch('', '', '', $barcode);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'thirdparty not found');
|
||||
}
|
||||
$thirdparty = new Societe($this->db);
|
||||
$result = $thirdparty->fetch('', '', '', $barcode);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'thirdparty not found');
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty->id);
|
||||
if ( ! $result ) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch('', '', $thirdparty->id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if ( ! DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('adherent', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($member);
|
||||
}
|
||||
return $this->_cleanObjectDatas($member);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members
|
||||
*
|
||||
* Get a list of members
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $typeid ID of the type of member
|
||||
/**
|
||||
* List members
|
||||
*
|
||||
* Get a list of members
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $typeid ID of the type of member
|
||||
* @param int $category Use this param to filter list by category
|
||||
* @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))"
|
||||
* @return array Array of member objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
* @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))"
|
||||
* @return array Array of member objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $category = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
|
||||
if ($category > 0) {
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as t";
|
||||
if ($category > 0) {
|
||||
$sql .= ", ".MAIN_DB_PREFIX."categorie_member as c";
|
||||
}
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
|
||||
if (!empty($typeid)) {
|
||||
$sql .= ' AND t.fk_adherent_type='.$typeid;
|
||||
}
|
||||
// Select members of given category
|
||||
if ($category > 0) {
|
||||
}
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('adherent').')';
|
||||
if (!empty($typeid)) {
|
||||
$sql .= ' AND t.fk_adherent_type='.$typeid;
|
||||
}
|
||||
// Select members of given category
|
||||
if ($category > 0) {
|
||||
$sql .= " AND c.fk_categorie = ".$this->db->escape($category);
|
||||
$sql .= " AND c.fk_member = t.rowid ";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$member = new Adherent($this->db);
|
||||
if ($member->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($member);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No member found');
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$member = new Adherent($this->db);
|
||||
if ($member->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($member);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No member found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create member object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of member
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
/**
|
||||
* Create member object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of member
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$member->$field = $value;
|
||||
}
|
||||
if ($member->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors));
|
||||
}
|
||||
return $member->id;
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$member->$field = $value;
|
||||
}
|
||||
if ($member->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating member', array_merge(array($member->error), $member->errors));
|
||||
}
|
||||
return $member->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update member
|
||||
*
|
||||
* @param int $id ID of member to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Update member
|
||||
*
|
||||
* @param int $id ID of member to update
|
||||
* @param array $request_data Datas
|
||||
* @return Object Updated object
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
// Process the status separately because it must be updated using
|
||||
// the validate() and resiliate() methods of the class Adherent.
|
||||
if ($field == 'statut') {
|
||||
if ($value == '0') {
|
||||
$result = $member->resiliate(DolibarrApiAccess::$user);
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when resiliating member: '.$member->error);
|
||||
}
|
||||
} elseif ($value == '1') {
|
||||
$result = $member->validate(DolibarrApiAccess::$user);
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when validating member: '.$member->error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$member->$field = $value;
|
||||
}
|
||||
}
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
// Process the status separately because it must be updated using
|
||||
// the validate() and resiliate() methods of the class Adherent.
|
||||
if ($field == 'statut') {
|
||||
if ($value == '0') {
|
||||
$result = $member->resiliate(DolibarrApiAccess::$user);
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when resiliating member: '.$member->error);
|
||||
}
|
||||
} elseif ($value == '1') {
|
||||
$result = $member->validate(DolibarrApiAccess::$user);
|
||||
if ($result < 0) {
|
||||
throw new RestException(500, 'Error when validating member: '.$member->error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$member->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
if ($member->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $member->error);
|
||||
}
|
||||
}
|
||||
// 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.
|
||||
if ($member->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $member->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete member
|
||||
*
|
||||
* @param int $id member ID
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
/**
|
||||
* Delete member
|
||||
*
|
||||
* @param int $id member ID
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->supprimer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $member->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
if (!$member->delete($member->id, DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401, 'error when deleting member');
|
||||
}
|
||||
if (!$member->delete($member->id, DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401, 'error when deleting member');
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'member deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'member deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$member = array();
|
||||
foreach (Members::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$member[$field] = $data[$field];
|
||||
}
|
||||
return $member;
|
||||
}
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$member = array();
|
||||
foreach (Members::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$member[$field] = $data[$field];
|
||||
}
|
||||
return $member;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
protected function _cleanObjectDatas($object)
|
||||
{
|
||||
// phpcs:enable
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param Object $object Object to clean
|
||||
* @return Object Object with cleaned properties
|
||||
*/
|
||||
protected function _cleanObjectDatas($object)
|
||||
{
|
||||
// phpcs:enable
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
// Remove the subscriptions because they are handled as a subresource.
|
||||
unset($object->subscriptions);
|
||||
unset($object->fk_incoterms);
|
||||
unset($object->label_incoterms);
|
||||
unset($object->location_incoterms);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
// Remove the subscriptions because they are handled as a subresource.
|
||||
unset($object->subscriptions);
|
||||
unset($object->fk_incoterms);
|
||||
unset($object->label_incoterms);
|
||||
unset($object->location_incoterms);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
|
||||
unset($object->total_ht);
|
||||
unset($object->total_ttc);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
unset($object->total_ht);
|
||||
unset($object->total_ttc);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
|
||||
return $object;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* List subscriptions of a member
|
||||
*
|
||||
* Get a list of subscriptions
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @return array Array of subscription objects
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET {id}/subscriptions
|
||||
*/
|
||||
public function getSubscriptions($id)
|
||||
{
|
||||
$obj_ret = array();
|
||||
/**
|
||||
* List subscriptions of a member
|
||||
*
|
||||
* Get a list of subscriptions
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @return array Array of subscription objects
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @url GET {id}/subscriptions
|
||||
*/
|
||||
public function getSubscriptions($id)
|
||||
{
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
|
||||
$obj_ret = array();
|
||||
foreach ($member->subscriptions as $subscription) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
$obj_ret = array();
|
||||
foreach ($member->subscriptions as $subscription) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a subscription for a member
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param int $start_date Start 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 string $label Label {@from body}
|
||||
* @return int ID of subscription
|
||||
*
|
||||
* @url POST {id}/subscriptions
|
||||
*/
|
||||
public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Add a subscription for a member
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param int $start_date Start 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 string $label Label {@from body}
|
||||
* @return int ID of subscription
|
||||
*
|
||||
* @url POST {id}/subscriptions
|
||||
*/
|
||||
public function createSubscription($id, $start_date, $end_date, $amount, $label = '')
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member not found');
|
||||
}
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($id);
|
||||
if (!$result) {
|
||||
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
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
/**
|
||||
* Get categories for a member
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
|
||||
@ -27,289 +27,289 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
*/
|
||||
class MembersTypes extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'label',
|
||||
);
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'label',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a member type object
|
||||
*
|
||||
* Return an array with member type informations
|
||||
*
|
||||
* @param int $id ID of member type
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a member type object
|
||||
*
|
||||
* Return an array with member type informations
|
||||
*
|
||||
* @param int $id ID of member type
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($membertype);
|
||||
}
|
||||
return $this->_cleanObjectDatas($membertype);
|
||||
}
|
||||
|
||||
/**
|
||||
* List members types
|
||||
*
|
||||
* Get a list of members types
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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')"
|
||||
* @return array Array of member type objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
/**
|
||||
* List members types
|
||||
*
|
||||
* Get a list of members types
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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')"
|
||||
* @return array Array of member type objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('member_type').')';
|
||||
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$membertype = new AdherentType($this->db);
|
||||
if ($membertype->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($membertype);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No member type found');
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$membertype = new AdherentType($this->db);
|
||||
if ($membertype->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($membertype);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve member type list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No member type found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create member type object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of member type
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
/**
|
||||
* Create member type object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of member type
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$membertype->$field = $value;
|
||||
}
|
||||
if ($membertype->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
|
||||
}
|
||||
return $membertype->id;
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$membertype->$field = $value;
|
||||
}
|
||||
if ($membertype->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error creating member type', array_merge(array($membertype->error), $membertype->errors));
|
||||
}
|
||||
return $membertype->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update member type
|
||||
*
|
||||
* @param int $id ID of member type to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Update member type
|
||||
*
|
||||
* @param int $id ID of member type to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
// Process the status separately because it must be updated using
|
||||
// the validate() and resiliate() methods of the class AdherentType.
|
||||
$membertype->$field = $value;
|
||||
}
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
// Process the status separately because it must be updated using
|
||||
// the validate() and resiliate() methods of the class AdherentType.
|
||||
$membertype->$field = $value;
|
||||
}
|
||||
|
||||
// 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.
|
||||
if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $membertype->error);
|
||||
}
|
||||
}
|
||||
// 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.
|
||||
if ($membertype->update(DolibarrApiAccess::$user) >= 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $membertype->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete member type
|
||||
*
|
||||
* @param int $id member type ID
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
/**
|
||||
* Delete member type
|
||||
*
|
||||
* @param int $id member type ID
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->configurer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$membertype = new AdherentType($this->db);
|
||||
$result = $membertype->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'member type not found');
|
||||
}
|
||||
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
if (!DolibarrApi::_checkAccessToResource('member', $membertype->id, 'adherent_type')) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
if (!$membertype->delete()) {
|
||||
throw new RestException(401, 'error when deleting member type');
|
||||
}
|
||||
if (!$membertype->delete()) {
|
||||
throw new RestException(401, 'error when deleting member type');
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'member type deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'member type deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$membertype = array();
|
||||
foreach (MembersTypes::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$membertype[$field] = $data[$field];
|
||||
}
|
||||
return $membertype;
|
||||
}
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$membertype = array();
|
||||
foreach (MembersTypes::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$membertype[$field] = $data[$field];
|
||||
}
|
||||
return $membertype;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
protected function _cleanObjectDatas($object)
|
||||
{
|
||||
// phpcs:enable
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param Object $object Object to clean
|
||||
* @return Object Object with cleaned properties
|
||||
*/
|
||||
protected function _cleanObjectDatas($object)
|
||||
{
|
||||
// phpcs:enable
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->array_options);
|
||||
unset($object->linkedObjectsIds);
|
||||
unset($object->context);
|
||||
unset($object->canvas);
|
||||
unset($object->fk_project);
|
||||
unset($object->contact);
|
||||
unset($object->contact_id);
|
||||
unset($object->thirdparty);
|
||||
unset($object->user);
|
||||
unset($object->origin);
|
||||
unset($object->origin_id);
|
||||
unset($object->ref_ext);
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
unset($object->country_code);
|
||||
unset($object->barcode_type);
|
||||
unset($object->barcode_type_code);
|
||||
unset($object->barcode_type_label);
|
||||
unset($object->barcode_type_coder);
|
||||
unset($object->mode_reglement_id);
|
||||
unset($object->cond_reglement_id);
|
||||
unset($object->cond_reglement);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
unset($object->model_pdf);
|
||||
unset($object->fk_account);
|
||||
unset($object->note_public);
|
||||
unset($object->note_private);
|
||||
unset($object->fk_incoterms);
|
||||
unset($object->label_incoterms);
|
||||
unset($object->location_incoterms);
|
||||
unset($object->name);
|
||||
unset($object->lastname);
|
||||
unset($object->firstname);
|
||||
unset($object->civility_id);
|
||||
unset($object->total_ht);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
unset($object->total_ttc);
|
||||
unset($object->array_options);
|
||||
unset($object->linkedObjectsIds);
|
||||
unset($object->context);
|
||||
unset($object->canvas);
|
||||
unset($object->fk_project);
|
||||
unset($object->contact);
|
||||
unset($object->contact_id);
|
||||
unset($object->thirdparty);
|
||||
unset($object->user);
|
||||
unset($object->origin);
|
||||
unset($object->origin_id);
|
||||
unset($object->ref_ext);
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
unset($object->country_code);
|
||||
unset($object->barcode_type);
|
||||
unset($object->barcode_type_code);
|
||||
unset($object->barcode_type_label);
|
||||
unset($object->barcode_type_coder);
|
||||
unset($object->mode_reglement_id);
|
||||
unset($object->cond_reglement_id);
|
||||
unset($object->cond_reglement);
|
||||
unset($object->fk_delivery_address);
|
||||
unset($object->shipping_method_id);
|
||||
unset($object->model_pdf);
|
||||
unset($object->fk_account);
|
||||
unset($object->note_public);
|
||||
unset($object->note_private);
|
||||
unset($object->fk_incoterms);
|
||||
unset($object->label_incoterms);
|
||||
unset($object->location_incoterms);
|
||||
unset($object->name);
|
||||
unset($object->lastname);
|
||||
unset($object->firstname);
|
||||
unset($object->civility_id);
|
||||
unset($object->total_ht);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
unset($object->total_ttc);
|
||||
|
||||
return $object;
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,219 +27,219 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
*/
|
||||
class Subscriptions extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'fk_adherent',
|
||||
'dateh',
|
||||
'datef',
|
||||
'amount',
|
||||
);
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'fk_adherent',
|
||||
'dateh',
|
||||
'datef',
|
||||
'amount',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get properties of a subscription object
|
||||
*
|
||||
* Return an array with subscription informations
|
||||
*
|
||||
* @param int $id ID of subscription
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Get properties of a subscription object
|
||||
*
|
||||
* Return an array with subscription informations
|
||||
*
|
||||
* @param int $id ID of subscription
|
||||
* @return Object data without useless information
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
|
||||
return $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
return $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
|
||||
/**
|
||||
* List subscriptions
|
||||
*
|
||||
* Get a list of subscriptions
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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')"
|
||||
* @return array Array of subscription objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
/**
|
||||
* List subscriptions
|
||||
*
|
||||
* Get a list of subscriptions
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @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')"
|
||||
* @return array Array of subscription objects
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '')
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
$obj_ret = array();
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."subscription as t";
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
$sql = "SELECT rowid";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."subscription as t";
|
||||
$sql .= ' WHERE 1 = 1';
|
||||
// Add sql filters
|
||||
if ($sqlfilters) {
|
||||
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||
}
|
||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$sql .= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
$sql .= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($i < min($limit, $num)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$subscription = new Subscription($this->db);
|
||||
if ($subscription->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Subscription found');
|
||||
}
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$i = 0;
|
||||
$num = $this->db->num_rows($result);
|
||||
while ($i < min($limit, $num)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$subscription = new Subscription($this->db);
|
||||
if ($subscription->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($subscription);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
throw new RestException(503, 'Error when retrieve subscription list : '.$this->db->lasterror());
|
||||
}
|
||||
if (!count($obj_ret)) {
|
||||
throw new RestException(404, 'No Subscription found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create subscription object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of subscription
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
/**
|
||||
* Create subscription object
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of subscription
|
||||
*/
|
||||
public function post($request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
$subscription = new Subscription($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$subscription->$field = $value;
|
||||
}
|
||||
if ($subscription->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors));
|
||||
}
|
||||
return $subscription->id;
|
||||
}
|
||||
$subscription = new Subscription($this->db);
|
||||
foreach ($request_data as $field => $value) {
|
||||
$subscription->$field = $value;
|
||||
}
|
||||
if ($subscription->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, 'Error when creating subscription', array_merge(array($subscription->error), $subscription->errors));
|
||||
}
|
||||
return $subscription->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update subscription
|
||||
*
|
||||
* @param int $id ID of subscription to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
/**
|
||||
* Update subscription
|
||||
*
|
||||
* @param int $id ID of subscription to update
|
||||
* @param array $request_data Datas
|
||||
* @return Object
|
||||
*/
|
||||
public function put($id, $request_data = null)
|
||||
{
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
$subscription->$field = $value;
|
||||
}
|
||||
foreach ($request_data as $field => $value) {
|
||||
if ($field == 'id') continue;
|
||||
$subscription->$field = $value;
|
||||
}
|
||||
|
||||
if ($subscription->update(DolibarrApiAccess::$user) > 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $subscription->error);
|
||||
}
|
||||
}
|
||||
if ($subscription->update(DolibarrApiAccess::$user) > 0) {
|
||||
return $this->get($id);
|
||||
} else {
|
||||
throw new RestException(500, $subscription->error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete subscription
|
||||
*
|
||||
* @param int $id ID of subscription to delete
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// The right to delete a subscription comes with the right to create one.
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
/**
|
||||
* Delete subscription
|
||||
*
|
||||
* @param int $id ID of subscription to delete
|
||||
* @return array
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
// The right to delete a subscription comes with the right to create one.
|
||||
if (!DolibarrApiAccess::$user->rights->adherent->cotisation->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
$subscription = new Subscription($this->db);
|
||||
$result = $subscription->fetch($id);
|
||||
if (!$result) {
|
||||
throw new RestException(404, 'Subscription not found');
|
||||
}
|
||||
|
||||
if (!$subscription->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401, 'error when deleting subscription');
|
||||
}
|
||||
if (!$subscription->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401, 'error when deleting subscription');
|
||||
}
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'subscription deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
'message' => 'subscription deleted'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$subscription = array();
|
||||
foreach (Subscriptions::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$subscription[$field] = $data[$field];
|
||||
}
|
||||
return $subscription;
|
||||
}
|
||||
/**
|
||||
* Validate fields before creating an object
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
private function _validate($data)
|
||||
{
|
||||
$subscription = array();
|
||||
foreach (Subscriptions::$FIELDS as $field) {
|
||||
if (!isset($data[$field]))
|
||||
throw new RestException(400, "$field field missing");
|
||||
$subscription[$field] = $data[$field];
|
||||
}
|
||||
return $subscription;
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,435 +32,435 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class Subscription extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element = 'subscription';
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element = 'subscription';
|
||||
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'subscription';
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public $ismultientitymanaged = 'fk_adherent@adherent';
|
||||
/**
|
||||
* @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';
|
||||
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'payment';
|
||||
/**
|
||||
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
|
||||
*/
|
||||
public $picto = 'payment';
|
||||
|
||||
/**
|
||||
* Date creation record (datec)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datec;
|
||||
/**
|
||||
* Date creation record (datec)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datec;
|
||||
|
||||
/**
|
||||
* Date modification record (tms)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datem;
|
||||
/**
|
||||
* Date modification record (tms)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datem;
|
||||
|
||||
/**
|
||||
* Subscription start date (date subscription)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $dateh;
|
||||
/**
|
||||
* Subscription start date (date subscription)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $dateh;
|
||||
|
||||
/**
|
||||
* Subscription end date
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datef;
|
||||
/**
|
||||
* Subscription end date
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datef;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_type;
|
||||
public $fk_adherent;
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_type;
|
||||
public $fk_adherent;
|
||||
|
||||
public $amount;
|
||||
public $amount;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_bank;
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_bank;
|
||||
|
||||
public $fields = array(
|
||||
'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),
|
||||
'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),
|
||||
'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
||||
'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),
|
||||
'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),
|
||||
'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_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
|
||||
);
|
||||
public $fields = array(
|
||||
'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),
|
||||
'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),
|
||||
'dateadh' =>array('type'=>'datetime', 'label'=>'DateSubscription', 'enabled'=>1, 'visible'=>-1, 'position'=>30),
|
||||
'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),
|
||||
'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),
|
||||
'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_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>65),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function who permitted cretaion of the subscription
|
||||
*
|
||||
* @param User $user User that create
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id subscription created if OK
|
||||
*/
|
||||
public function create($user, $notrigger = false)
|
||||
{
|
||||
global $langs;
|
||||
/**
|
||||
* Function who permitted cretaion of the subscription
|
||||
*
|
||||
* @param User $user User that create
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id subscription created if OK
|
||||
*/
|
||||
public function create($user, $notrigger = false)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$error = 0;
|
||||
$error = 0;
|
||||
|
||||
$now = dol_now();
|
||||
$now = dol_now();
|
||||
|
||||
// Check parameters
|
||||
if ($this->datef <= $this->dateh) {
|
||||
$this->error = $langs->trans("ErrorBadValueForDate");
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->datec)) $this->datec = $now;
|
||||
// Check parameters
|
||||
if ($this->datef <= $this->dateh) {
|
||||
$this->error = $langs->trans("ErrorBadValueForDate");
|
||||
return -1;
|
||||
}
|
||||
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';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
|
||||
if ($this->fk_type == null) { // If type not defined, we use the type of member
|
||||
$type = $member->typeid;
|
||||
} else {
|
||||
$type = $this->fk_type;
|
||||
}
|
||||
$sql .= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',";
|
||||
$sql .= " '".$this->db->idate($this->dateh)."',";
|
||||
$sql .= " '".$this->db->idate($this->datef)."',";
|
||||
$sql .= " ".$this->amount.",";
|
||||
$sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')";
|
||||
if ($this->fk_type == null) { // If type not defined, we use the type of member
|
||||
$type = $member->typeid;
|
||||
} else {
|
||||
$type = $this->fk_type;
|
||||
}
|
||||
$sql .= " VALUES (".$this->fk_adherent.", '".$this->db->escape($type)."', '".$this->db->idate($now)."',";
|
||||
$sql .= " '".$this->db->idate($this->dateh)."',";
|
||||
$sql .= " '".$this->db->idate($this->datef)."',";
|
||||
$sql .= " ".$this->amount.",";
|
||||
$sql .= " '".$this->db->escape($this->note_public ? $this->note_public : $this->note)."')";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||
$this->fk_type = $type;
|
||||
}
|
||||
if (!$error) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
|
||||
$this->fk_type = $type;
|
||||
}
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
$this->context = array('member'=>$member);
|
||||
// Call triggers
|
||||
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
if (!$error && !$notrigger) {
|
||||
$this->context = array('member' => $member);
|
||||
// Call triggers
|
||||
$result = $this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method to load a subscription
|
||||
*
|
||||
* @param int $rowid Id subscription
|
||||
* @return int <0 if KO, =0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT rowid, fk_type, fk_adherent, datec,";
|
||||
$sql .= " tms,";
|
||||
$sql .= " dateadh as dateh,";
|
||||
$sql .= " datef,";
|
||||
$sql .= " subscription, note, fk_bank";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."subscription";
|
||||
$sql .= " WHERE rowid=".$rowid;
|
||||
/**
|
||||
* Method to load a subscription
|
||||
*
|
||||
* @param int $rowid Id subscription
|
||||
* @return int <0 if KO, =0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT rowid, fk_type, fk_adherent, datec,";
|
||||
$sql .= " tms,";
|
||||
$sql .= " dateadh as dateh,";
|
||||
$sql .= " datef,";
|
||||
$sql .= " subscription, note, fk_bank";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."subscription";
|
||||
$sql .= " WHERE rowid=".$rowid;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
if ($this->db->num_rows($resql)) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->fk_type = $obj->fk_type;
|
||||
$this->fk_adherent = $obj->fk_adherent;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->tms);
|
||||
$this->dateh = $this->db->jdate($obj->dateh);
|
||||
$this->datef = $this->db->jdate($obj->datef);
|
||||
$this->amount = $obj->subscription;
|
||||
$this->note = $obj->note;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
$this->fk_type = $obj->fk_type;
|
||||
$this->fk_adherent = $obj->fk_adherent;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->datem = $this->db->jdate($obj->tms);
|
||||
$this->dateh = $this->db->jdate($obj->dateh);
|
||||
$this->datef = $this->db->jdate($obj->datef);
|
||||
$this->amount = $obj->subscription;
|
||||
$this->note = $obj->note;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update subscription
|
||||
*
|
||||
* @param User $user User who updated
|
||||
* @param int $notrigger 0=Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update($user, $notrigger = 0)
|
||||
{
|
||||
$error = 0;
|
||||
/**
|
||||
* Update subscription
|
||||
*
|
||||
* @param User $user User who updated
|
||||
* @param int $notrigger 0=Disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update($user, $notrigger = 0)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
|
||||
$sql .= " fk_type = ".$this->fk_type.",";
|
||||
$sql .= " fk_adherent = ".$this->fk_adherent.",";
|
||||
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
|
||||
$sql .= " subscription = '".price2num($this->amount)."',";
|
||||
$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
|
||||
$sql .= " datef='".$this->db->idate($this->datef)."',";
|
||||
$sql .= " datec='".$this->db->idate($this->datec)."',";
|
||||
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET ";
|
||||
$sql .= " fk_type = ".$this->fk_type.",";
|
||||
$sql .= " fk_adherent = ".$this->fk_adherent.",";
|
||||
$sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').",";
|
||||
$sql .= " subscription = '".price2num($this->amount)."',";
|
||||
$sql .= " dateadh='".$this->db->idate($this->dateh)."',";
|
||||
$sql .= " datef='".$this->db->idate($this->datef)."',";
|
||||
$sql .= " datec='".$this->db->idate($this->datec)."',";
|
||||
$sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null');
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
$result = $member->update_end_date($user);
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
$result = $member->update_end_date($user);
|
||||
|
||||
if (!$error && !$notrigger) {
|
||||
$this->context = array('member'=>$member);
|
||||
// Call triggers
|
||||
$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
|
||||
// End call triggers
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
if (!$error && !$notrigger) {
|
||||
$this->context = array('member'=>$member);
|
||||
// Call triggers
|
||||
$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
|
||||
// End call triggers
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a subscription
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function delete($user, $notrigger = false)
|
||||
{
|
||||
$error = 0;
|
||||
/**
|
||||
* Delete a subscription
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function delete($user, $notrigger = false)
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
// It subscription is linked to a bank transaction, we get it
|
||||
if ($this->fk_bank > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$accountline = new AccountLine($this->db);
|
||||
$result = $accountline->fetch($this->fk_bank);
|
||||
}
|
||||
// It subscription is linked to a bank transaction, we get it
|
||||
if ($this->fk_bank > 0) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$accountline = new AccountLine($this->db);
|
||||
$result = $accountline->fetch($this->fk_bank);
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
$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
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
if (!$error) {
|
||||
if (!$notrigger) {
|
||||
// Call triggers
|
||||
$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
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->affected_rows($resql);
|
||||
if ($num) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
$result = $member->update_end_date($user);
|
||||
if (!$error) {
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id;
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $this->db->affected_rows($resql);
|
||||
if ($num) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
$member = new Adherent($this->db);
|
||||
$result = $member->fetch($this->fk_adherent);
|
||||
$result = $member->update_end_date($user);
|
||||
|
||||
if ($this->fk_bank > 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
|
||||
if ($result > 0) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $accountline->error;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
if ($result > 0) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $accountline->error;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
$this->error = $this->db->lasterror();
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// Commit or rollback
|
||||
if ($error) {
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
} else {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $option Page for link ('', 'nolink', ...)
|
||||
* @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
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1)
|
||||
{
|
||||
global $langs;
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $notooltip 1=Disable tooltip
|
||||
* @param string $option Page for link ('', 'nolink', ...)
|
||||
* @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
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result = '';
|
||||
$result = '';
|
||||
|
||||
$langs->load("members");
|
||||
$label = $langs->trans("ShowSubscription").': '.$this->ref;
|
||||
$langs->load("members");
|
||||
$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') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
if ($option != 'nolink') {
|
||||
// Add param to save lastsearch_values or not
|
||||
$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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
||||
}
|
||||
|
||||
$linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
|
||||
$linkend = '</a>';
|
||||
$linkstart = '<a href="'.$url.'" class="classfortooltip" title="'.dol_escape_htmltag($label, 1).'">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$picto = 'payment';
|
||||
$picto = 'payment';
|
||||
|
||||
$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 != 2) $result .= $this->ref;
|
||||
$result .= $linkend;
|
||||
$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 != 2) $result .= $this->ref;
|
||||
$result .= $linkend;
|
||||
|
||||
return $result;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return string Label
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
* @return string Label
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @return string Label
|
||||
*/
|
||||
public function LibStatut($status)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
$langs->load("members");
|
||||
return '';
|
||||
}
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Renvoi le libelle d'un statut donne
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @return string Label
|
||||
*/
|
||||
public function LibStatut($status)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
$langs->load("members");
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load information of the subscription object
|
||||
*
|
||||
* @param int $id Id subscription
|
||||
* @return void
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, c.datec,';
|
||||
$sql .= ' c.tms as datem';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
|
||||
$sql .= ' WHERE c.rowid = '.$id;
|
||||
/**
|
||||
* Load information of the subscription object
|
||||
*
|
||||
* @param int $id Id subscription
|
||||
* @return void
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, c.datec,';
|
||||
$sql .= ' c.tms as datem';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'subscription as c';
|
||||
$sql .= ' WHERE c.rowid = '.$id;
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
if ($this->db->num_rows($result)) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->datem);
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->datem);
|
||||
}
|
||||
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,8 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
||||
$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');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
@ -60,7 +61,7 @@ if (!$sortfield) $sortfield = "name";
|
||||
$form = new Form($db);
|
||||
$object = new Adherent($db);
|
||||
$membert = new AdherentType($db);
|
||||
$result = $object->fetch($id);
|
||||
$result = $object->fetch($id, $ref);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
@ -86,7 +87,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Mi
|
||||
llxHeader("", $title, $helpurl);
|
||||
|
||||
if ($id > 0) {
|
||||
$result = $membert->fetch($object->typeid);
|
||||
$result = $membert->fetch($object->typeid);
|
||||
if ($result > 0) {
|
||||
// Build file list
|
||||
$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'];
|
||||
}
|
||||
|
||||
if (!empty($conf->notification->enabled))
|
||||
if (!empty($conf->notification->enabled))
|
||||
$langs->load("mails");
|
||||
|
||||
$head = member_prepare_head($object);
|
||||
|
||||
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">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Login
|
||||
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.' </td></tr>';
|
||||
}
|
||||
// Login
|
||||
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.' </td></tr>';
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
|
||||
|
||||
// Morphy
|
||||
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%">';
|
||||
// Morphy
|
||||
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 $form->showphoto('memberphoto',$object);
|
||||
print '</td>';*/
|
||||
print '</tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||
|
||||
// Civility
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>';
|
||||
print '</tr>';
|
||||
// Civility
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>';
|
||||
print '</tr>';
|
||||
|
||||
// Number of Attached Files
|
||||
// Number of Attached Files
|
||||
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
|
||||
|
||||
//Total Size Of Attached Files
|
||||
@ -157,7 +158,7 @@ if ($id > 0) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
// Search contact/address
|
||||
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
|
||||
$listofsearchfields['search_member'] = array('text'=>'Member');
|
||||
}
|
||||
if (!empty($conf->adherent->enabled) && $user->rights->adherent->lire) {
|
||||
$listofsearchfields['search_member'] = array('text'=>'Member');
|
||||
}
|
||||
|
||||
if (count($listofsearchfields)) {
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i = 0;
|
||||
foreach ($listofsearchfields as $key => $value) {
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
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>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
if (count($listofsearchfields)) {
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
$i = 0;
|
||||
foreach ($listofsearchfields as $key => $value) {
|
||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||
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>';
|
||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -158,53 +158,53 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is usel
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||
print '<tr><td class="center" colspan="2">';
|
||||
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
||||
print '<tr><td class="center" colspan="2">';
|
||||
|
||||
$SommeA = 0;
|
||||
$SommeB = 0;
|
||||
$SommeC = 0;
|
||||
$SommeD = 0;
|
||||
$total = 0;
|
||||
$dataval = array();
|
||||
$i = 0;
|
||||
foreach ($AdherentType as $key => $adhtype) {
|
||||
$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['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0);
|
||||
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
|
||||
$SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0;
|
||||
$SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0;
|
||||
$SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0;
|
||||
$SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
|
||||
$i++;
|
||||
}
|
||||
$total = $SommeA + $SommeB + $SommeC + $SommeD;
|
||||
$dataseries = array();
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB));
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC));
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD));
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SommeA));
|
||||
$SommeA = 0;
|
||||
$SommeB = 0;
|
||||
$SommeC = 0;
|
||||
$SommeD = 0;
|
||||
$total = 0;
|
||||
$dataval = array();
|
||||
$i = 0;
|
||||
foreach ($AdherentType as $key => $adhtype) {
|
||||
$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['uptodate'][] = array($i, isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0);
|
||||
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
|
||||
$SommeA += isset($MemberToValidate[$key]) ? $MemberToValidate[$key] : 0;
|
||||
$SommeB += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0) : 0;
|
||||
$SommeC += isset($MemberUpToDate[$key]) ? $MemberUpToDate[$key] : 0;
|
||||
$SommeD += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
|
||||
$i++;
|
||||
}
|
||||
$total = $SommeA + $SommeB + $SommeC + $SommeD;
|
||||
$dataseries = array();
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersNotUpToDate"), round($SommeB));
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MenuMembersUpToDate"), round($SommeC));
|
||||
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SommeD));
|
||||
$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';
|
||||
$dolgraph = new DolGraph();
|
||||
$dolgraph->SetData($dataseries);
|
||||
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0));
|
||||
$dolgraph->setShowLegend(2);
|
||||
$dolgraph->setShowPercent(1);
|
||||
$dolgraph->SetType(array('pie'));
|
||||
$dolgraph->setHeight('200');
|
||||
$dolgraph->draw('idgraphstatus');
|
||||
print $dolgraph->show($total ? 0 : 1);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
$dolgraph = new DolGraph();
|
||||
$dolgraph->SetData($dataseries);
|
||||
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0));
|
||||
$dolgraph->setShowLegend(2);
|
||||
$dolgraph->setShowPercent(1);
|
||||
$dolgraph->SetType(array('pie'));
|
||||
$dolgraph->setHeight('200');
|
||||
$dolgraph->draw('idgraphstatus');
|
||||
print $dolgraph->show($total ? 0 : 1);
|
||||
|
||||
print '</td></tr>';
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
|
||||
print $SommeA + $SommeB + $SommeC + $SommeD;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</td></tr>';
|
||||
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
|
||||
print $SommeA + $SommeB + $SommeC + $SommeD;
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
@ -223,17 +223,17 @@ $sql .= " AND d.rowid = c.fk_adherent";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$year = dol_print_date($db->jdate($objp->dateh), "%Y");
|
||||
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
|
||||
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
|
||||
$tot += $objp->subscription;
|
||||
$numb += 1;
|
||||
$i++;
|
||||
}
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$year = dol_print_date($db->jdate($objp->dateh), "%Y");
|
||||
$Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
|
||||
$Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
|
||||
$tot += $objp->subscription;
|
||||
$numb += 1;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
@ -258,12 +258,12 @@ foreach ($Total as $key=>$value) {
|
||||
break;
|
||||
}
|
||||
print '<tr class="oddeven">';
|
||||
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
|
||||
print "<td class=\"right\">".$Number[$key]."</td>";
|
||||
print "<td class=\"right\">".price($value)."</td>";
|
||||
print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
|
||||
print "<td class=\"right\">".$Number[$key]."</td>";
|
||||
print "<td class=\"right\">".price($value)."</td>";
|
||||
print "<td class=\"right\">".price(price2num($value / $Number[$key], 'MT'))."</td>";
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Total
|
||||
@ -284,10 +284,10 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
*/
|
||||
$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.tms as datem, datefin as date_end_subscription,";
|
||||
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
|
||||
$sql .= " a.tms as datem, a.datefin as date_end_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 .= " WHERE a.entity IN (".getEntity('adherent').")";
|
||||
$sql .= " AND a.fk_adherent_type = ta.rowid";
|
||||
@ -306,7 +306,7 @@ if ($resql) {
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
$staticmember->id = $obj->rowid;
|
||||
$staticmember->ref = $obj->rowid;
|
||||
$staticmember->lastname = $obj->lastname;
|
||||
@ -315,6 +315,9 @@ if ($resql) {
|
||||
$staticmember->email = $obj->email;
|
||||
$staticmember->photo = $obj->photo;
|
||||
$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)) {
|
||||
$staticmember->fk_soc = $obj->fk_soc;
|
||||
$staticmember->fetch_thirdparty();
|
||||
@ -322,12 +325,16 @@ if ($resql) {
|
||||
} else {
|
||||
$staticmember->name = $obj->company;
|
||||
}
|
||||
|
||||
$statictype->id = $obj->typeid;
|
||||
$statictype->label = $obj->label;
|
||||
$statictype->subscription = $obj->need_subscription;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32).'</td>';
|
||||
print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
|
||||
print '<td 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>';
|
||||
$i++;
|
||||
}
|
||||
@ -344,12 +351,14 @@ if ($resql) {
|
||||
*/
|
||||
$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.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 .= " 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 .= " AND a.fk_adherent_type = ta.rowid";
|
||||
$sql .= " AND c.fk_adherent = a.rowid";
|
||||
$sql .= $db->order("c.tms", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
@ -366,9 +375,7 @@ if ($resql) {
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven">';
|
||||
$subscriptionstatic->id = $obj->cid;
|
||||
$subscriptionstatic->ref = $obj->cid;
|
||||
|
||||
$staticmember->id = $obj->rowid;
|
||||
$staticmember->ref = $obj->rowid;
|
||||
$staticmember->lastname = $obj->lastname;
|
||||
@ -377,6 +384,9 @@ if ($resql) {
|
||||
$staticmember->email = $obj->email;
|
||||
$staticmember->photo = $obj->photo;
|
||||
$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)) {
|
||||
$staticmember->fk_soc = $obj->fk_soc;
|
||||
$staticmember->fetch_thirdparty();
|
||||
@ -384,6 +394,11 @@ if ($resql) {
|
||||
} else {
|
||||
$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">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>';
|
||||
print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';
|
||||
|
||||
@ -38,7 +38,7 @@ $action = GETPOST('action', 'aZ09');
|
||||
// Protection
|
||||
$socid = 0;
|
||||
if ($user->socid > 0) {
|
||||
$socid = $user->socid;
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
||||
$object = new Adherent($db);
|
||||
@ -165,24 +165,24 @@ if ($result > 0) {
|
||||
$search = "(".$object->_load_ldap_dn($info, 2).")";
|
||||
|
||||
if (empty($dn)) {
|
||||
$langs->load("errors");
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
|
||||
$langs->load("errors");
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Member")).'</font></td></tr>';
|
||||
} else {
|
||||
$records = $ldap->getAttribute($dn, $search);
|
||||
$records = $ldap->getAttribute($dn, $search);
|
||||
|
||||
//print_r($records);
|
||||
//print_r($records);
|
||||
|
||||
// Show tree
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
|
||||
if (!is_array($records)) {
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||
} else {
|
||||
$result = show_ldap_content($records, 0, $records['count'], true);
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
||||
}
|
||||
}
|
||||
// Show tree
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
|
||||
if (!is_array($records)) {
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||
} else {
|
||||
$result = show_ldap_content($records, 0, $records['count'], true);
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
$ldap->unbind();
|
||||
$ldap->close();
|
||||
|
||||
@ -204,30 +204,30 @@ if (empty($reshook)) {
|
||||
|
||||
// Close
|
||||
if ($massaction == 'close' && $user->rights->adherent->creer) {
|
||||
$tmpmember = new Adherent($db);
|
||||
$error = 0;
|
||||
$nbclose = 0;
|
||||
$tmpmember = new Adherent($db);
|
||||
$error = 0;
|
||||
$nbclose = 0;
|
||||
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
foreach ($toselect as $idtoclose) {
|
||||
$tmpmember->fetch($idtoclose);
|
||||
$result = $tmpmember->resiliate($user);
|
||||
foreach ($toselect as $idtoclose) {
|
||||
$tmpmember->fetch($idtoclose);
|
||||
$result = $tmpmember->resiliate($user);
|
||||
|
||||
if ($result < 0 && !count($tmpmember->errors)) {
|
||||
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
|
||||
} else {
|
||||
if ($result > 0) $nbclose++;
|
||||
}
|
||||
}
|
||||
if ($result < 0 && !count($tmpmember->errors)) {
|
||||
setEventMessages($tmpmember->error, $tmpmember->errors, 'errors');
|
||||
} else {
|
||||
if ($result > 0) $nbclose++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("XMembersClosed", $nbclose), null, 'mesgs');
|
||||
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Mass actions
|
||||
@ -409,7 +409,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
$newcardbutton = '';
|
||||
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"].'">';
|
||||
@ -560,7 +560,7 @@ if (!empty($arrayfields['d.email']['checked'])) {
|
||||
// End of subscription date
|
||||
if (!empty($arrayfields['d.datefin']['checked'])) {
|
||||
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 '</td>';
|
||||
}
|
||||
|
||||
@ -40,8 +40,8 @@ $result = restrictedArea($user, 'adherent', $id);
|
||||
$object = new Adherent($db);
|
||||
$result = $object->fetch($id);
|
||||
if ($result > 0) {
|
||||
$adht = new AdherentType($db);
|
||||
$result = $adht->fetch($object->typeid);
|
||||
$adht = new AdherentType($db);
|
||||
$result = $adht->fetch($object->typeid);
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
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">';
|
||||
|
||||
// Login
|
||||
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.' </td></tr>';
|
||||
}
|
||||
// Login
|
||||
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.' </td></tr>';
|
||||
}
|
||||
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
|
||||
// Type
|
||||
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$adht->getNomUrl(1)."</td></tr>\n";
|
||||
|
||||
// Morphy
|
||||
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%">';
|
||||
// Morphy
|
||||
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 $form->showphoto('memberphoto',$member);
|
||||
print '</td>';*/
|
||||
print '</tr>';
|
||||
print '</tr>';
|
||||
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$object->company.'</td></tr>';
|
||||
|
||||
// Civility
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>';
|
||||
print '</tr>';
|
||||
// Civility
|
||||
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().' </td>';
|
||||
print '</tr>';
|
||||
|
||||
print "</table>";
|
||||
print "</table>";
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
$cssclass = 'titlefield';
|
||||
$permission = $user->rights->adherent->creer; // Used by the include of notes.tpl.php
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
|
||||
$cssclass = 'titlefield';
|
||||
$permission = $user->rights->adherent->creer; // Used by the include of 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
|
||||
|
||||
@ -34,8 +34,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : '';
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
|
||||
|
||||
@ -69,7 +69,7 @@ $sql .= " d.morphy as code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$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"; // Not draft
|
||||
$sql .= " AND d.statut != -1"; // Not draft
|
||||
$sql .= " GROUP BY d.morphy";
|
||||
$foundphy = $foundmor = 0;
|
||||
|
||||
@ -100,7 +100,7 @@ $sql .= " d.morphy as code";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
|
||||
$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"; // Active (not draft=-1, not resiliated=0)
|
||||
$sql .= " AND d.statut >= 1"; // Active (not draft=-1, not resiliated=0)
|
||||
$sql .= " GROUP BY d.morphy";
|
||||
$foundphy = $foundmor = 0;
|
||||
|
||||
|
||||
@ -35,8 +35,8 @@ $mode = GETPOST('mode') ?GETPOST('mode') : '';
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
|
||||
|
||||
@ -68,129 +68,129 @@ print load_fiche_titre($title, '', 'object_group');
|
||||
dol_mkdir($dir);
|
||||
|
||||
if ($mode) {
|
||||
// Define sql
|
||||
if ($mode == 'memberbycountry') {
|
||||
$label = $langs->trans("Country");
|
||||
$tab = 'statscountry';
|
||||
// Define sql
|
||||
if ($mode == 'memberbycountry') {
|
||||
$label = $langs->trans("Country");
|
||||
$tab = 'statscountry';
|
||||
|
||||
$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 .= " 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."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";
|
||||
//print $sql;
|
||||
}
|
||||
$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 .= " 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."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";
|
||||
//print $sql;
|
||||
}
|
||||
|
||||
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");
|
||||
$label2 = $langs->trans("Region"); //département
|
||||
$tab = 'statsregion'; //onglet
|
||||
$label2 = $langs->trans("State");
|
||||
$tab = 'statsstate';
|
||||
|
||||
$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, co.code, co.label, r.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, r.nom"; //+
|
||||
//print $sql;
|
||||
}
|
||||
if ($mode == 'memberbytown') {
|
||||
$label = $langs->trans("Country");
|
||||
$label2 = $langs->trans("Town");
|
||||
$tab = 'statstown';
|
||||
$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");
|
||||
$label2 = $langs->trans("Region"); //département
|
||||
$tab = 'statsregion'; //onglet
|
||||
|
||||
$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, d.town as label2";
|
||||
$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."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;
|
||||
}
|
||||
$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, co.code, co.label, r.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, r.nom"; //+
|
||||
//print $sql;
|
||||
}
|
||||
if ($mode == 'memberbytown') {
|
||||
$label = $langs->trans("Country");
|
||||
$label2 = $langs->trans("Town");
|
||||
$tab = 'statstown';
|
||||
|
||||
$langsen = new Translate('', $conf);
|
||||
$langsen->setDefaultLang('en_US');
|
||||
$langsen->load("dict");
|
||||
//print $langsen->trans("Country"."FI");exit;
|
||||
$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, d.town as label2";
|
||||
$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."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
|
||||
dol_syslog("Count member", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($mode == 'memberbycountry') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
$langsen = new Translate('', $conf);
|
||||
$langsen->setDefaultLang('en_US');
|
||||
$langsen->load("dict");
|
||||
//print $langsen->trans("Country"."FI");exit;
|
||||
|
||||
// Define $data array
|
||||
dol_syslog("Count member", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if ($mode == 'memberbycountry') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'code'=>$obj->code,
|
||||
'nb'=>$obj->nb,
|
||||
'lastdate'=>$db->jdate($obj->lastdate),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbyregion') { //+
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbyregion') { //+
|
||||
$data[] = array(
|
||||
'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'nb'=>$obj->nb,
|
||||
'lastdate'=>$db->jdate($obj->lastdate),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbystate') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbystate') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'nb'=>$obj->nb,
|
||||
'lastdate'=>$db->jdate($obj->lastdate),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbytown') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'nb'=>$obj->nb,
|
||||
'lastdate'=>$db->jdate($obj->lastdate),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
if ($mode == 'memberbytown') {
|
||||
$data[] = array('label'=>(($obj->code && $langs->trans("Country".$obj->code) != "Country".$obj->code) ? $langs->trans("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code) != "Country".$obj->code) ? $langsen->transnoentitiesnoconv("Country".$obj->code) : ($obj->label ? $obj->label : $langs->trans("Unknown"))),
|
||||
'label2'=>($obj->label2 ? $obj->label2 : $langs->trans("Unknown")),
|
||||
'nb'=>$obj->nb,
|
||||
'lastdate'=>$db->jdate($obj->lastdate),
|
||||
'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)
|
||||
);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -201,101 +201,101 @@ print dol_get_fiche_head($head, $tab, $langs->trans("Statistics"), -1, 'user');
|
||||
|
||||
// Print title
|
||||
if ($mode && !count($data)) {
|
||||
print $langs->trans("NoValidatedMemberYet").'<br>';
|
||||
print '<br>';
|
||||
print $langs->trans("NoValidatedMemberYet").'<br>';
|
||||
print '<br>';
|
||||
} else {
|
||||
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 == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
|
||||
elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
|
||||
else {
|
||||
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
|
||||
print '<br>'; //+
|
||||
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 == 'memberbytown') print '<span class="opacitymedium">'.$langs->trans("MembersByTownDesc").'</span><br>';
|
||||
elseif ($mode == 'memberbyregion') print '<span class="opacitymedium">'.$langs->trans("MembersByRegion").'</span><br>'; //+
|
||||
else {
|
||||
print '<span class="opacitymedium">'.$langs->trans("MembersStatisticsDesc").'</span><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbycountry">'.$langs->trans("MembersStatisticsByCountries").'</a><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbystate">'.$langs->trans("MembersStatisticsByState").'</a><br>';
|
||||
print '<br>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbytown">'.$langs->trans("MembersStatisticsByTown").'</a><br>';
|
||||
print '<br>'; //+
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=memberbyregion">'.$langs->trans("MembersStatisticsByRegion").'</a><br>'; //+
|
||||
}
|
||||
print '<br>';
|
||||
}
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
|
||||
// Show graphics
|
||||
if (count($arrayjs) && $mode == 'memberbycountry') {
|
||||
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||
if (is_readable($color_file)) include_once $color_file;
|
||||
$color_file = DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
||||
if (is_readable($color_file)) include_once $color_file;
|
||||
|
||||
// Assume we've already included the proper headers so just call our script inline
|
||||
// More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
|
||||
print "\n<script type='text/javascript'>\n";
|
||||
print "google.load('visualization', '1', {'packages': ['geomap']});\n";
|
||||
print "google.setOnLoadCallback(drawMap);\n";
|
||||
print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
|
||||
// Assume we've already included the proper headers so just call our script inline
|
||||
// More doc: https://developers.google.com/chart/interactive/docs/gallery/geomap?hl=fr-FR
|
||||
print "\n<script type='text/javascript'>\n";
|
||||
print "google.load('visualization', '1', {'packages': ['geomap']});\n";
|
||||
print "google.setOnLoadCallback(drawMap);\n";
|
||||
print "function drawMap() {\n\tvar data = new google.visualization.DataTable();\n";
|
||||
|
||||
// Get the total number of rows
|
||||
print "\tdata.addRows(".count($data).");\n";
|
||||
print "\tdata.addColumn('string', 'Country');\n";
|
||||
print "\tdata.addColumn('number', 'Number');\n";
|
||||
// Get the total number of rows
|
||||
print "\tdata.addRows(".count($data).");\n";
|
||||
print "\tdata.addColumn('string', 'Country');\n";
|
||||
print "\tdata.addColumn('number', 'Number');\n";
|
||||
|
||||
// loop and dump
|
||||
$i = 0;
|
||||
foreach ($data as $val) {
|
||||
$valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
|
||||
//$valcountry=ucfirst($val['label_en']);
|
||||
if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels)
|
||||
print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
|
||||
print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
|
||||
// Google's Geomap only supports up to 400 entries
|
||||
if ($i >= 400) { break; }
|
||||
$i++;
|
||||
}
|
||||
// loop and dump
|
||||
$i = 0;
|
||||
foreach ($data as $val) {
|
||||
$valcountry = strtoupper($val['code']); // Should be ISO-3166 code (faster)
|
||||
//$valcountry=ucfirst($val['label_en']);
|
||||
if ($valcountry == 'Great Britain') { $valcountry = 'United Kingdom'; } // fix case of uk (when we use labels)
|
||||
print "\tdata.setValue(".$i.", 0, \"".$valcountry."\");\n";
|
||||
print "\tdata.setValue(".$i.", 1, ".$val['nb'].");\n";
|
||||
// Google's Geomap only supports up to 400 entries
|
||||
if ($i >= 400) { break; }
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "\tvar options = {};\n";
|
||||
print "\toptions['dataMode'] = 'regions';\n";
|
||||
print "\toptions['showZoomOut'] = false;\n";
|
||||
//print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
|
||||
print "\toptions['width'] = ".$graphwidth.";\n";
|
||||
print "\toptions['height'] = ".$graphheight.";\n";
|
||||
print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n";
|
||||
print "\tvar container = document.getElementById('".$mode."');\n";
|
||||
print "\tvar geomap = new google.visualization.GeoMap(container);\n";
|
||||
print "\tgeomap.draw(data, options);\n";
|
||||
print "};\n";
|
||||
print "</script>\n";
|
||||
print "\tvar options = {};\n";
|
||||
print "\toptions['dataMode'] = 'regions';\n";
|
||||
print "\toptions['showZoomOut'] = false;\n";
|
||||
//print "\toptions['zoomOutLabel'] = '".dol_escape_js($langs->transnoentitiesnoconv("Numbers"))."';\n";
|
||||
print "\toptions['width'] = ".$graphwidth.";\n";
|
||||
print "\toptions['height'] = ".$graphheight.";\n";
|
||||
print "\toptions['colors'] = [0x".colorArrayToHex($theme_datacolor[1], 'BBBBBB').", 0x".colorArrayToHex($theme_datacolor[0], '444444')."];\n";
|
||||
print "\tvar container = document.getElementById('".$mode."');\n";
|
||||
print "\tvar geomap = new google.visualization.GeoMap(container);\n";
|
||||
print "\tgeomap.draw(data, options);\n";
|
||||
print "};\n";
|
||||
print "</script>\n";
|
||||
|
||||
// print the div tag that will contain the map
|
||||
print '<div class="center" id="'.$mode.'"></div>'."\n";
|
||||
print '<br>';
|
||||
// print the div tag that will contain the map
|
||||
print '<div class="center" id="'.$mode.'"></div>'."\n";
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
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 '<table class="liste centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$label.'</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="center">'.$langs->trans("LastMemberDate").'</td>';
|
||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||
print '</tr>';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$label.'</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="center">'.$langs->trans("LastMemberDate").'</td>';
|
||||
print '<td class="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$val['label'].'</td>';
|
||||
if ($label2) print '<td class="center">'.$val['label2'].'</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['lastsubscriptiondate'], 'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$val['label'].'</td>';
|
||||
if ($label2) print '<td class="center">'.$val['label2'].'</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['lastsubscriptiondate'], 'dayhour').'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -36,8 +36,8 @@ $socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0;
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'adherent', '', '', 'cotisation');
|
||||
|
||||
@ -79,24 +79,24 @@ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscripti
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg) {
|
||||
$px1->SetData($data);
|
||||
$i = $startyear;
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
$px1->SetLegend($legend);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
$px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
|
||||
$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
$px1->SetYLabel($langs->trans("NbOfSubscriptions"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->mode = 'depth';
|
||||
$px1->SetTitle($langs->trans("NbOfSubscriptions"));
|
||||
$px1->SetData($data);
|
||||
$i = $startyear;
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
$px1->SetLegend($legend);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
$px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
|
||||
$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
$px1->SetYLabel($langs->trans("NbOfSubscriptions"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->mode = 'depth';
|
||||
$px1->SetTitle($langs->trans("NbOfSubscriptions"));
|
||||
|
||||
$px1->draw($filenamenb, $fileurlnb);
|
||||
$px1->draw($filenamenb, $fileurlnb);
|
||||
}
|
||||
|
||||
// Build graphic amount of object
|
||||
@ -110,24 +110,24 @@ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=memberstats&file=subscr
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
if (!$mesg) {
|
||||
$px2->SetData($data);
|
||||
$i = $startyear;
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode = 'depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfSubscriptions"));
|
||||
$px2->SetData($data);
|
||||
$i = $startyear;
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfSubscriptions"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode = 'depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfSubscriptions"));
|
||||
|
||||
$px2->draw($filenameamount, $fileurlamount);
|
||||
$px2->draw($filenameamount, $fileurlamount);
|
||||
}
|
||||
|
||||
|
||||
@ -171,31 +171,31 @@ print '</tr>';
|
||||
|
||||
$oldyear = 0;
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
while ($oldyear > $year + 1) { // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr class="oddeven" height="24">';
|
||||
print '<td class="center">';
|
||||
//print '<a href="month.php?year='.$oldyear.'&mode='.$mode.'">';
|
||||
print $oldyear;
|
||||
//print '</a>';
|
||||
print '</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr class="oddeven" height="24">';
|
||||
print '<td class="center">';
|
||||
//print '<a href="month.php?year='.$year.'">';
|
||||
print $year;
|
||||
//print '</a>';
|
||||
print '</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['avg'], 'MT'), 1).'</td>';
|
||||
print '</tr>';
|
||||
$oldyear = $year;
|
||||
$year = $val['year'];
|
||||
while ($oldyear > $year + 1) { // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr class="oddeven" height="24">';
|
||||
print '<td class="center">';
|
||||
//print '<a href="month.php?year='.$oldyear.'&mode='.$mode.'">';
|
||||
print $oldyear;
|
||||
//print '</a>';
|
||||
print '</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
print '<tr class="oddeven" height="24">';
|
||||
print '<td class="center">';
|
||||
//print '<a href="month.php?year='.$year.'">';
|
||||
print $year;
|
||||
//print '</a>';
|
||||
print '</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['avg'], 'MT'), 1).'</td>';
|
||||
print '</tr>';
|
||||
$oldyear = $year;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -208,9 +208,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
// Show graphs
|
||||
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
||||
if ($mesg) { print $mesg; } else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
print $px2->show();
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
print $px2->show();
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
@ -550,100 +550,100 @@ if ($rowid > 0) {
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
print "</table>\n";
|
||||
print "</table>\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
|
||||
*/
|
||||
|
||||
// Button to create a new subscription if member no draft neither resiliated
|
||||
if ($user->rights->adherent->cotisation->creer) {
|
||||
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
||||
print '<div class="tabsAction">';
|
||||
// Button to create a new subscription if member no draft neither resiliated
|
||||
if ($user->rights->adherent->cotisation->creer) {
|
||||
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
||||
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>";
|
||||
else print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$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>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* List of subscriptions
|
||||
*/
|
||||
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
||||
$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.datec, c.fk_type as cfk_type,";
|
||||
$sql .= " c.dateadh as dateh,";
|
||||
$sql .= " c.datef,";
|
||||
$sql .= " c.fk_bank,";
|
||||
$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 .= " 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_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
|
||||
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
|
||||
$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.datec, c.fk_type as cfk_type,";
|
||||
$sql .= " c.dateadh as dateh,";
|
||||
$sql .= " c.datef,";
|
||||
$sql .= " c.fk_bank,";
|
||||
$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 .= " 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_account as ba ON b.fk_account = ba.rowid";
|
||||
$sql .= " WHERE d.rowid = c.fk_adherent AND d.rowid=".$rowid;
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$subscriptionstatic = new Subscription($db);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$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_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('Type', $_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('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print "</tr>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
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('Type', $_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('Amount', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print_liste_field_titre('Account', $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$accountstatic = new Account($db);
|
||||
$adh = new Adherent($db);
|
||||
$adht = new AdherentType($db);
|
||||
$accountstatic = new Account($db);
|
||||
$adh = new Adherent($db);
|
||||
$adht = new AdherentType($db);
|
||||
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$adh->id = $objp->rowid;
|
||||
$adh->typeid = $objp->type;
|
||||
$adh->id = $objp->rowid;
|
||||
$adh->typeid = $objp->type;
|
||||
|
||||
$subscriptionstatic->ref = $objp->crowid;
|
||||
$subscriptionstatic->id = $objp->crowid;
|
||||
$subscriptionstatic->ref = $objp->crowid;
|
||||
$subscriptionstatic->id = $objp->crowid;
|
||||
|
||||
$typeid = $objp->cfk_type;
|
||||
if ($typeid > 0) {
|
||||
$adht->fetch($typeid);
|
||||
}
|
||||
$typeid = $objp->cfk_type;
|
||||
if ($typeid > 0) {
|
||||
$adht->fetch($typeid);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n";
|
||||
print '<td class="center">';
|
||||
if ($typeid > 0) {
|
||||
print $adht->getNomUrl(1);
|
||||
}
|
||||
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->datef), 'day')."</td>\n";
|
||||
print '<td class="right">'.price($objp->subscription).'</td>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="center">'.dol_print_date($db->jdate($objp->datec), 'dayhour')."</td>\n";
|
||||
print '<td class="center">';
|
||||
if ($typeid > 0) {
|
||||
print $adht->getNomUrl(1);
|
||||
}
|
||||
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->datef), 'day')."</td>\n";
|
||||
print '<td class="right">'.price($objp->subscription).'</td>';
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
print '<td class="right">';
|
||||
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 '<br>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '<br>';
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Bank account
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
|
||||
$form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2);
|
||||
print "</td></tr>\n";
|
||||
// Bank account
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("FinancialAccount").'</td><td>';
|
||||
$form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Payment mode
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$form->select_types_paiements(GETPOST('operation'), 'operation', '', 2);
|
||||
print "</td></tr>\n";
|
||||
// Payment mode
|
||||
print '<tr class="bankswitchclass"><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td>';
|
||||
$form->select_types_paiements(GETPOST('operation'), 'operation', '', 2);
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Date of payment
|
||||
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 "</td></tr>\n";
|
||||
// Date of payment
|
||||
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 "</td></tr>\n";
|
||||
|
||||
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>';
|
||||
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="fieldnum_chq" name="num_chq" type="text" size="8" value="'.(!GETPOST('num_chq') ? '' : GETPOST('num_chq')).'"></td></tr>';
|
||||
|
||||
print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
|
||||
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>';
|
||||
print '<tr class="bankswitchclass2 fieldrequireddyn"><td>'.$langs->trans('CheckTransmitter');
|
||||
print ' <em>('.$langs->trans("ChequeMaker").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="fieldchqemetteur" name="chqemetteur" size="32" type="text" value="'.(!GETPOST('chqemetteur') ? '' : GETPOST('chqemetteur')).'"></td></tr>';
|
||||
|
||||
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
|
||||
print ' <em>('.$langs->trans("ChequeBank").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!GETPOST('chqbank') ? '' : GETPOST('chqbank')).'"></td></tr>';
|
||||
}
|
||||
}
|
||||
print '<tr class="bankswitchclass2"><td>'.$langs->trans('Bank');
|
||||
print ' <em>('.$langs->trans("ChequeBank").')</em>';
|
||||
print '</td>';
|
||||
print '<td><input id="chqbank" name="chqbank" size="32" type="text" value="'.(!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 '<td>';
|
||||
if (!$object->email) {
|
||||
print $langs->trans("NoEMail");
|
||||
} else {
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
print '<tr><td>'.$langs->trans("SendAcknowledgementByMail").'</td>';
|
||||
print '<td>';
|
||||
if (!$object->email) {
|
||||
print $langs->trans("NoEMail");
|
||||
} else {
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($object->typeid);
|
||||
|
||||
// Send subscription email
|
||||
$subject = '';
|
||||
$msg = '';
|
||||
// Send subscription email
|
||||
$subject = '';
|
||||
$msg = '';
|
||||
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content from template
|
||||
$arraydefaultmessage = null;
|
||||
$labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION;
|
||||
// Send subscription email
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
|
||||
$formmail = new FormMail($db);
|
||||
// Set output language
|
||||
$outputlangs = new Translate('', $conf);
|
||||
$outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang);
|
||||
// Load traductions files required by page
|
||||
$outputlangs->loadLangs(array("main", "members"));
|
||||
// Get email content from template
|
||||
$arraydefaultmessage = null;
|
||||
$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) {
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) {
|
||||
$subject = $arraydefaultmessage->topic;
|
||||
$msg = $arraydefaultmessage->content;
|
||||
}
|
||||
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs);
|
||||
$texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnSubscription()), $substitutionarray, $outputlangs);
|
||||
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
|
||||
complete_substitutions_array($substitutionarray, $outputlangs, $object);
|
||||
$subjecttosend = make_substitutions($subject, $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' : '')).'>';
|
||||
$helpcontent = '';
|
||||
$helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
|
||||
if ($subjecttosend) {
|
||||
$helpcontent .= $subjecttosend."\n";
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
|
||||
}
|
||||
$helpcontent .= "<br>";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>';
|
||||
if ($texttosend) {
|
||||
$helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
|
||||
}
|
||||
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</tbody>';
|
||||
print '</table>';
|
||||
$tmp = '<input name="sendmail" type="checkbox"'.(GETPOST('sendmail', 'alpha') ? ' checked' : (!empty($conf->global->ADHERENT_DEFAULT_SENDINFOBYMAIL) ? ' checked' : '')).'>';
|
||||
$helpcontent = '';
|
||||
$helpcontent .= '<b>'.$langs->trans("MailFrom").'</b>: '.$conf->global->ADHERENT_MAIL_FROM.'<br>'."\n";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailRecipient").'</b>: '.$object->email.'<br>'."\n";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailTopic").'</b>:<br>'."\n";
|
||||
if ($subjecttosend) {
|
||||
$helpcontent .= $subjecttosend."\n";
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
|
||||
}
|
||||
$helpcontent .= "<br>";
|
||||
$helpcontent .= '<b>'.$langs->trans("MailText").'</b>:<br>';
|
||||
if ($texttosend) {
|
||||
$helpcontent .= dol_htmlentitiesbr($texttosend)."\n";
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
$helpcontent .= '<span class="error">'.$langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("Module310Name")).'</span>'."\n";
|
||||
}
|
||||
print $form->textwithpicto($tmp, $helpcontent, 1, 'help', '', 0, 2, 'helpemailtosend');
|
||||
}
|
||||
print '</td></tr>';
|
||||
print '</tbody>';
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
print dol_get_fiche_end();
|
||||
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
print '<div class="center">';
|
||||
print '<input type="submit" class="button" name="add" value="'.$langs->trans("AddSubscription").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
print '</form>';
|
||||
|
||||
print "\n<!-- End form subscription -->\n\n";
|
||||
}
|
||||
print "\n<!-- End form subscription -->\n\n";
|
||||
}
|
||||
|
||||
//print '</td></tr>';
|
||||
//print '</table>';
|
||||
//print '</td></tr>';
|
||||
//print '</table>';
|
||||
} else {
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorRecordNotFound");
|
||||
$langs->load("errors");
|
||||
print $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
|
||||
// End of page
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -40,10 +40,13 @@ $object = new Subscription($db);
|
||||
$errmsg = '';
|
||||
|
||||
$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");
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$confirm = GETPOST('confirm');
|
||||
$note = GETPOST('note', 'alpha');
|
||||
$typeid = (int) GETPOST('typeid', 'int');
|
||||
$amount = price2num(GETPOST('amount', 'alpha'), 'MT');
|
||||
|
||||
if (!$user->rights->adherent->cotisation->lire)
|
||||
accessforbidden();
|
||||
@ -84,7 +87,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
|
||||
} else {
|
||||
$accountline->datev = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
|
||||
$accountline->dateo = dol_mktime($_POST['datesubhour'], $_POST['datesubmin'], 0, $_POST['datesubmonth'], $_POST['datesubday'], $_POST['datesubyear']);
|
||||
$accountline->amount = $_POST["amount"];
|
||||
$accountline->amount = $amount;
|
||||
$result = $accountline->update($user);
|
||||
if ($result < 0) {
|
||||
$errmsg = $accountline->error;
|
||||
@ -96,9 +99,9 @@ if ($user->rights->adherent->cotisation->creer && $action == 'update' && !$cance
|
||||
// Modify values
|
||||
$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->fk_type = $_POST["typeid"];
|
||||
$object->note = $_POST["note"];
|
||||
$object->amount = $_POST["amount"];
|
||||
$object->fk_type = $typeid;
|
||||
$object->note = $note;
|
||||
$object->amount = $amount;
|
||||
//print 'datef='.$object->datef.' '.$_POST['datesubendday'];
|
||||
|
||||
$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>';
|
||||
|
||||
// Bank line
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) {
|
||||
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
|
||||
if ($object->fk_bank) {
|
||||
$bankline = new AccountLine($db);
|
||||
$result = $bankline->fetch($object->fk_bank);
|
||||
print $bankline->getNomUrl(1, 0, 'showall');
|
||||
} else {
|
||||
print $langs->trans("NoneF");
|
||||
}
|
||||
print '</td></tr>';
|
||||
if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
|
||||
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur" colspan="2">';
|
||||
if ($object->fk_bank) {
|
||||
$bankline = new AccountLine($db);
|
||||
$result = $bankline->fetch($object->fk_bank);
|
||||
print $bankline->getNomUrl(1, 0, 'showall');
|
||||
} else {
|
||||
print $langs->trans("NoneF");
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
@ -316,18 +317,16 @@ if ($rowid && $action != 'edit') {
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td class="valeur">'.$object->note.'</td></tr>';
|
||||
|
||||
// Bank line
|
||||
if (!empty($conf->banque->enabled)) {
|
||||
if ($conf->global->ADHERENT_BANK_USE || $object->fk_bank) {
|
||||
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
|
||||
if ($object->fk_bank) {
|
||||
$bankline = new AccountLine($db);
|
||||
$result = $bankline->fetch($object->fk_bank);
|
||||
print $bankline->getNomUrl(1, 0, 'showall');
|
||||
} else {
|
||||
print $langs->trans("NoneF");
|
||||
}
|
||||
print '</td></tr>';
|
||||
if (!empty($conf->banque->enabled) && ($conf->global->ADHERENT_BANK_USE || $object->fk_bank)) {
|
||||
print '<tr><td>'.$langs->trans("BankTransactionLine").'</td><td class="valeur">';
|
||||
if ($object->fk_bank) {
|
||||
$bankline = new AccountLine($db);
|
||||
$result = $bankline->fetch($object->fk_bank);
|
||||
print $bankline->getNomUrl(1, 0, 'showall');
|
||||
} else {
|
||||
print $langs->trans("NoneF");
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
|
||||
@ -110,22 +110,22 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
// Selection of new fields
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
// 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
|
||||
$search_type = "";
|
||||
$search_ref = "";
|
||||
$search_lastname = "";
|
||||
$search_firstname = "";
|
||||
$search_login = "";
|
||||
$search_note = "";
|
||||
$search_amount = "";
|
||||
$search_account = "";
|
||||
$toselect = '';
|
||||
$search_array_options = array();
|
||||
}
|
||||
$search_ref = "";
|
||||
$search_lastname = "";
|
||||
$search_firstname = "";
|
||||
$search_login = "";
|
||||
$search_note = "";
|
||||
$search_amount = "";
|
||||
$search_account = "";
|
||||
$toselect = '';
|
||||
$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 .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
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 + 1)."-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'";
|
||||
}
|
||||
if ($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
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) $nbtotalofrecords = $db->num_rows($resql);
|
||||
else dol_print_error($db);
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) $nbtotalofrecords = $db->num_rows($resql);
|
||||
else dol_print_error($db);
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
// Add limit
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
@ -241,7 +241,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
|
||||
$newcardbutton = '';
|
||||
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"].'">';
|
||||
@ -409,8 +409,8 @@ while ($i < min($num, $limit)) {
|
||||
$adherent->typeid = $obj->type;
|
||||
|
||||
$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($typeid);
|
||||
$adht = new AdherentType($db);
|
||||
$adht->fetch($typeid);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -419,14 +419,14 @@ while ($i < min($num, $limit)) {
|
||||
print '<td>'.$subscription->getNomUrl(1).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
// Type
|
||||
if (!empty($arrayfields['d.fk_type']['checked'])) {
|
||||
print '<td class="nowraponall">';
|
||||
if ($typeid > 0) {
|
||||
print $adht->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
// Type
|
||||
if (!empty($arrayfields['d.fk_type']['checked'])) {
|
||||
print '<td class="nowraponall">';
|
||||
if ($typeid > 0) {
|
||||
print $adht->getNomUrl(1);
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// Lastname
|
||||
|
||||
@ -33,12 +33,12 @@ $langs->load("members");
|
||||
|
||||
$total = 0;
|
||||
foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
echo '<tr class="oddeven">';
|
||||
echo '<td>'.$langs->trans("Subscription").'</td>';
|
||||
echo '<td>'.$objectlink->getNomUrl(1).'</td>';
|
||||
echo '<td class="center"></td>';
|
||||
echo '<td class="center">'.dol_print_date($objectlink->dateh, 'day').'</td>';
|
||||
echo '<td class="right">';
|
||||
echo '<tr class="oddeven">';
|
||||
echo '<td>'.$langs->trans("Subscription").'</td>';
|
||||
echo '<td>'.$objectlink->getNomUrl(1).'</td>';
|
||||
echo '<td class="center"></td>';
|
||||
echo '<td class="center">'.dol_print_date($objectlink->dateh, 'day').'</td>';
|
||||
echo '<td class="right">';
|
||||
if ($user->rights->adherent->lire) {
|
||||
$total = $total + $objectlink->amount;
|
||||
echo price($objectlink->amount);
|
||||
@ -46,7 +46,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
||||
echo '</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 '</tr>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
echo "<!-- END PHP TEMPLATE -->\n";
|
||||
|
||||
@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
||||
print '<tr class="liste_titre">';
|
||||
print '<th>'.$langs->trans("Ref").'</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("VoteAllowed").'</th>';
|
||||
print '<th class="center">'.$langs->trans("Status").'</th>';
|
||||
@ -263,6 +263,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
||||
$membertype->ref = $objp->rowid;
|
||||
$membertype->label = $objp->rowid;
|
||||
$membertype->status = $objp->status;
|
||||
$membertype->subscription = $objp->subscription;
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>';
|
||||
@ -271,7 +272,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
|
||||
print '</td>';
|
||||
print '<td>'.dol_escape_htmltag($objp->label).'</td>';
|
||||
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 class="center">'.yn($objp->subscription).'</td>';
|
||||
print '<td class="center">'.yn($objp->vote).'</td>';
|
||||
@ -321,10 +322,10 @@ if ($action == 'create') {
|
||||
|
||||
// Morphy
|
||||
$morphys = array();
|
||||
$morphys[""] = $langs->trans("MorPhy");
|
||||
$morphys["phy"] = $langs->trans("Physical");
|
||||
$morphys[""] = $langs->trans("MorAndPhy");
|
||||
$morphys["phy"] = $langs->trans("Physical");
|
||||
$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 "</td></tr>";
|
||||
|
||||
@ -343,12 +344,12 @@ if ($action == 'create') {
|
||||
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
|
||||
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();
|
||||
|
||||
print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
|
||||
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();
|
||||
print '</td></tr>';
|
||||
|
||||
@ -401,7 +402,7 @@ if ($rowid > 0) {
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// 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><td class="titlefield">'.$langs->trans("SubscriptionRequired").'</td><td>';
|
||||
@ -614,13 +615,16 @@ if ($rowid > 0) {
|
||||
$adh = new Adherent($db);
|
||||
$adh->lastname = $objp->lastname;
|
||||
$adh->firstname = $objp->firstname;
|
||||
$adh->datefin = $datefin;
|
||||
$adh->need_subscription = $objp->subscription;
|
||||
$adh->statut = $objp->status;
|
||||
|
||||
// Lastname
|
||||
print '<tr class="oddeven">';
|
||||
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 {
|
||||
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
|
||||
@ -640,9 +644,9 @@ if ($rowid > 0) {
|
||||
// EMail
|
||||
print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
|
||||
|
||||
// Statut
|
||||
// Status
|
||||
print '<td class="nowrap">';
|
||||
print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
|
||||
print $adh->getLibStatut(2);
|
||||
print "</td>";
|
||||
|
||||
// Date end subscription
|
||||
@ -668,11 +672,10 @@ if ($rowid > 0) {
|
||||
// Actions
|
||||
print '<td class="center">';
|
||||
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 ' ';
|
||||
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>";
|
||||
|
||||
@ -723,11 +726,11 @@ if ($rowid > 0) {
|
||||
print '</td></tr>';
|
||||
|
||||
// Morphy
|
||||
$morphys[""] = $langs->trans("MorPhy");
|
||||
$morphys[""] = $langs->trans("MorAndPhy");
|
||||
$morphys["phy"] = $langs->trans("Physical");
|
||||
$morphys["mor"] = $langs->trans("Moral");
|
||||
print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
|
||||
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
|
||||
print '<tr><td><span>'.$langs->trans("MembersNature").'</span></td><td>';
|
||||
print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : $object->morphy);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
|
||||
|
||||
@ -123,7 +123,7 @@ print dol_get_fiche_end();
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
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";
|
||||
@ -146,27 +146,27 @@ print '</tr>';
|
||||
$ldap = new Ldap();
|
||||
$result = $ldap->connect_bind();
|
||||
if ($result > 0) {
|
||||
$info = $object->_load_ldap_info();
|
||||
$dn = $object->_load_ldap_dn($info, 1);
|
||||
$search = "(".$object->_load_ldap_dn($info, 2).")";
|
||||
$info = $object->_load_ldap_info();
|
||||
$dn = $object->_load_ldap_dn($info, 1);
|
||||
$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
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
|
||||
if (!is_array($records)) {
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||
} else {
|
||||
$result = show_ldap_content($records, 0, $records['count'], true);
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
||||
}
|
||||
// Show tree
|
||||
if (((!is_numeric($records)) || $records != 0) && (!isset($records['count']) || $records['count'] > 0)) {
|
||||
if (!is_array($records)) {
|
||||
print '<tr class="oddeven"><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
|
||||
} else {
|
||||
$result = show_ldap_content($records, 0, $records['count'], true);
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
|
||||
}
|
||||
|
||||
$ldap->unbind();
|
||||
$ldap->close();
|
||||
$ldap->unbind();
|
||||
$ldap->close();
|
||||
} else {
|
||||
setEventMessages($ldap->error, $ldap->errors, 'errors');
|
||||
}
|
||||
|
||||
@ -154,9 +154,9 @@ $titre = $langs->trans("MemberType".$object->type);
|
||||
// Calculate $cnt_trans
|
||||
$cnt_trans = 0;
|
||||
if (!empty($object->multilangs)) {
|
||||
foreach ($object->multilangs as $key => $value) {
|
||||
$cnt_trans++;
|
||||
}
|
||||
foreach ($object->multilangs as $key => $value) {
|
||||
$cnt_trans++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -179,10 +179,10 @@ print dol_get_fiche_end();
|
||||
print "\n<div class=\"tabsAction\">\n";
|
||||
|
||||
if ($action == '') {
|
||||
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>';
|
||||
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 ($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>';
|
||||
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";
|
||||
@ -262,7 +262,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
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 '<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>';
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.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
|
||||
* 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);
|
||||
if ($result <= 0)
|
||||
{
|
||||
if ($result <= 0) {
|
||||
dol_print_error($adherent->error);
|
||||
exit;
|
||||
}
|
||||
@ -48,8 +48,7 @@ if ($result <= 0)
|
||||
$physicalperson = 1;
|
||||
|
||||
$company = new Societe($db);
|
||||
if ($adherent->socid)
|
||||
{
|
||||
if ($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->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->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK");
|
||||
|
||||
$v->setEmail($adherent->email);
|
||||
$v->setNote($adherent->note);
|
||||
$v->setNote($adherent->note_public);
|
||||
$v->setTitle($adherent->poste);
|
||||
|
||||
// Data from linked company
|
||||
if ($company->id)
|
||||
{
|
||||
if ($company->id) {
|
||||
$v->setURL($company->url, "TYPE=WORK");
|
||||
if (! $adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
|
||||
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");
|
||||
|
||||
if (!$adherent->phone_pro) {
|
||||
$v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
|
||||
}
|
||||
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
|
||||
if (empty(trim($company->email)))
|
||||
{
|
||||
if (empty(trim($company->email))) {
|
||||
// was set before, don't set twice
|
||||
}
|
||||
// when adherent e-mail is empty, use only company e-mail
|
||||
elseif (empty(trim($adherent->email)))
|
||||
{
|
||||
} elseif (empty(trim($adherent->email))) {
|
||||
// when adherent e-mail is empty, use only company e-mail
|
||||
$v->setEmail($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)
|
||||
elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $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)
|
||||
$v->setEmail($adherent->email);
|
||||
|
||||
// support by Microsoft Outlook (2019 and possible earlier)
|
||||
$v->setEmail($company->email, 'INTERNET');
|
||||
}
|
||||
// when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
|
||||
else {
|
||||
} else {
|
||||
// when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second)
|
||||
$v->setEmail($company->email);
|
||||
|
||||
// support by Microsoft Outlook (2019 and possible earlier)
|
||||
@ -110,12 +107,16 @@ if ($company->id)
|
||||
}
|
||||
|
||||
// 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
|
||||
$v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE");
|
||||
if ($adherent->birthday) $v->setBirthday($adherent->birthday);
|
||||
if ($adherent->birth) {
|
||||
$v->setBirthday($adherent->birth);
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -124,7 +125,7 @@ $db->close();
|
||||
|
||||
$output = $v->getVCard();
|
||||
|
||||
$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
|
||||
$filename = trim(urldecode($v->getFileName())); // "Nom prenom.vcf"
|
||||
$filenameurlencoded = dol_sanitizeFileName(urlencode($filename));
|
||||
//$filename = dol_sanitizeFileName($filename);
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$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))
|
||||
{
|
||||
$i = 0;
|
||||
$i = 0;
|
||||
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
foreach ($triggers as $trigger)
|
||||
{
|
||||
@ -102,13 +102,13 @@ if ($action == "save" && empty($cancel))
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
$db->commit();
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
$db->commit();
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -84,9 +84,9 @@ print dol_get_fiche_end();
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
print '<div class="tabsAction">';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
@ -99,9 +99,9 @@ if ($action != 'create' && $action != 'edit')
|
||||
if ($action == 'create')
|
||||
{
|
||||
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))
|
||||
{
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
print "<br>";
|
||||
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
|
||||
|
||||
@ -54,9 +54,9 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
|
||||
|
||||
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);
|
||||
|
||||
$i = 1; $errorsaved = 0;
|
||||
@ -103,14 +103,14 @@ if ($actionsave)
|
||||
$MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
if (!$error)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@ -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';
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('admin', 'other', 'agenda', 'users'));
|
||||
@ -80,49 +80,49 @@ if ($action == 'set')
|
||||
$getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE');
|
||||
$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_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_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_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
||||
} elseif ($action == 'specimen') // For orders
|
||||
{
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db, $commande);
|
||||
$module = new $classname($db, $commande);
|
||||
|
||||
if ($module->write_file($commande, $langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, $module->errors, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
if ($module->write_file($commande, $langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, $module->errors, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
@ -135,7 +135,7 @@ elseif ($action == 'setmodel')
|
||||
$ret = delDocumentModel($value, $type);
|
||||
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);
|
||||
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++;
|
||||
}
|
||||
$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);
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
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 '<tr class="liste_titre">'."\n";
|
||||
print '<td width="100">'.$langs->trans("Name").'</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("Default").'</td>'."\n";
|
||||
print '<td class="center" width="40">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td class="center" width="40">'.$langs->trans("Preview").'</td>';
|
||||
print '</tr>'."\n";
|
||||
print '<table class="noborder centpercent">'."\n";
|
||||
print '<tr class="liste_titre">'."\n";
|
||||
print '<td width="100">'.$langs->trans("Name").'</td>'."\n";
|
||||
print '<td>'.$langs->trans("Description").'</td>'."\n";
|
||||
print '<td 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="40">'.$langs->trans("ShortInfo").'</td>';
|
||||
print '<td class="center" width="40">'.$langs->trans("Preview").'</td>';
|
||||
print '</tr>'."\n";
|
||||
|
||||
clearstatcache();
|
||||
clearstatcache();
|
||||
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/action/doc");
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir."core/modules/action/doc");
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
|
||||
{
|
||||
$name = substr($file, 4, dol_strlen($file) - 16);
|
||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new ActionComm($db));
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, new ActionComm($db));
|
||||
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print "<td>";
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, $specimenthirdparty);
|
||||
if (method_exists($module, 'info'))
|
||||
print $module->info($langs);
|
||||
else print $module->description;
|
||||
print "</td>\n";
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print "<td>";
|
||||
print (empty($module->name) ? $name : $module->name);
|
||||
print "</td>\n";
|
||||
print "<td>\n";
|
||||
require_once $dir.'/'.$file;
|
||||
$module = new $classname($db, $specimenthirdparty);
|
||||
if (method_exists($module, 'info'))
|
||||
print $module->info($langs);
|
||||
else print $module->description;
|
||||
print "</td>\n";
|
||||
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
print '<td class="center">'."\n";
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
}
|
||||
print "</td>";
|
||||
} else {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
// Active
|
||||
if (in_array($name, $def))
|
||||
{
|
||||
print '<td class="center">'."\n";
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name")
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">';
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
print '</a>';
|
||||
} else {
|
||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||
}
|
||||
print "</td>";
|
||||
} else {
|
||||
print '<td class="center">'."\n";
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
|
||||
print "</td>";
|
||||
}
|
||||
|
||||
// Default
|
||||
print '<td class="center">';
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
|
||||
{
|
||||
print img_picto($langs->trans("Default"), 'on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
// Default
|
||||
print '<td class="center">';
|
||||
if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name")
|
||||
{
|
||||
print img_picto($langs->trans("Default"), 'on');
|
||||
} else {
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&token='.newToken().'&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'order').'</a>';
|
||||
print '</td>';
|
||||
// Info
|
||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
||||
print '<td class="center">';
|
||||
print $form->textwithpicto('', $htmltooltip, 1, 0);
|
||||
print '</td>';
|
||||
print '<td class="center">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'order').'</a>';
|
||||
print '</td>';
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</table><br>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</table><br>';
|
||||
}
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" name="agenda">';
|
||||
@ -343,13 +343,13 @@ print '</td></tr>'."\n";
|
||||
|
||||
if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\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);
|
||||
print '</td></tr>'."\n";
|
||||
print '<!-- AGENDA_USE_EVENT_TYPE_DEFAULT -->';
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\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);
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
|
||||
// AGENDA_DEFAULT_FILTER_TYPE
|
||||
@ -359,8 +359,8 @@ print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right nowrap">'."\n";
|
||||
$multiselect = 0;
|
||||
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"
|
||||
$multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE));
|
||||
// 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));
|
||||
}
|
||||
$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";
|
||||
|
||||
@ -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';
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "other", "agenda"));
|
||||
@ -73,49 +73,49 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
||||
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_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_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_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity);
|
||||
} elseif ($action == 'specimen') // For orders
|
||||
{
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
$modele = GETPOST('module', 'alpha');
|
||||
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
$commande = new CommandeFournisseur($db);
|
||||
$commande->initAsSpecimen();
|
||||
$commande->thirdparty = $specimenthirdparty;
|
||||
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Search template files
|
||||
$file = ''; $classname = ''; $filefound = 0;
|
||||
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
|
||||
foreach ($dirmodels as $reldir)
|
||||
{
|
||||
$file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0);
|
||||
if (file_exists($file))
|
||||
{
|
||||
$filefound = 1;
|
||||
$classname = "pdf_".$modele;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
if ($filefound)
|
||||
{
|
||||
require_once $file;
|
||||
|
||||
$module = new $classname($db, $commande);
|
||||
$module = new $classname($db, $commande);
|
||||
|
||||
if ($module->write_file($commande, $langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, $module->errors, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
if ($module->write_file($commande, $langs) > 0)
|
||||
{
|
||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf");
|
||||
return;
|
||||
} else {
|
||||
setEventMessages($module->error, $module->errors, 'errors');
|
||||
dol_syslog($module->error, LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
// Activate a model
|
||||
@ -128,7 +128,7 @@ elseif ($action == 'setmodel')
|
||||
$ret = delDocumentModel($value, $type);
|
||||
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
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL == 2)
|
||||
{
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
|
||||
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
|
||||
print '</td></tr>'."\n";
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
|
||||
print '</td></tr>'."\n";
|
||||
if (empty($conf->global->AGENDA_REMINDER_BROWSER)) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
|
||||
print '</td></tr>'."\n";
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_REMINDER_BROWSER_SOUND').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
|
||||
if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
|
||||
}
|
||||
if (empty($conf->global->AGENDA_REMINDER_BROWSER_SOUND)) {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Disabled'), 'switch_off').'</a>';
|
||||
} else {
|
||||
print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_BROWSER_SOUND&token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';
|
||||
}
|
||||
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
print '</td></tr>'."\n";
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
||||
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "other", "agenda"));
|
||||
@ -41,23 +41,23 @@ $actionsave = GETPOST('save', 'alpha');
|
||||
// Sauvegardes parametres
|
||||
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_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, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', '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_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);
|
||||
|
||||
if ($i >= 4)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
setEventMessages($langs->trans("SaveFailed"), null, 'errors');
|
||||
}
|
||||
if ($i >= 4)
|
||||
{
|
||||
$db->commit();
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
$db->rollback();
|
||||
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 .= '<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 .=$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 .= '<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">';
|
||||
|
||||
@ -81,9 +81,9 @@ print dol_get_fiche_end();
|
||||
// Buttons
|
||||
if ($action != 'create' && $action != 'edit')
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
print '<div class="tabsAction">';
|
||||
print "<a class=\"butAction\" href=\"".$_SERVER["PHP_SELF"]."?action=create#newattrib\">".$langs->trans("NewAttribute")."</a>";
|
||||
print "</div>";
|
||||
}
|
||||
|
||||
|
||||
@ -93,9 +93,9 @@ if ($action != 'create' && $action != 'edit')
|
||||
if ($action == 'create')
|
||||
{
|
||||
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))
|
||||
{
|
||||
print "<br>";
|
||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||
print "<br>";
|
||||
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
|
||||
|
||||
@ -44,11 +44,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
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);
|
||||
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')
|
||||
{
|
||||
@ -76,45 +76,45 @@ if ($action == 'setcoder')
|
||||
$res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id, 'chaine', 0, '', $conf->entity);
|
||||
|
||||
if ($res > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
{
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
} elseif ($action == 'updateengine')
|
||||
{
|
||||
$sql = "SELECT rowid, coder";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
||||
$sql .= " WHERE entity = ".$conf->entity;
|
||||
$sql .= " ORDER BY code";
|
||||
$sql = "SELECT rowid, coder";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
|
||||
$sql .= " WHERE entity = ".$conf->entity;
|
||||
$sql .= " ORDER BY code";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if (GETPOST('coder'.$obj->rowid, 'alpha'))
|
||||
{
|
||||
$coder = GETPOST('coder'.$obj->rowid, 'alpha');
|
||||
$code_id = $obj->rowid;
|
||||
if (GETPOST('coder'.$obj->rowid, 'alpha'))
|
||||
{
|
||||
$coder = GETPOST('coder'.$obj->rowid, 'alpha');
|
||||
$code_id = $obj->rowid;
|
||||
|
||||
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
||||
$sqlp .= " SET coder = '".$db->escape($coder)."'";
|
||||
$sqlp .= " WHERE rowid = ".((int) $code_id);
|
||||
$sqlp .= " AND entity = ".$conf->entity;
|
||||
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
|
||||
$sqlp .= " SET coder = '".$db->escape($coder)."'";
|
||||
$sqlp .= " WHERE rowid = ".((int) $code_id);
|
||||
$sqlp .= " AND entity = ".$conf->entity;
|
||||
|
||||
$upsql = $db->query($sqlp);
|
||||
if (!$upsql) dol_print_error($db);
|
||||
}
|
||||
$upsql = $db->query($sqlp);
|
||||
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)
|
||||
{
|
||||
$dir = dol_buildpath($reldir);
|
||||
$newdir = dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (!is_dir($newdir)) continue;
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (!is_dir($newdir)) continue;
|
||||
|
||||
$handle = @opendir($newdir);
|
||||
if (is_resource($handle))
|
||||
@ -190,9 +190,9 @@ print load_fiche_titre($langs->trans("BarcodeEncodeModule"), '', '');
|
||||
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="updateengine">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" id="form_engine">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="updateengine">';
|
||||
}
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
@ -236,11 +236,11 @@ if ($resql)
|
||||
|
||||
foreach ($dirbarcode as $reldir)
|
||||
{
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
$dir = dol_buildpath($reldir, 0);
|
||||
$newdir = dol_osencode($dir);
|
||||
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (!is_dir($newdir)) continue;
|
||||
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php)
|
||||
if (!is_dir($newdir)) continue;
|
||||
|
||||
$result = @include_once $newdir.$obj->coder.'.modules.php';
|
||||
if ($result) break;
|
||||
@ -254,7 +254,7 @@ if ($resql)
|
||||
if ($module->encodingIsSupported($obj->encoding))
|
||||
{
|
||||
// Build barcode on disk (not used, this is done to make debug easier)
|
||||
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
||||
$result = $module->writeBarCode($obj->example, $obj->encoding, 'Y');
|
||||
// Generate on the fly and output barcode with generator
|
||||
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($obj->coder).'&code='.urlencode($obj->example).'&encoding='.urlencode($obj->encoding);
|
||||
//print $url;
|
||||
@ -282,8 +282,8 @@ print "</table>\n";
|
||||
|
||||
if (empty($conf->use_javascript_ajax))
|
||||
{
|
||||
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
|
||||
print '</form>';
|
||||
print '<div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"></div>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
print "<br>";
|
||||
@ -371,48 +371,48 @@ if ($conf->product->enabled)
|
||||
$dir = dol_buildpath($dirroot, 0);
|
||||
|
||||
$handle = @opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/^mod_barcode_product_.*php$/', $file))
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (preg_match('/^mod_barcode_product_.*php$/', $file))
|
||||
{
|
||||
$file = substr($file, 0, dol_strlen($file) - 4);
|
||||
|
||||
try {
|
||||
dol_include_once($dirroot.$file.'.php');
|
||||
} catch (Exception $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
try {
|
||||
dol_include_once($dirroot.$file.'.php');
|
||||
} catch (Exception $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_ERR);
|
||||
}
|
||||
|
||||
$modBarCode = new $file();
|
||||
$modBarCode = new $file();
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
|
||||
print $modBarCode->info($langs);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."</td><td>\n";
|
||||
print $modBarCode->info($langs);
|
||||
print '</td>';
|
||||
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";
|
||||
|
||||
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file")
|
||||
{
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&token='.newToken().'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproducto&token='.newToken().'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td class="center">';
|
||||
$s = $modBarCode->getToolTip($langs, null, -1);
|
||||
print $form->textwithpicto('', $s, 1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
if ($conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file")
|
||||
{
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&token='.newToken().'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproducto&token='.newToken().'&value='.urlencode($file).'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td class="center">';
|
||||
$s = $modBarCode->getToolTip($langs, null, -1);
|
||||
print $form->textwithpicto('', $s, 1);
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user