Merge pull request #1 from Dolibarr/develop

Mise à jour du fork
This commit is contained in:
Damien BENOIT 2020-11-16 11:06:51 +01:00 committed by GitHub
commit 3f16dc8620
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1789 changed files with 121811 additions and 116461 deletions

View File

@ -56,7 +56,7 @@ You can add it to your git configuration using:
git config --local commit.template .gitmessage
```
where
where
#### Keyword
In uppercase if you want to have the log comment appears into the generated ChangeLog file.
@ -101,7 +101,7 @@ Long description (Can span accross multiple lines).
</pre>
### Pull Requests
Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and
Pull Request (PR) process is the process to submit a change (enhancement, bug fix, ...) into the code of the project. There is some rules to know and
a process to follow to optimize the chance to have PRs merged efficiently...
* A PR must be atomic. It means it must contains the lower possible changes for 1 need (1 bug fix or 1 new feature) without breaking usability of code. If a PR can be split into several PRs, it often means your PR is not atomic.
@ -120,7 +120,7 @@ Once a PR has been submitted, you may need to wait for its integration. It is co
If the label of PR start with "Draft" or "WIP" (Work In Progress), it will not be analyzed for merging until you change the label of PR (but it can be analyzed for discussion).
If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration.
If your PR has errors reported by the Continuous Integration Platform, it means your PR is not valid and nothing will be done with it. It will be kept open to allow developers to fix this, or it may be closed several month later. Don't expect anything on your PR if you have such errors, you MUST first fix the Continuous Integration error to have it taken into consideration.
If the PR is valid, and is kept open for a long time, a tag will also be added on the PR to describe the status of your PR and why the PR is kept open. By putting your mouse on the tag, you will get a full explanation of the tag/status that explain why your PR has not been integrated yet.
In most cases, it gives you information of things you have to do to have the PR taken into consideration (for example a change is requested, a conflict is expected to be solved, some questions were asked). If you have a yellow, red flag of purple flag, don't expect to have your PR validated. You must first provide the answer the tag ask you. The majority of open PR are waiting an action of the author of the PR.
@ -141,7 +141,7 @@ Translations done on transifex are available in the next major release.
Note: Sometimes, the source text (english) is modified. In such a case, the translation is reset. Transifex assume that if the original source
has changed, the translation is surely no more correct so must be done again. But old translation is not lost and you can use the tab "History"
to retreive all old translation of a source text, and restore the translation in one click with no need to retranslate it if there is no need to.
to retrieve all old translation of a source text, and restore the translation in one click with no need to retranslate it if there is no need to.
### Resources

View File

@ -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'

View File

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

View File

@ -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 ^0 \
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 \
php-parallel-lint/php-parallel-lint ^1 \
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
@ -428,7 +445,7 @@ script:
after_script:
- |
echo "After script - Output lines of dolibarr.log"
echo "After script - Output last lines of dolibarr.log"
ls $TRAVIS_BUILD_DIR/documents
#cat $TRAVIS_BUILD_DIR/documents/dolibarr.log
sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log

View File

@ -21,6 +21,7 @@ Mobiledetect 2.8.34 MIT License Yes
NuSoap 0.9.5 LGPL 2.1+ Yes Library to develop SOAP Web services (not into rpm and deb package)
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

305
ChangeLog
View File

@ -7,25 +7,242 @@ English Dolibarr ChangeLog
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 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 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 an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
NEW: Added incoterms dara into the substitution array
NEW: Add employee link 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: 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 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 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 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 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 send context for ticket
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 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 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: 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 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: 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: 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: 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: 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: get all child recursively
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: 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: 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: 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
NEW: PDF model storm for delivery
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: 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: 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: 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 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: 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: 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
NEW: Ticket message notifications when edited from public interface
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: 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
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 get thirdparty by barcode
NEW: API get users by email / login
NEW: fetch contact by email with REST API
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: 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: Triggers Attributes and Attributes values
NEW: Add hooks on newpayment page to allow external payment modules
WARNING:
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
* Properties ->contactid have been renamed into ->contact_id
* Properties ->titre have been renamed into ->title
* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id (english)
* The deprecated subsitution key __SIGNATURE__ has been removed. Replace with __USER_SIGNATURE__ if you used the old syntax in
your email templates.
* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom
days of holiday.
* The object "livraison" has been renamed into "delivery" (directory, class, keys, methods with livraison in name ...).
* All properties ->contactid have been renamed into ->contact_id
* All properties ->titre have been renamed into ->title
* Property $paiementid in API 'api_supplier_invoices.php' has been renamed into into $payment_mode_id
* Property 'num_paiement' has been renamed 'num_payment' everywhere for better code consistency.
* The deprecated subsitution key __SIGNATURE__ has been removed. Use __USER_SIGNATURE__ if you used the old syntax in your email templates.
* The hidden option HOLIDAY_MORE_PUBLIC_HOLIDAYS has been removed. Use instead the dictionary table if you need to define custom days of holiday.
* If you build a class that implement CommonObject to use the incoterm properties or methods (->fk_incoterm, ->label_incoterm, ->location_incoterm),
you must now also include declaration of the Trait 'CommonIncoterm' in your class. All incoterm functions were moved into this Trait.
you must now also include declaration of the Trait 'CommonIncoterm' in your class. All incoterm functions were moved into this Trait.
* The GETPOST(..., 'alpha') has now the same behaviour than GETPOST(..., 'alphanohtml') so no html will be allowed. Use GETPOST(..., 'restricthtml') to accept HTML.
* If you have links in your code with '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors.
* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of amount.
* If you have links in your code with '&action=add', '&action=update', '&action=delete' as a parameter, you must also add '&token='.newToken() as another parameter to avoid CSRF protection errors.
* The API addPayment for api_invoice has evolved to accept amount into a foreign currency. You must provide array(amount=>X,mutlicurrency_ammount=>Y) instead of simple amount.
* The method select_thirdparty(), deprecated since 3.8, into html.form.class.php has been removed.
* Depreciate all methods with name ->valide(). Use instead methods ->validate().
***** ChangeLog for 12.0.3 compared to 12.0.2 *****
FIX: 10.0 - when the mime file name is different from the filesystem name, the attachment name should be the mime filename
@ -383,28 +600,28 @@ Following changes may create regressions for some external modules, but were nec
* Default mode for GETPOST function is now 'alphanohtml' instead of 'none'. So check when you make POST or GET requests with
HTML content that you make a GETPOST('myparam', 'restricthtml') or GETPOST('myparam', 'none') if you really need posted content without sanitizing
the HTML code of content (in such a case, sanitize data later)
* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless.
* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced
by a "_" automatically when a reference (with a custom numbering mask that use it) is generated.
* Removed hidden constant MAIN_EXTRAFIELDS_IN_ONE_TD that was useless.
* Reference of object including a "/" are no more allowed. It is never used by default but to support setup that introduced it, the "/" will be replaced
by a "_" automatically when a reference (with a custom numbering mask that use it) is generated.
* Library jflot (replace with chartjs) was removed.
* Library geoip (replaced with geoip2) was removed.
* Library geoip (replaced with geoip2) was removed.
* Hidden constant COMMANDE_VALID_AFTER_CLOSE_PROPAL was renamed into ORDER_VALID_AFTER_CLOSE_PROPAL.
* Object field ref_int is deprecated and set to 'not used', method to fetch object by only ref_int is not supported anymore.
* UserGroup class has been refactored with new architecture. Triggers of class UserGroup are now USERGROUP_CREATE, USERGROUP_MODIFY, USERGROUP_DELETE
* A new way to navigate between pages in list is available. To use it (not mandatory), you must:
- replace line $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
- replace line $page = GETPOST('page', 'int') with $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
- remove input field in form '<input type="hidden" name="page" value="'.$page.'">';'
- add parameter $pagenavastextinput to value 1 when calling print_barre_liste()
WARNING FOR DOLIWAMP USERS ONLY:
Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings:
* DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture.
* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one.
You must make a backup of your database, make a fresh installation using the new installer and reload your backup.
Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production
solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one).
* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one.
You must make a backup of your database, make a fresh installation using the new installer and reload your backup.
Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production
solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one).
DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production.
@ -568,7 +785,7 @@ FIX: #13118
FIX: #13124
FIX: #13131
FIX: #13135
FIX: #13146
FIX: #13146
FIX: #13198
FIX: #13175
FIX: #13182
@ -635,7 +852,7 @@ FIX: Confusion between 'bank reconciled' and 'accounted'. Show both data.
FIX: Count of Stripe payment mode must take test/live into account
FIX: Creation of Stripe card from backoffice must return a clean message
FIX: CVE-201917223
FIX: CVE-201917223
FIX: CVE-201917223
FIX: CVE-2020-7994
FIX: CVE Need permission to be able to develop modules
FIX: #13053
@ -835,7 +1052,7 @@ NEW: #4301
For Developers or integrators:
NEW: Compatible with PHP 7.4
NEW: Compatible with PHP 7.4
NEW: Code for extrafields uses the new array $extrafields->attributes
NEW: Can set a filter on object linked in modulebuilder.
NEW: Can defined a position of numbering submodules for thirdparties
@ -902,9 +1119,9 @@ Following changes may create regressions for some external modules, but were nec
* Removed function dol_micro_time. Use native PHP microtime instead.
* The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE.
* The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS.
* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again.
* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'.
* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'.
* If your logo is no more visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible again.
* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'.
* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'.
* All properties 'type_libelle' were renamed into 'type_label'.
* Renamed property of thirdparty "statut_commercial" into "status_prospect_label"
* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core.
@ -1054,11 +1271,11 @@ FIX: wrong invoice id for fetchObjetctLinked
***** ChangeLog for 10.0.3 compared to 10.0.2 *****
IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.
The unit were not saved correctly in database making calculation on shipments wrong.
The unit were not saved correctly in database making calculation on shipments wrong.
Update to this version must be done if you use them and have installed version 10.0.0, 10.0.1 or 10.0.2 and set some products after installing or upgrading to one of this version.
Once update is done you must then edit (manually) the product that has bad unit to set the correct unit to have features restored.
FIX: #11702
FIX: #11702
FIX: #11861 No consistent code to manage measuring units
FIX: #11942
FIX: #12026
@ -1120,7 +1337,7 @@ FIX: wrong test
FIX: XSS
FIX: Payment from POS ware not recorded.
FIX: Can validate invoice with amount including tax of zero for the case of having a final invoice with
VAT that includes a deposit without vat.
VAT that includes a deposit without vat.
***** ChangeLog for 10.0.2 compared to 10.0.1 *****
FIX: #10460 compatibility with MariaDB 10.4
@ -1223,14 +1440,14 @@ FIX: Wrong variable. Must be PROJECT_HIDE_UNSELECTABLES
***** ChangeLog for 10.0.1 compared to 10.0.0 *****
FIX: #10930
FIX: #10984
FIX: #10984
FIX: reposition on "Build backup" button
FIX: #11400
FIX: #11412
FIX: #11460
FIX: #11460
FIX: #11463
FIX: #11466
FIX: #11492
FIX: #11492
FIX: #11498
FIX: #11505
FIX: #11506
@ -1239,7 +1456,7 @@ FIX: #11509
FIX: #11537
FIX: #11543
FIX: #11553
FIX: #11576
FIX: #11576
FIX: #11584
FIX: #11590
FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface
@ -1332,14 +1549,14 @@ FIX: wrong path sociales/index.php doesnt exist anymore
***** ChangeLog for 10.0.1 compared to 10.0.0 *****
FIX: #10930
FIX: #10984
FIX: #10984
FIX: reposition on "Build backup" button
FIX: #11400
FIX: #11412
FIX: #11460
FIX: #11460
FIX: #11463
FIX: #11466
FIX: #11492
FIX: #11492
FIX: #11498
FIX: #11505
FIX: #11506
@ -1348,7 +1565,7 @@ FIX: #11509
FIX: #11537
FIX: #11543
FIX: #11553
FIX: #11576
FIX: #11576
FIX: #11584
FIX: #11590
FIX: accounting mode must be taken from global conf, because there's no way to choose a mode with interface
@ -1517,7 +1734,7 @@ NEW: Manage account sell_intra & sell_export in page accoutancy admin default pr
NEW: Manage loan schedule.
NEW: Manage status of member types.
NEW: Mass action "create bills" for validated reception
NEW: Measuring unit are now defined into an editable dictionary. Add product size/unit into product import.
NEW: Measuring unit are now defined into an editable dictionary. Add product size/unit into product import.
NEW: Template pdf 'canelle_reception' displays linked reception lines.
NEW: Moral/physic status can be defined at member type level
NEW: Pagination into list of time spent.
@ -1580,7 +1797,7 @@ NEW: Enhance management of webhooks
NEW: Generation of doc by modulebuilder can include README and CHANGELOG
NEW: massfilesarea feature is possible for external modules
NEW: Show list of enabled modules in dol_print_error().
NEW: Simplification of CSS styles of default themes.
NEW: Simplification of CSS styles of default themes.
NEW: Clean code of a lot of deprecated code.
NEW: Add hidden option to set a search entry to the top
NEW: add hidden option DISPLAY_DISCOUNTED_SUPPLIER_PRICE
@ -1600,8 +1817,8 @@ Following changes may create regressions for some external modules, but were nec
* The PHP extension php-intl is not mandatory and must be installed to have new features working correctly.
* Method GetUrlTrackingStatus were renamed into getUrlTrackingStatus for consistency with naming rules.
* API getListOfCivility has been renamed into getListOfCivilities for consistency with naming rules.
* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.;
* Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming
* Deprecated function img_phone as been removed. You can use img_picto(..., 'call|call_out') instead.;
* Files for variables of themes were renamed from graph-color.php into theme_vars.inc.php to match naming
convention of extension .inc.php for files to be included.
* All methods set_draft() were renamed into setDraft().
* Signatures of methods createFromClone() has been standardized. All methods requires the object User as first parameter.
@ -1613,7 +1830,7 @@ Following changes may create regressions for some external modules, but were nec
* Deprecated property ->fk_departement is now ->state_id everywhere.
* Removed the method 4 of GETPOST (to get $_COOKIE). It was not used and not recommanded to use in Dolibarr.
* Column llx_facture.facnumber change to llx_facture.ref
* Variable $dolibarr_main_cookie_cryptkey is no more created at install (it was not used by Dolibarr). A new variable
* Variable $dolibarr_main_cookie_cryptkey is no more created at install (it was not used by Dolibarr). A new variable
called $dolibarr_main_instance_unique_id is now generated at each installation. It will be used by some future features.
@ -3385,7 +3602,7 @@ Following changes may create regression for some external modules, but were nece
entities and to review completely the rights of the groups and the users.
* Use getEntity('xxx') instead getEntity('xxx', 1) and use getEntity('xxx', 0) instead getEntity('xxx')
* Some other change were done in the way we read permission of a user when module multicompany is enabled. You can
retreive the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
retrieve the old behavior by adding constant MULTICOMPANY_BACKWARD_COMPATIBILITY to 1.
* The hook formObjectOptions was not implemented correctly in previous version. Sometimes, you had to return output
content by doing a print into function, sometimes by returning content into "resprint". This has been fixed to follow
hook specifications so you must return output into "resprint".
@ -6131,7 +6348,7 @@ For users:
- Fix: [Bug #958] LocalTax2 for Spain fails on Suppliers
- Fix: [ bug #972 ] Auto completion contact field do not take account the min caract number before search
- Fix: [ bug #971 ] html.form.class.php select_contact with autocomplete do not exclude id from exclude array
- Fix: Expedition creation, can retreive product from other expedition
- Fix: Expedition creation, can retrieve product from other expedition
For translators:
- Update language files.

View File

@ -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, ...).
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg)
![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENCE

View File

@ -2,6 +2,8 @@
![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg)
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg?style=flat-square)](https://php.net/)
[![GitHub release](https://img.shields.io/github/v/release/Dolibarr/dolibarr)](https://github.com/Dolibarr/dolibarr)
Dolibarr ERP & CRM is a modern software package that helps manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…).
@ -13,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)
![ScreenShot](https://www.dolibarr.org/images/dolibarr_screenshot1_1920x1080.jpg)
![ScreenShot](https://www.dolibarr.org/medias/dolibarr_screenshot1_1920x1080.jpg)
## LICENSE

View File

@ -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';

View File

@ -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

View File

@ -20,6 +20,9 @@ RUN apt-get update -y \
unzip \
curl \
apt-utils \
msmtp \
msmtp-mta \
mailutils \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \
@ -44,7 +47,17 @@ RUN echo 'xdebug.remote_port=9000' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_connect_back=1' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.profiler_enable=0' >> ${PHP_INI_DIR}/php.ini
RUN echo 'xdebug.remote_log="/tmp/xdebug.log"' >> ${PHP_INI_DIR}/php.ini
#RUN echo '172.17.0.1 docker.host' >> /etc/hosts
#RUN echo 'localhost docker.host' >> /etc/hosts
# set up sendmail config, to use maildev
RUN echo "account default" > /etc/msmtprc
RUN echo "auth off" >> /etc/msmtprc
RUN echo "port 25" >> /etc/msmtprc
RUN echo "host mail" >> /etc/msmtprc
RUN echo "from local@localdomain.com" >> /etc/msmtprc
RUN echo "domain localhost.localdomain" >> /etc/msmtprc
RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/php-sendmail.ini
RUN echo "localhost localhost.localdomain" >> /etc/hosts
EXPOSE 80

View File

@ -16,7 +16,7 @@ And then, you can run :
docker-compose up
This will run 3 container Docker : Dolibarr, MariaDB and PhpMyAdmin.
This will run 4 containers Docker : Dolibarr, MariaDB, PhpMyAdmin and MailDev.
The URL to go to the Dolibarr is :
@ -25,7 +25,10 @@ The URL to go to the Dolibarr is :
The URL to go to PhpMyAdmin is (login/password is root/root) :
http://0.0.0.0:8080
In Dolibarr configuration Email let PHP mail function, To see all mail send by Dolibarr go to maildev
Setup the database connection during the installation process, please use mariad
b (name of the database container) as database host.
http://0.0.0.0:8081
Setup the database connection during the installation process, please use mariadb (name of the database container) as database host.
Setup documents folder, during the installation process, to /var/documents

View File

@ -52,3 +52,6 @@ services:
ports:
- "8081:80"
- "25:25"
networks:
- internal-pod
- external-pod

View File

@ -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='';
?>

View File

@ -181,6 +181,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/datapolicy
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/debugbar
%_datadir/dolibarr/htdocs/delivery
%_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/emailcollector
@ -198,7 +199,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/install
%_datadir/dolibarr/htdocs/intracommreport
%_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt
%_datadir/dolibarr/htdocs/livraison
%_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin

View File

@ -261,6 +261,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/datapolicy
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/debugbar
%_datadir/dolibarr/htdocs/delivery
%_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/emailcollector
@ -278,7 +279,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/install
%_datadir/dolibarr/htdocs/intracommreport
%_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt
%_datadir/dolibarr/htdocs/livraison
%_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin

View File

@ -177,6 +177,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/custom
%_datadir/dolibarr/htdocs/datapolicy
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/delivery
%_datadir/dolibarr/htdocs/debugbar
%_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm
@ -195,7 +196,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/install
%_datadir/dolibarr/htdocs/intracommreport
%_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt
%_datadir/dolibarr/htdocs/livraison
%_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin

View File

@ -189,6 +189,7 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/datapolicy
%_datadir/dolibarr/htdocs/dav
%_datadir/dolibarr/htdocs/debugbar
%_datadir/dolibarr/htdocs/delivery
%_datadir/dolibarr/htdocs/don
%_datadir/dolibarr/htdocs/ecm
%_datadir/dolibarr/htdocs/emailcollector
@ -206,7 +207,6 @@ done >>%{name}.lang
%_datadir/dolibarr/htdocs/install
%_datadir/dolibarr/htdocs/intracommreport
%_datadir/dolibarr/htdocs/langs/HOWTO-Translation.txt
%_datadir/dolibarr/htdocs/livraison
%_datadir/dolibarr/htdocs/loan
%_datadir/dolibarr/htdocs/mailmanspip
%_datadir/dolibarr/htdocs/margin

View File

@ -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';

View File

@ -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

View File

@ -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';

View File

@ -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';

View File

@ -0,0 +1,21 @@
# EditorConfig is awesome: https://editorconfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
[*.js]
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = false

View File

@ -5,3 +5,4 @@ node_modules
.environment
.env
.zapierapprc
package-lock.json

View File

@ -0,0 +1,68 @@
# HOW TO BUILD
## 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/)
## INSTALL ZAPIER COMMAND LINE TOOLS WITH LINK TO ZAPIER ONLINE ACCOUNT
### Install Node.js
An easy option to get set up with Node.js is to visit [https://nodejs.org/en/download/](https://nodejs.org/en/download/) and download the official installer for your OS. If you're installing with a package manager it's even easier.
After installation, confirm that Node.js is ready to use:
`node --version`
### Install the Zapier CLI
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/examples/zapier`
`npm install -g zapier-platform-cli` to install the CLI globally
`zapier --version` to return version of the CLI
### Run Zapier Login
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 login`
This command will set up a .zapierrc file in your home directory.
### Install the Project
In zapier example directory, run:
`cd dev/examples/zapier`
`npm install`
### Deploying your App
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`
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.

View File

@ -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],
};

View File

@ -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'}
]

View File

@ -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!

View File

@ -1,405 +0,0 @@
{
"name": "Dolibarr",
"version": "1.0.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/node": {
"version": "8.10.20",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.20.tgz",
"integrity": "sha512-M7x8+5D1k/CuA6jhiwuSCmE8sbUWJF0wYsjcig9WrXvwUI5ArEoUBdOXpV4JcEMrLp02/QbDjw+kI+vQeKyQgg==",
"optional": true
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
},
"bluebird": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
"integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"commander": {
"version": "2.15.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
"integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
"dev": true
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
},
"content-disposition": {
"version": "0.5.2",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
"integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ="
},
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"dotenv": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz",
"integrity": "sha512-4As8uPrjfwb7VXC+WnLCbXK7y+Ueb2B3zgNCePYfhxS1PYeaO1YTeplffTEcbfLhvFNGLAz90VvJs9yomG7bow=="
},
"encoding": {
"version": "0.1.12",
"resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz",
"integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=",
"requires": {
"iconv-lite": "~0.4.13"
}
},
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
"dev": true
},
"form-data": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "1.0.6",
"mime-types": "^2.1.12"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
"dev": true
},
"glob": {
"version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
"dev": true,
"requires": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
}
},
"growl": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
"integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
"dev": true
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
"dev": true
},
"he": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
"dev": true
},
"iconv-lite": {
"version": "0.4.24",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
"dev": true,
"requires": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
"dev": true
},
"is-stream": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
},
"json-tryparse": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/json-tryparse/-/json-tryparse-1.0.5.tgz",
"integrity": "sha1-Khy6CLTjEjNo+p+2o01GQwBFeyc="
},
"jsonschema": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.1.1.tgz",
"integrity": "sha1-PO3o4+QR03eHLu+8n98mODy8Ptk="
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"mime-db": {
"version": "1.38.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.38.0.tgz",
"integrity": "sha512-bqVioMFFzc2awcdJZIzR3HjZFX20QhilVS7hytkKrv7xFAn8bM1gzc/FOX2awLISvWe0PV8ptFKcon+wZ5qYkg=="
},
"mime-types": {
"version": "2.1.22",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.22.tgz",
"integrity": "sha512-aGl6TZGnhm/li6F7yx82bJiBZwgiEa4Hf6CNr8YO+r5UHr53tSTYZb102zyU50DOWWKeOv0uQLRL0/9EiKWCog==",
"requires": {
"mime-db": "~1.38.0"
}
},
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
}
},
"mocha": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
"integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
"dev": true,
"requires": {
"browser-stdout": "1.3.1",
"commander": "2.15.1",
"debug": "3.1.0",
"diff": "3.5.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.2",
"growl": "1.10.5",
"he": "1.1.1",
"minimatch": "3.0.4",
"mkdirp": "0.5.1",
"supports-color": "5.4.0"
}
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"node-fetch": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.1.tgz",
"integrity": "sha512-j8XsFGCLw79vWXkZtMSmmLaOk9z5SQ9bV/tkbZVCqvgwzrjAGq66igobLofHtF63NvMTp2WjytpsNTGKa+XRIQ==",
"requires": {
"encoding": "^0.1.11",
"is-stream": "^1.0.1"
}
},
"oauth-sign": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
"integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ=="
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"dev": true,
"requires": {
"wrappy": "1"
}
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true
},
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"semver": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg=="
},
"should": {
"version": "13.2.3",
"resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz",
"integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==",
"dev": true,
"requires": {
"should-equal": "^2.0.0",
"should-format": "^3.0.3",
"should-type": "^1.4.0",
"should-type-adaptors": "^1.0.1",
"should-util": "^1.0.0"
}
},
"should-equal": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz",
"integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==",
"dev": true,
"requires": {
"should-type": "^1.4.0"
}
},
"should-format": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz",
"integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=",
"dev": true,
"requires": {
"should-type": "^1.3.0",
"should-type-adaptors": "^1.0.1"
}
},
"should-type": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz",
"integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=",
"dev": true
},
"should-type-adaptors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz",
"integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==",
"dev": true,
"requires": {
"should-type": "^1.3.0",
"should-util": "^1.0.0"
}
},
"should-util": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.0.tgz",
"integrity": "sha1-yYzaN0qmsZDfi6h8mInCtNtiAGM=",
"dev": true
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"dev": true,
"requires": {
"has-flag": "^3.0.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"zapier-platform-core": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/zapier-platform-core/-/zapier-platform-core-8.0.1.tgz",
"integrity": "sha512-vuAe7JkFQ88AeQ//NwwNEh8ZjiZr30GRWtwYo7Wo/nx1cqZwq+CRc9zJU2WRrhJfJOtOOTUF6w+pArBTtMOC5A==",
"requires": {
"@types/node": "8.10.20",
"bluebird": "3.5.0",
"content-disposition": "0.5.2",
"dotenv": "5.0.1",
"form-data": "2.3.2",
"lodash": "4.17.11",
"node-fetch": "1.7.1",
"oauth-sign": "0.9.0",
"semver": "5.6.0",
"zapier-platform-schema": "8.0.1"
}
},
"zapier-platform-schema": {
"version": "8.0.1",
"resolved": "https://registry.npmjs.org/zapier-platform-schema/-/zapier-platform-schema-8.0.1.tgz",
"integrity": "sha512-97KJ0xVLtpU4BiXVaMTPQpiA0T6CQIEzWfzAWwJAWbu5336+6DMFUzDWN4bANBeD3CIsRHHPcZkP8n/17U05ag==",
"requires": {
"jsonschema": "1.1.1",
"lodash": "4.17.10"
},
"dependencies": {
"lodash": {
"version": "4.17.10",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz",
"integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg=="
}
}
}
}
}

View File

@ -1,9 +1,9 @@
{
"name": "Dolibarr",
"version": "1.0.0",
"name": "dolibarr",
"version": "1.13.0",
"description": "An app for connecting Dolibarr to the Zapier platform.",
"repository": "Dolibarr/dolibarr",
"homepage": "https://www.dolibarr.fr/",
"homepage": "https://www.dolibarr.org/",
"author": "Frédéric France <frederic.france@netlogic.fr>",
"license": "BSD-3-Clause",
"main": "index.js",
@ -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",

View File

@ -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'
}
]
}
};

View File

@ -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'
}
]
}
};

View File

@ -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'}
]

View File

@ -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'},

View File

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

View File

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

View File

@ -120,8 +120,8 @@ $sqls=array(
"DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'",
),
'delivery'=>array(
"DELETE FROM ".MAIN_DB_PREFIX."livraisondet WHERE fk_livraison IN (select rowid FROM ".MAIN_DB_PREFIX."livraison where date_creation < '__DATE__')",
"DELETE FROM ".MAIN_DB_PREFIX."livraison where date_creation < '__DATE__'",
"DELETE FROM ".MAIN_DB_PREFIX."deliverydet WHERE fk_delivery IN (select rowid FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__')",
"DELETE FROM ".MAIN_DB_PREFIX."delivery where date_creation < '__DATE__'",
),
'contract'=>array(
"DELETE FROM ".MAIN_DB_PREFIX."contratdet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__'))",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,6 +17,7 @@
<exclude-pattern type="relative">*/nltechno*</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">*/htdocs/includes</exclude-pattern>
<exclude-pattern type="relative">.git</exclude-pattern>
<!-- List of all tests -->

View File

@ -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/

View File

@ -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']++;

View File

@ -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;

View File

@ -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) {
@ -210,7 +210,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -252,7 +252,7 @@ if ($action == 'create') {
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
@ -272,7 +272,7 @@ if ($action == 'create') {
// Edit mode
if ($action == 'update')
{
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -314,7 +314,7 @@ if ($action == 'create') {
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
@ -327,7 +327,7 @@ if ($action == 'create') {
// View mode
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/account.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), -1, 'billr');
dol_banner_tab($object, 'ref', $linkback, 1, 'account_number', 'ref');
@ -364,7 +364,7 @@ if ($action == 'create') {
print '</div>';
dol_fiche_end();
print dol_get_fiche_end();
/*
* Actions buttons

View File

@ -102,7 +102,7 @@ print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="display">';
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -146,7 +146,7 @@ if (!empty($cat_id))
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '</form>';

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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>';
}

View File

@ -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');

View File

@ -159,7 +159,7 @@ if ($action == 'create')
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -187,7 +187,7 @@ if ($action == 'create')
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
@ -202,7 +202,7 @@ if ($action == 'create')
$head = fiscalyear_prepare_head($object);
if ($action == 'edit') {
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -248,7 +248,7 @@ if ($action == 'create')
print '</form>';
dol_fiche_end();
print dol_get_fiche_end();
} else {
/*
* Confirm delete
@ -257,7 +257,7 @@ if ($action == 'create')
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id, $langs->trans("DeleteFiscalYear"), $langs->trans("ConfirmDeleteFiscalYear"), "confirm_delete");
}
dol_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print dol_get_fiche_head($head, 'card', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table class="border centpercent">';
@ -296,7 +296,7 @@ if ($action == 'create')
print "</table>";
dol_fiche_end();
print dol_get_fiche_end();
if (!empty($user->rights->accounting->fiscalyear->write))
{

View File

@ -49,7 +49,7 @@ if ($id) {
$head = fiscalyear_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron');
print dol_get_fiche_head($head, 'info', $langs->trans("Fiscalyear"), 0, 'cron');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);

View File

@ -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;

View File

@ -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();
});

View File

@ -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">&nbsp;</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>';
}

View File

@ -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;

View File

@ -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);
@ -351,7 +351,7 @@ if ($action == 'create')
print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
print '<input type="hidden" name="mode" value="_tmp">'."\n";
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -386,7 +386,7 @@ if ($action == 'create')
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
@ -415,7 +415,7 @@ if ($action == 'create')
$head[$h][2] = 'transaction';
$h++;
dol_fiche_head($head, 'transaction', '', -1);
print dol_get_fiche_head($head, 'transaction', '', -1);
//dol_banner_tab($object, '', $backlink);
@ -573,7 +573,7 @@ if ($action == 'create')
print '</div></div><!-ee-->';
dol_fiche_end();
print dol_get_fiche_end();
print '<div style="clear:both"></div>';
@ -719,7 +719,7 @@ if ($action == 'create')
}
}
dol_fiche_end();
print dol_get_fiche_end();
// End of page
llxFooter();

View File

@ -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>';

View File

@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// 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 .= ' &nbsp; ';
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', './card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=create');
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($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);

View File

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

View File

@ -135,13 +135,13 @@ $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company');
print dol_get_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_fiche_end();
print dol_get_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
@ -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);

View File

@ -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');
@ -134,13 +134,13 @@ $head = societe_prepare_head($object);
dol_htmloutput_mesg(is_numeric($error) ? '' : $error, $errors, 'error');
dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company');
print dol_get_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'company');
$linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
dol_fiche_end();
print dol_get_fiche_end();
$sql = "SELECT bk.rowid, bk.doc_date, bk.doc_type, bk.doc_ref, ";
$sql .= " bk.subledger_account, bk.numero_compte , bk.label_compte, bk.debit, ";
@ -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);

View File

@ -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++;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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,28 +446,29 @@ 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, $user;
global $langs, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
$url = '';
if (empty($option) || $option == 'ledger') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
$url = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number);
$labelurl = $langs->trans("ShowAccountingAccountInLedger");
} elseif ($option == 'journals') {
$url = DOL_URL_ROOT . '/accountancy/bookkeeping/list.php?search_accountancy_code_start=' . $this->account_number . '&search_accountancy_code_end=' . $this->account_number;
$url = DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?search_accountancy_code_start='.urlencode($this->account_number).'&search_accountancy_code_end='.urlencode($this->account_number);
$labelurl = $langs->trans("ShowAccountingAccountInJournals");
} elseif ($option == 'accountcard') {
$url = DOL_URL_ROOT . '/accountancy/admin/card.php?id=' . $this->id;
$url = DOL_URL_ROOT.'/accountancy/admin/card.php?id='.urlencode($this->id);
$labelurl = $langs->trans("ShowAccountingAccount");
}
@ -523,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
@ -531,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;
@ -567,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();
@ -603,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'";
@ -630,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;
}
}
}
}
/**
@ -652,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
*
@ -662,7 +663,7 @@ class AccountingAccount extends CommonObject
*/
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
// phpcs:enable
global $langs;
$langs->loadLangs(array("users"));

View File

@ -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"));

View File

@ -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;
}
@ -1530,14 +1537,14 @@ class BookKeeping extends CommonObject
$this->label_compte = 'Customer';
$this->label_operation = 'Sales of pea';
$this->debit = 99.9;
$this->credit = '';
$this->montant = '';
$this->credit = 0.0;
$this->amount = 0.0;
$this->sens = 'D';
$this->fk_user_author = $user->id;
$this->import_key = '';
$this->import_key = '20201027';
$this->code_journal = 'VT';
$this->journal_label = 'Journal de vente';
$this->piece_num = '';
$this->piece_num = 1234;
$this->date_creation = $now;
}

View File

@ -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>';
}

View File

@ -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");
@ -119,7 +119,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('CustomersVentilation'), '', 'title_accountancy');
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -137,7 +137,7 @@ if (!empty($id)) {
print '</td></tr>';
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';

View File

@ -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 = '';

View File

@ -121,7 +121,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('ExpenseReportsVentilation'), '', 'title_accountancy');
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -146,7 +146,7 @@ if (!empty($id)) {
print '</td></tr>';
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';

View File

@ -166,7 +166,7 @@ print '<script type="text/javascript">
$sql = "SELECT er.ref, er.rowid as erid,";
$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht, erd.fk_code_ventilation, erd.tva_tx, erd.vat_src_code, erd.date,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label,";
$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " aa.label, aa.labelshort, aa.account_number";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
@ -311,7 +311,7 @@ if ($result) {
$expensereportstatic->ref = $objp->ref;
$expensereportstatic->id = $objp->erid;
$userstatic->id = $objp->rowid;
$userstatic->id = $objp->userid;
$userstatic->ref = $objp->label;
$userstatic->login = $objp->login;
$userstatic->statut = $objp->statut;

View File

@ -190,7 +190,7 @@ if (empty($chartaccountcode))
$sql = "SELECT er.ref, er.rowid as erid, er.date_debut, er.date_valid,";
$sql .= " erd.rowid, erd.fk_c_type_fees, erd.comments, erd.total_ht as price, erd.fk_code_ventilation, erd.tva_tx as tva_tx_line, erd.vat_src_code, erd.date,";
$sql .= " f.id as type_fees_id, f.code as type_fees_code, f.label as type_fees_label, f.accountancy_code as code_buy,";
$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " u.rowid as userid, u.login, u.lastname, u.firstname, u.email, u.gender, u.employee, u.photo, u.statut,";
$sql .= " aa.rowid as aarowid";
$sql .= " FROM ".MAIN_DB_PREFIX."expensereport as er";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."expensereport_det as erd ON er.rowid = erd.fk_expensereport";
@ -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 = '';
@ -356,7 +350,7 @@ if ($result) {
$expensereport_static->ref = $objp->ref;
$expensereport_static->id = $objp->erid;
$userstatic->id = $objp->rowid;
$userstatic->id = $objp->userid;
$userstatic->ref = $objp->label;
$userstatic->login = $objp->login;
$userstatic->statut = $objp->statut;

View File

@ -45,14 +45,14 @@ $hookmanager->initHooks(array('accountancyindex'));
if (GETPOST('addbox')) // Add box (when submit is done from a form when ajax disabled)
{
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";
}

View File

@ -339,7 +339,7 @@ if ($result) {
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
// Retreive the accounting code of the social contribution of the payment from link of payment.
// Retrieve the accounting code of the social contribution of the payment from link of payment.
// Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
$sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
@ -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')

View File

@ -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;

View File

@ -669,7 +669,7 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
print '""'.$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;

View File

@ -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;

View File

@ -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");
@ -121,7 +121,7 @@ if (!empty($id)) {
print load_fiche_titre($langs->trans('SuppliersVentilation'), '', 'title_accountancy');
dol_fiche_head();
print dol_get_fiche_head();
print '<table class="border centpercent">';
@ -141,7 +141,7 @@ if (!empty($id)) {
print '</td></tr>';
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';

View File

@ -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 = '';

View File

@ -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();
}
}
@ -132,7 +180,7 @@ print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
$head = member_admin_prepare_head();
dol_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user');
print dol_get_fiche_head($head, 'general', $langs->trans("Members"), -1, 'user');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">';
@ -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,8 +293,139 @@ $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']);
dol_fiche_end();
// Defini tableau def des modeles
$def = array();
$sql = "SELECT nom";
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
$sql .= " WHERE type = '".$db->escape($type)."'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$num_rows = $db->num_rows($resql);
while ($i < $num_rows) {
$array = $db->fetch_array($resql);
array_push($def, $array[0]);
$i++;
}
} else {
dol_print_error($db);
}
print load_fiche_titre($langs->trans("MembersDocModules"), '', '');
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Description").'</td>';
print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
print "</tr>\n";
clearstatcache();
foreach ($dirmodels as $reldir) {
foreach (array('', '/doc') as $valdir) {
$dir = dol_buildpath($reldir."core/modules/member".$valdir);
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false) {
$filelist[] = $file;
}
closedir($handle);
arsort($filelist);
foreach ($filelist as $file) {
if (preg_match('/\.class\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
if (file_exists($dir.'/'.$file)) {
$name = substr($file, 4, dol_strlen($file) - 14);
$classname = substr($file, 0, dol_strlen($file) - 10);
require_once $dir.'/'.$file;
$module = new $classname($db);
$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
$modulequalified = 0;
}
if ($modulequalified) {
print '<tr class="oddeven"><td width="100">';
print (empty($module->name) ? $name : $module->name);
print "</td><td>\n";
if (method_exists($module, 'info')) {
print $module->info($langs);
} else {
print $module->description;
}
print '</td>';
// Active
if (in_array($name, $def)) {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del_default&amp;token='.newToken().'&amp;value='.$name.'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
print '</td>';
} else {
print '<td class="center">'."\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set_default&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print "</td>";
}
// Defaut
print '<td class="center">';
if ($conf->global->MEMBER_ADDON_PDF == $name) {
print img_picto($langs->trans("Default"), 'on');
} else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';
// Info
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
if ($module->type == 'pdf') {
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
}
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
print '</td>';
// Preview
print '<td class="center">';
if ($module->type == 'pdf')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
} else {
print img_object($langs->trans("PreviewNotAvailable"), 'generic');
}
print '</td>';
print "</tr>\n";
}
}
}
}
}
}
}
}
print '</table>';
print "<br>";
print dol_get_fiche_end();
// End of page
llxFooter();

View File

@ -119,7 +119,7 @@ print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
$head = member_admin_prepare_head();
dol_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
print dol_get_fiche_head($head, 'emails', $langs->trans("Members"), -1, 'user');
// TODO Use global form
//print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
@ -136,7 +136,7 @@ form_constantes($constantes, 0, $helptext);
//print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("Update").'" name="update"></div>';
//print '</form>';
dol_fiche_end();
print dol_get_fiche_end();
// End of page
llxFooter();

View File

@ -70,11 +70,11 @@ print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
$head = member_admin_prepare_head();
dol_fiche_head($head, 'attributes', $langs->trans("Members"), -1, 'user');
print dol_get_fiche_head($head, 'attributes', $langs->trans("Members"), -1, 'user');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
print dol_get_fiche_end();
// Buttons
@ -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

View File

@ -73,11 +73,11 @@ print load_fiche_titre($langs->trans("MembersSetup"), $linkback, 'title_setup');
$head = member_admin_prepare_head();
dol_fiche_head($head, 'attributes_type', $langs->trans("Members"), -1, 'user');
print dol_get_fiche_head($head, 'attributes_type', $langs->trans("Members"), -1, 'user');
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
dol_fiche_end();
print dol_get_fiche_end();
// Buttons

View File

@ -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');
}
}
@ -94,11 +94,11 @@ print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="token" value="'.newToken().'">';
dol_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
print dol_get_fiche_head($head, 'website', $langs->trans("Members"), -1, 'user');
if ($conf->use_javascript_ajax) {
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";
}
@ -208,7 +208,7 @@ if (!empty($conf->global->MEMBER_ENABLE_PUBLIC)) {
}
dol_fiche_end();
print dol_get_fiche_end();
print '</form>';

View File

@ -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 = '';
}
}
@ -118,7 +118,7 @@ if ($object->id > 0) {
if (!empty($conf->notification->enabled)) $langs->load("mails");
$head = member_prepare_head($object);
dol_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
print dol_get_fiche_head($head, 'agenda', $langs->trans("Member"), -1, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -133,34 +133,34 @@ if ($object->id > 0) {
print '</div>';
dol_fiche_end();
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

View File

@ -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.'&nbsp;' : '');
$this->tpl['zip'] = ($this->object->zip ? $this->object->zip.'&nbsp;' : '');
$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);
}
}
}
}

View File

@ -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();
}
}

View File

@ -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'].'&amp;action=edit&amp;canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
}
if ($user->rights->adherent->creer) {
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=edit&amp;canvas='.$canvas.'">'.$langs->trans('Modify').'</a>';
}
if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=create_user&amp;canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
}
if (!$this->control->tpl['user_id'] && $user->rights->user->user->creer) {
echo '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=create_user&amp;canvas='.$canvas.'">'.$langs->trans("CreateDolibarrLogin").'</a>';
}
if ($user->rights->adherent->supprimer) {
echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=delete&amp;canvas='.$canvas.'">'.$langs->trans('Delete').'</a>';
}
if ($user->rights->adherent->supprimer) {
echo '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&amp;action=delete&amp;canvas='.$canvas.'">'.$langs->trans('Delete').'</a>';
}
echo '</div><br>';
echo '</div><br>';
}
echo $this->control->tpl['actionstodo'];

View File

@ -4,9 +4,9 @@
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2012-2018 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012-2020 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2015-2018 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 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'));
}
@ -833,7 +836,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<input type="hidden" name="socid" value="'.$socid.'">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
dol_fiche_head('');
print dol_get_fiche_head('');
print '<table class="border centpercent">';
print '<tbody>';
@ -969,7 +972,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tbody>';
print "</table>\n";
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" name="button" class="button" value="'.$langs->trans("AddMember").'">';
@ -1058,7 +1061,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<input type="hidden" name="statut" value="'.$object->statut.'" />';
if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
dol_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
print dol_get_fiche_head($head, 'general', $langs->trans("Member"), 0, 'user');
print '<table class="border centpercent">';
@ -1229,7 +1232,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
print '</table>';
dol_fiche_end();
print dol_get_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
@ -1268,11 +1271,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
*/
$head = member_prepare_head($object);
dol_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
print dol_get_fiche_head($head, 'general', $langs->trans("Member"), -1, 'user');
// 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");
}
@ -1608,7 +1613,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print "</div></div></div>\n";
print '<div style="clear:both"></div>';
dol_fiche_end();
print dol_get_fiche_end();
/*
@ -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>';

View File

@ -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;
}
}

View File

@ -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,8 +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 = ucwords(trim($this->lastname));
if (!empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname = ucwords(trim($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);
@ -1320,7 +1350,7 @@ class Adherent extends CommonObject
$this->model_pdf = $obj->model_pdf;
// Retreive all extrafield
// Retrieve all extrafield
// fetch optionals attributes and labels
if ($fetch_optionals) {
$this->fetch_optionals();
@ -1983,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;
@ -2275,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';
@ -2299,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;
@ -2325,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;
}
@ -2364,6 +2404,7 @@ class Adherent extends CommonObject
global $conf, $langs;
$info = array();
$socialnetworks = getArrayOfSocialNetworks();
$keymodified = false;
// Object classes
@ -2378,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) {
@ -2399,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;
@ -2415,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)) {

View File

@ -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;

View File

@ -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);
}

View File

@ -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) {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}
}

View File

@ -86,7 +86,7 @@ $helpurl = "EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;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 +95,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);
dol_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
print dol_get_fiche_head($head, 'document', $langs->trans("Member"), -1, 'user');
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/adherents/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'rowid', $linkback);
dol_banner_tab($object, 'rowid', $linkback);
print '<div class="fichecenter">';
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield centpercent">';
$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.'&nbsp;</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.'&nbsp;</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().'&nbsp;</td>';
print '</tr>';
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$object->getCivilityLabel().'&nbsp;</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
@ -145,7 +145,7 @@ if ($id > 0) {
print '</div>';
dol_fiche_end();
print dol_get_fiche_end();
$modulepart = 'member';
$permission = $user->rights->adherent->creer;
@ -157,7 +157,7 @@ if ($id > 0) {
dol_print_error($db);
}
} else {
$langs->load("errors");
$langs->load("errors");
print $langs->trans("ErrorRecordNotFound");
}

View File

@ -125,29 +125,29 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
// 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,9 +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 .= " a.tms as datem, datefin as date_end_subscription,";
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
$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, 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";
@ -305,10 +306,18 @@ 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;
$staticmember->firstname = $obj->firstname;
$staticmember->gender = $obj->gender;
$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();
@ -316,13 +325,16 @@ if ($resql) {
} else {
$staticmember->name = $obj->company;
}
$staticmember->ref = $staticmember->getFullName($langs);
$statictype->id = $obj->typeid;
$statictype->label = $obj->label;
print '<td class="nowraponall">'.$staticmember->getNomUrl(1, 32).'</td>';
$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++;
}
@ -339,11 +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 .= " datefin as date_end_subscription,";
$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);
@ -360,12 +375,18 @@ 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;
$staticmember->firstname = $obj->firstname;
$staticmember->gender = $obj->gender;
$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();
@ -373,9 +394,13 @@ if ($resql) {
} else {
$staticmember->name = $obj->company;
}
$staticmember->ref = $staticmember->getFullName($langs);
$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">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>';
print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';
print '<td class="right">'.price($obj->subscription).'</td>';
//print '<td class="right">'.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';

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