merge confilct
This commit is contained in:
commit
93c86d077a
15
.gitattributes
vendored
15
.gitattributes
vendored
@ -11,26 +11,31 @@
|
||||
*.htm text eol=lf
|
||||
*.html text eol=lf
|
||||
*.js text eol=lf
|
||||
*.json text eol=lf
|
||||
*.css text eol=lf
|
||||
*.lang text eol=lf
|
||||
*.txt text eol=lf
|
||||
*.md text eol=lf
|
||||
*.pp text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.yml text eol=lf
|
||||
*.yaml text eol=lf
|
||||
*.conf text eol=lf
|
||||
|
||||
.bash_aliases text eol=lf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.bmp binary
|
||||
*.ico binary
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.odt binary
|
||||
*.odf binary
|
||||
*.frm binary
|
||||
*.ico binary
|
||||
*.jpeg binary
|
||||
*.jpg binary
|
||||
*.MYD binary
|
||||
*.MYI binary
|
||||
*.odf binary
|
||||
*.odt binary
|
||||
*.png binary
|
||||
|
||||
|
||||
# Export ignores to generate clean production tarballs
|
||||
/build export-ignore
|
||||
|
||||
6
.github/CODE_OF_CONDUCT.md
vendored
6
.github/CODE_OF_CONDUCT.md
vendored
@ -77,8 +77,8 @@ contact@dolibarr.org
|
||||
|
||||
## 10. License and attribution
|
||||
|
||||
This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/).
|
||||
This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](https://creativecommons.org/licenses/by-sa/3.0/).
|
||||
|
||||
Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).
|
||||
Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](https://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy).
|
||||
|
||||
Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/)
|
||||
Retrieved on November 22, 2016 from [https://citizencodeofconduct.org/](http://citizencodeofconduct.org/)
|
||||
|
||||
10
.github/CONTRIBUTING.md
vendored
10
.github/CONTRIBUTING.md
vendored
@ -4,15 +4,17 @@ How to contribute to Dolibarr
|
||||
Bug reports and feature requests
|
||||
--------------------------------
|
||||
|
||||
<a name="not-a-support-forum"></a>*Note*: Issues are not a support forum. If you need help using the software, please use [the forums](https://www.dolibarr.org/forum.php). Forums exist in different languages.
|
||||
<a name="not-a-support-forum"></a>*Note*: **GitHub Issues is not a support forum.** If you have questions about Dolibarr / need help using the software, please use [the forums](https://www.dolibarr.org/forum.php). Forums exist in different languages.
|
||||
|
||||
Issues are managed on [GitHub](https://github.com/Dolibarr/dolibarr/issues).
|
||||
Default language here is english. So please prepare your contributions in english.
|
||||
Default **language here is english**. So please prepare your contributions in english.
|
||||
|
||||
1. Please [use the search engine](https://help.github.com/articles/searching-issues) to check if nobody's already reported your problem.
|
||||
2. [Create an issue](https://help.github.com/articles/creating-an-issue). Choose an appropriate title. Prepend appropriately with Bug or Feature Request.
|
||||
4. Tell us the version you are using! (look at /htdocs/admin/system/dolibarr.php? and check if you are using the latest version)
|
||||
3. Write a report with as much detail as possible (Use [screenshots](https://help.github.com/articles/issue-attachments) or even screencasts and provide logging and debugging informations whenever possible).
|
||||
3. Tell us the version you are using! (look at /htdocs/admin/system/dolibarr.php? and check if you are using the latest version)
|
||||
4. Write a report with as much detail as possible (Use [screenshots](https://help.github.com/articles/issue-attachments) or even screencasts and provide logging and debugging informations whenever possible).
|
||||
5. Delete unnecessary submissions.
|
||||
6. **Check your Message at Preview before sending.**
|
||||
|
||||
|
||||
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,6 +16,7 @@ default.properties
|
||||
.DS_Store
|
||||
.idea
|
||||
*.iml
|
||||
*.orig
|
||||
Thumbs.db
|
||||
/dolibarr_genesis.mp4
|
||||
# Log files
|
||||
|
||||
28
.travis.yml
28
.travis.yml
@ -1,6 +1,6 @@
|
||||
# This script is used by Travis CI to run automatically Continuous test integration
|
||||
# from Dolibarr GitHub repository.
|
||||
# For syntax, see http://about.travis-ci.org/docs/user/languages/php/
|
||||
# For syntax, see https://docs.travis-ci.com/user/languages/php/
|
||||
|
||||
# We use dist: xenial to have php 5.6+ available
|
||||
os: linux
|
||||
@ -38,8 +38,8 @@ env:
|
||||
|
||||
jobs:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- php: nightly
|
||||
#allow_failures:
|
||||
#- php: nightly
|
||||
include:
|
||||
- if: type = push
|
||||
php: '5.6'
|
||||
@ -50,6 +50,9 @@ jobs:
|
||||
- if: type = push AND branch = develop
|
||||
php: nightly
|
||||
env: DB=mysql
|
||||
- if: type = push AND branch = 14.0
|
||||
php: nightly
|
||||
env: DB=mysql
|
||||
|
||||
notifications:
|
||||
email:
|
||||
@ -70,13 +73,6 @@ before_install:
|
||||
phpenv config-rm xdebug.ini
|
||||
echo
|
||||
|
||||
- |
|
||||
if [ "$DB" = 'postgresql' ]; then
|
||||
echo "Check pgloader version"
|
||||
pgloader --version
|
||||
echo
|
||||
fi
|
||||
|
||||
install:
|
||||
- |
|
||||
echo "Updating Composer"
|
||||
@ -175,6 +171,10 @@ before_script:
|
||||
mysql --version | head -
|
||||
mysql -e "SELECT VERSION();" | head -
|
||||
psql --version
|
||||
if [ "$DB" = 'postgresql' ]; then
|
||||
echo "Check pgloader version"
|
||||
pgloader --version
|
||||
fi
|
||||
echo
|
||||
|
||||
- |
|
||||
@ -398,10 +398,14 @@ script:
|
||||
php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log
|
||||
php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log
|
||||
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
|
||||
php upgrade.php 13.0.0 14.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade13001400.log
|
||||
php upgrade2.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-2.log
|
||||
php step5.php 13.0.0 14.0.0 > $TRAVIS_BUILD_DIR/upgrade13001400-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_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log
|
||||
echo $?
|
||||
cd -
|
||||
set +e
|
||||
|
||||
2
COPYING
2
COPYING
@ -1,7 +1,7 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
@ -23,16 +23,16 @@ PEAR Mail_MIME 1.8.9 BSD Yes
|
||||
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
|
||||
PHPSpreadSheet ? LGPL-2.1+ Yes Read/Write XLS files, read ODS files
|
||||
PHPSpreadSheet 1.8.2 LGPL-2.1+ Yes Read/Write XLS files, read ODS files
|
||||
php-iban 1.4.7 LGPL-3+ Yes Parse and validate IBAN (and IIBAN) bank account information in PHP
|
||||
PHPoAuthLib 0.8.2 MIT License Yes Library to provide oauth1 and oauth2 to different service
|
||||
PHPPrintIPP 1.3 GPL-2+ Yes Library to send print IPP requests
|
||||
PSR/Logs 1.0 Library for logs (used by DebugBar)
|
||||
PSR/simple-cache ? Library for cache (used by PHPSpreadSheet)
|
||||
Restler 3.0.0RC6 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
|
||||
Restler 3.1.1 LGPL-3+ Yes Library to develop REST Web services (+ swagger-ui js lib into dir explorer)
|
||||
Sabre 3.2.2 BSD Yes DAV support
|
||||
Swift Mailer 5.4.2-DEV MIT license Yes Comprehensive mailing tools for PHP
|
||||
Stripe 6.43.1 MIT licence Yes Library for Stripe module
|
||||
Stripe 7.67.0 MIT licence Yes Library for Stripe module
|
||||
TCPDF 6.3.2 LGPL-3+ Yes PDF generation
|
||||
TCPDI 1.0.0 LGPL-3+ / Apache 2.0 Yes FPDI replacement
|
||||
|
||||
|
||||
283
ChangeLog
283
ChangeLog
@ -3,11 +3,143 @@ English Dolibarr ChangeLog
|
||||
--------------------------------------------------------------
|
||||
|
||||
|
||||
***** ChangeLog for 14.0.0 compared to 13.0.0 *****
|
||||
|
||||
For users:
|
||||
----------
|
||||
NEW: Several security issues after a second private bug bounty campaign.
|
||||
|
||||
|
||||
|
||||
For developers:
|
||||
---------------
|
||||
* start new module EventOrganization
|
||||
|
||||
|
||||
|
||||
WARNING:
|
||||
|
||||
Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
|
||||
* The ICS value for direct debit or credit transfer is now store on each bank account instead of into the global setup.
|
||||
* API /setup/shipment_methods has been replaced with API /setup/shipping_methods
|
||||
* Field "total" renamed into to "total_ht" for table llx_facture, llx_facture_rec for better field name consistency
|
||||
* Field "tva" renamed into "total_tva" for table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
|
||||
* Field "total" renamed into "total_ttc" for table lx_propal, llx_supplier_proposal for better field name consistency
|
||||
* If your database is PostgreSql, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT)
|
||||
* If your database is MySql or MariaDB, you need at least version 5.1
|
||||
* Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules
|
||||
|
||||
|
||||
***** ChangeLog for 13.0.2 compared to 13.0.1 *****
|
||||
|
||||
FIX: 11.0 - $this->socid injected in query without checking for empty value
|
||||
FIX: #16096 #16085 Any call of ajax pages must provide the token
|
||||
FIX: #16296
|
||||
FIX: #16325
|
||||
FIX: #16341 : Fetch the Product ExtraFields in Shippment lines
|
||||
FIX: #16366
|
||||
FIX: #16393 Do not sanitize <!DOCTYPE html>
|
||||
FIX: #16420 #16423 #16488 #16477
|
||||
FIX: #16431
|
||||
FIX: #16465
|
||||
FIX: #16480
|
||||
FIX: #16485
|
||||
FIX: #16487
|
||||
FIX: #16503
|
||||
FIX: #16530
|
||||
FIX: #16533
|
||||
FIX: #16629
|
||||
FIX: #16671 Can not generate zip file of documents in backup tool
|
||||
FIX: Add "Now" link on social charges creation card
|
||||
FIX: avoid undefined URL and missing token
|
||||
FIX: Bad project filter in ticket list
|
||||
FIX: Buttons to disable bindings not working
|
||||
FIX: class not found when creating recuring invoice from invoice+discount
|
||||
FIX: File attachment on lots/batches
|
||||
FIX: handling $heightforinfotot when he's superior to a page height on Supplier Invoice
|
||||
FIX: hourglass and hide button to pay
|
||||
FIX: massaction validate invoice do not regenerate PDF
|
||||
FIX: missing mp4 video mime
|
||||
FIX: picto on shipment to reset qty to 0. Some quantities were not reset.
|
||||
FIX: Protection to avoid #16504
|
||||
FIX: rounding amount on card updating
|
||||
FIX: rounding amount on social charges card updating
|
||||
FIX: select list dependencies now work for ModuleBuilder sellist field
|
||||
FIX: status in popup of member in widget
|
||||
FIX: status on tooltip on widgets
|
||||
FIX: Timezone management for datetime on list of events
|
||||
FIX: Timezone management for datetime with modulebuilder and extrafields
|
||||
FIX: Total_ht not show in contract link element
|
||||
FIX: use post instead get
|
||||
FIX: use var "saved_url" instead global var "$url"
|
||||
FIX: Various payment - Missing fields for check transmitter & bank name
|
||||
FIX: warning if setup of chart of account is not yet done.
|
||||
FIX: wrong extension
|
||||
|
||||
|
||||
***** ChangeLog for 13.0.1 compared to 13.0.0 *****
|
||||
|
||||
FIX: 10.0 before crediting a withdrawal receipt, check whether it has been credited already.
|
||||
FIX: 11.0 when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion
|
||||
FIX: 11.0 when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized
|
||||
FIX: create MO, Column 'tms' cannot be null
|
||||
FIX: #14290 #15900
|
||||
FIX: #16076 patch user/list.php for extrafields
|
||||
FIX: #16077 patch wrong timezone
|
||||
FIX: #16079 error of service date at duplicated invoice
|
||||
FIX: #16080 mailing list title
|
||||
FIX: #16084 DB error at projects
|
||||
FIX: #16107
|
||||
FIX: #16118 Timezone problem on some fields
|
||||
FIX: #16131
|
||||
FIX: #16135
|
||||
FIX: #16143
|
||||
FIX: #16156
|
||||
FIX: #16160
|
||||
FIX: #16165 Create customer discount without VAT
|
||||
FIX: #16185
|
||||
FIX: #16189 fix download/see check deposit PDF
|
||||
FIX: #16215
|
||||
FIX: Accountancy - label_operation is used instead of label_compte
|
||||
FIX: Add critical price patch
|
||||
FIX: Assignement of actors on tasks
|
||||
FIX: Bad dates on info tabs
|
||||
FIX: cash fence for takepos with multientity
|
||||
FIX: CSRF errors on margin forms
|
||||
FIX: encoding status in graph of vendor proposals
|
||||
FIX: Fix detect dispached product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES)
|
||||
FIX: hide/unhide external ICS calendars
|
||||
FIX: link to create event when task is in a project with a thirdparty
|
||||
FIX: Localtax must be converted with price2num
|
||||
FIX: manage price min for PRODUIT_CUSTOMER_PRICES
|
||||
FIX: Missing language ico
|
||||
FIX: Must not be able to edit vat of all lines if not draft
|
||||
FIX: Bad "htdocs" found into a path
|
||||
FIX: removed no more used proc update_modified_column_date_m on pgsql (its presence triggered errors)
|
||||
FIX: Vulnerability report by Ricardo Matias
|
||||
FIX: select default mail template
|
||||
FIX: Select transport mode function when creating a supplier invoice and add unique key to the table llx_c_transport_mode in migrate sql
|
||||
FIX: Merge of thirdparties : "unknow column fk_soc" + "Delivery" label
|
||||
FIX: SQL Error in group by with postgres or mysql strict mode
|
||||
FIX: TakePOS : load date function
|
||||
FIX: Timeout during import
|
||||
FIX: Trigger on expense report was not fired
|
||||
FIX: User creation of expense report not visible
|
||||
FIX: warning when adding a line if $remise_percent is an empty string
|
||||
FIX: status late on purchase orders
|
||||
FIX: ODT generation very slow
|
||||
FIX: amount in summary of report
|
||||
FIX: VAT value when code contains number
|
||||
FIX: payment term label on PDF
|
||||
FIX: date selector when using reduced year (like on smartphone)
|
||||
|
||||
|
||||
***** ChangeLog for 13.0.0 compared to 12.0.0 *****
|
||||
|
||||
For users:
|
||||
----------
|
||||
NEW: Add module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files.
|
||||
NEW: Module "Credit transfer SEPA" to manage payment of vendors using bank credit transfer SEPA files.
|
||||
NEW: Module Intracomm report
|
||||
NEW: Module Reception (for a more accurate management of your receptions) moved from experimental to stable.
|
||||
NEW: Module Recruitment to manage Job position and applications.
|
||||
NEW: Several security issues after a private bug bounty campaign.
|
||||
@ -16,13 +148,12 @@ NEW: Accountancy - add options to disable binding on sales, purchases & expense
|
||||
NEW: Accountancy balance - add a menu entry to show subtotal by group
|
||||
NEW: Accountancy - change menu disposition
|
||||
NEW: Accountancy - on transfers, select the periodicity by default
|
||||
NEW: Accountancy - Add export for Gestinum (v3 & v5)
|
||||
NEW: Accountancy - add export for Gestinum (v3 & v5) #15180
|
||||
NEW: new currency rate editor
|
||||
NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock.
|
||||
NEW: add a widget to show the customers with outstanding limits reached
|
||||
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
|
||||
@ -34,12 +165,12 @@ NEW: add column vat rate in page to define accounting account on product/service
|
||||
NEW: add costprice in fields of products list
|
||||
NEW: add an import profile for CUSTOMER ORDER, PO, PROPOSAL MODULE, SUPPLIER INVOICE
|
||||
NEW: add employee link in expense report binding page
|
||||
NEW: add EORI No. as ProfID5
|
||||
NEW: add EORI No. as ProfID5 #15382
|
||||
NEW: add export for various payments
|
||||
NEW: add Extrafields labels and values in mail on create ticket
|
||||
NEW: add Extrafields support on ECM module
|
||||
NEW: add filter rules "is answer" and "is not answer" in email collector
|
||||
NEW: add focus when editing on product/stock/product.php Close #14548
|
||||
NEW: add focus when editing on product/stock/product.php -> close #14548
|
||||
NEW: add free text on each terminal of cash desk
|
||||
NEW: add global search for customer payments and vendor payments
|
||||
NEW: add global search for miscellaneous payments
|
||||
@ -57,7 +188,6 @@ 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 a prospect status for the contact with managment of custom icon
|
||||
NEW: add public note on products ; this also partially fix the #14342
|
||||
@ -68,7 +198,6 @@ NEW: add search param for close date on order list
|
||||
NEW: add show preview for mail attachement on form mail
|
||||
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 vcard for adherent and user
|
||||
NEW: add week number for month view in agenda
|
||||
@ -76,11 +205,10 @@ NEW: Algeria data (VAT and forme_juridique)
|
||||
NEW: allow click on all header numbers on commerce area
|
||||
NEW: allow to reopen interventions (green button)
|
||||
NEW: allow zero quantity on supplier/vendor order line
|
||||
NEW: appearance tab in TakePOS with more visual parameters
|
||||
NEW: better currency rate editor
|
||||
NEW: can build vendor invoice from vendor orders
|
||||
NEW: can change a product in lines of a recurring invoice or contract
|
||||
NEW: can change size of logo on PDF documents
|
||||
NEW: can set the size of the 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
|
||||
@ -89,21 +217,16 @@ 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 web pages
|
||||
NEW: can hide eatby, sellby dates with option PRODUCT_DISABLE_SELLBY and PRODUCT_DISABLE_EATBY
|
||||
NEW: can hide eatby, sellby dates with option PRODUCT_DISABLE_EATBY and PRODUCT_DISABLE_SELLBY
|
||||
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: change thirdparty with barcode scan in TakePOS
|
||||
NEW: common behavior for monthly leave list view
|
||||
NEW: convert all subscription in datetime
|
||||
NEW: can create a thirdparty customer from TakePOS
|
||||
NEW: date shipment from order accepts hours
|
||||
NEW: price level compatibility for variant
|
||||
NEW: delayed payment in TakePOS
|
||||
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: Email configuration - allow auto signed certificate when smtp ssl activated
|
||||
NEW: enable free emails input with select2
|
||||
@ -125,29 +248,24 @@ 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 - Nature of product is now a dictionary #13287
|
||||
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: Rule "email to" accept wildcard *
|
||||
NEW: Save filter of the project homepage
|
||||
NEW: save filter of the project homepage
|
||||
NEW: select-able columns on customer and supplier invoice paymnet list
|
||||
NEW: select-able columns on miscellaneous payments + more data columns
|
||||
NEW: select-able columns on social taxes list
|
||||
NEW: send context and remove new lines on create ticket
|
||||
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 area, payment area, shipment area
|
||||
NEW: show image of user in the combo select of users
|
||||
@ -160,70 +278,80 @@ 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 appearance tab with more visual parameters
|
||||
NEW: TakePOS add alert before changing thirdparty
|
||||
NEW: TakePOS add third order printer
|
||||
NEW: TakePOS can change thirdparty with barcode scan
|
||||
NEW: TakePOS can create a thirdparty customer from TakePOS frontend
|
||||
NEW: TakePOS connector compatibility with RECEIPT PRINTERS module
|
||||
NEW: TakePOS add delayed payment
|
||||
NEW: TakePOS display date range if exist
|
||||
NEW: TakePOS display resiliate status for members
|
||||
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: TakePOS multicurrency compatibility
|
||||
NEW: TakePOS multicurrency total
|
||||
NEW: TakePOS print payment method and change
|
||||
NEW: TakePOS restrict thirdparty to customer
|
||||
NEW: TakePOS show available stock
|
||||
NEW: TakePOS Weighing Scale compatibility with TakePOS connector #14725
|
||||
NEW: Thirdparty 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 classification on create from email collector
|
||||
NEW: Ticket message notifications when edited from public interface
|
||||
NEW: translate classification labels in ticket
|
||||
NEW: Ticket translate classification labels in ticket
|
||||
NEW: VAT rate for Angola #15606
|
||||
NEW: VAT and juridical status for Algeria
|
||||
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: website - global header of a website can also have dynamic content
|
||||
NEW: when creating a user from a member linked to a thirdparty, you can choose to create it as external or internal user
|
||||
NEW: add clone button on miscellaneous payment
|
||||
NEW: #15065 Add option to put the product label in bold in the PDF templates if configured
|
||||
NEW: Add option "If the feature to manage kits of module Stock is used, show details of subproducts of a kit on PDF."
|
||||
NEW: add clone button on miscellaneous payment
|
||||
NEW: add option to put the product label in bold in the PDF templates if configured #15065
|
||||
NEW: add option "If the feature to manage kits of module Stock is used, show details of subproducts of a kit on PDF."
|
||||
|
||||
|
||||
For developers:
|
||||
---------------
|
||||
NEW: add __MEMBER_TYPE__ substitution key
|
||||
NEW: add __TYPE__ substitution key
|
||||
NEW: add __MEMBER_TYPE__ and __TYPE__ substitution key
|
||||
NEW: add function dolButtonToOpenUrlInDialogPopup() to be able to open page into a popup
|
||||
NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER)
|
||||
NEW: Add some fields to link website page to an other object
|
||||
NEW: add some fields to link website page to an other object
|
||||
NEW: fill ECM src object fields in dol_add_file_process
|
||||
NEW: conf to allow to show the full tree in warehouse popup
|
||||
NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: can use parameter ?THEME_DARKMODEENABLED=2 for a preview of theme in dark mode
|
||||
NEW: can force the antivirus from conf file or autoprepend ini setup
|
||||
NEW: can add event to log into blockedlog module with a constant
|
||||
NEW: add property cssview when declaring fields of an object
|
||||
NEW: Can use dynamic code into the 'enabled' property of DAO fields
|
||||
NEW: allow to edit "demand reason" field though API
|
||||
NEW: fetch contact by email with REST API
|
||||
NEW: can use dynamic code into the 'enabled' property of DAO fields
|
||||
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: added incoterms data into the substitution array
|
||||
NEW: add incoterms data into the substitution array
|
||||
NEW: add send context for ticket
|
||||
NEW: add a message in error_log after detection of SQL or script injection
|
||||
NEW: add validation of MX domain for emails
|
||||
NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') )
|
||||
NEW: Graphics can be horizontal bars
|
||||
NEW: add param to not show links when output tags
|
||||
|
||||
APIs
|
||||
NEW: API get contacts list of a given order
|
||||
NEW: API endpoint getContacts and Clean results
|
||||
NEW: API endpoint getContacts and clean results
|
||||
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: get state dictionnary by REST API
|
||||
NEW: improve Product API for variant products
|
||||
NEW: retrieve discount from invoice from API
|
||||
NEW: Thirdparty REST API: endpoint to set price level
|
||||
NEW: use new category API for project list view
|
||||
|
||||
HOOKs
|
||||
NEW: Hook on propal card
|
||||
NEW: add hook on propal card
|
||||
NEW: add hooks on newpayment page to allow external payment modules
|
||||
NEW: add hooks on stats pages
|
||||
NEW: add formConfirm hook on product page
|
||||
@ -238,7 +366,7 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* 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 deprecated subsitution key __SIGNATURE__ has been removed. Replace it 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.
|
||||
* 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.
|
||||
@ -250,8 +378,67 @@ Following changes may create regressions for some external modules, but were nec
|
||||
* Function showStripePaymentUrl, getStripePaymentUrl, showPaypalPaymentUrl and getPaypalPaymentUrl has been removed. The generic one showOnlinePaymentUrl and getOnlinePaymentUrl are always used.
|
||||
* Context for hook showSocinfoOnPrint has been moved from "showsocinfoonprint" to "main"
|
||||
* Library htdocs/includes/phpoffice/phpexcel as been removed (replaced with htdocs/includes/phpoffice/PhpSpreadsheet)
|
||||
* Database transaction in your triggers must be correctly balanced (one close for one open). If not, an error will be returned by the trigger, even if trigger did return error code.
|
||||
* Dolibarr v13 is still compatible with any PHP version between 5.6.0 and 7.4.*; Unit tests are OK with PHP 8.0 but some warnings or troubles may appears with PHP 8.0.
|
||||
* All your Ajax services must contains such a line at begin of file: if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
|
||||
|
||||
|
||||
***** ChangeLog for 12.0.5 compared to 12.0.4 *****
|
||||
FIX: before crediting a withdrawal receipt, check whether it has been credited already
|
||||
FIX: mandatory extrafields of type sellist
|
||||
FIX: when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion
|
||||
FIX: when a new intervention is created from an object, a new $extrafields object is instantiated but not initialized
|
||||
FIX: "openall" filter on ticket list does not include read tickets
|
||||
FIX: ticket - extrafields of type 'date' are not saved
|
||||
FIX: ticket - the "openall" filter on the ticket list does not include tickets with status READ
|
||||
FIX: #14290 #15900
|
||||
FIX: #15388 #15891
|
||||
FIX: #15465 External user sees last 5 shipments to other customers in the dashboard
|
||||
FIX: #15629
|
||||
FIX: #15751 Miscellaneous payment type change to 0 after updating subledger account
|
||||
FIX: #15946
|
||||
FIX: #15966 #15967
|
||||
FIX: Accountancy - Fix some problems on CEGID export
|
||||
FIX: Accountancy - label_operation is used instead of label_compte
|
||||
FIX: Accountancy - Retire entire opening balance feature
|
||||
FIX: add autofix of count of email target when data is corrupted
|
||||
FIX: add categories params on llxHeader filter
|
||||
FIX: Add critical price patch from 12 to 11.
|
||||
FIX: Bad cleaning of VAT rate when numbers are into code
|
||||
FIX: Bad dates filtering in the ticket list causes sql error
|
||||
FIX: balance starting and ending fiscal month #14197
|
||||
FIX: bom line unit display #13831
|
||||
FIX: cash fence for takepos with multientity
|
||||
FIX: Check of customer/vendor code fails in some cases
|
||||
FIX: create ticket : thirdparty/contact notification #15629
|
||||
FIX: Creation of thirdparty when setup is empty
|
||||
FIX: Dates of sales start in TakePOS
|
||||
FIX: dupliacete customer or supplier code must be error dipslayed with new code proposed
|
||||
FIX: Export FEC - Force Carriage Return Line Feed
|
||||
FIX: Facture Situation Out : status condition
|
||||
FIX: Filter on date of next generation on template invoices
|
||||
FIX: Fix detect dispatched product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES)
|
||||
FIX: Invoice Situation Out : status condition
|
||||
FIX: issue 15659 : Missing test if supplier conf is enabled
|
||||
FIX: link to create event when task is in a project with a thirdparty
|
||||
FIX: Localtax must be converted with price2num
|
||||
FIX: manage price min for PRODUIT_CUSTOMER_PRICES
|
||||
FIX: missing GETPOST parameters on card_presend.tpl.php
|
||||
FIX: missing socid into link to create event from project agenda tab
|
||||
FIX: Must delete extrafields before main table on product deletion.
|
||||
FIX: (path) htdocs removed
|
||||
FIX: php alert sms.php
|
||||
FIX: right to show VAT rate in product list
|
||||
FIX: select default mail template
|
||||
FIX: Timeout during import
|
||||
FIX: update order by api
|
||||
FIX: useless tracking number displayed on pdf if empty issue #14501
|
||||
FIX: Visible date of payment
|
||||
FIX: warning when adding a line if $remise_percent is an empty string
|
||||
FIX: When creating a new POS sell, the creation date must be modified.
|
||||
FIX: wrong name for search status param issue #15516
|
||||
|
||||
***** ChangeLog for 12.0.4 compared to 12.0.3 *****
|
||||
FIX: make formConfirm an addreplace-type hook
|
||||
FIX: regex to remove 'action' parameter: taking feedback from PR#15213 into account
|
||||
|
||||
34
DCO
Normal file
34
DCO
Normal file
@ -0,0 +1,34 @@
|
||||
Developer Certificate of Origin
|
||||
Version 1.1
|
||||
|
||||
Copyright (C) 2002 - Today, The Dolibarr team and its contributors.
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
@ -98,7 +98,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
|
||||
### Main application/modules (all optional)
|
||||
|
||||
- Customers, Prospects (Leads) and/or Suppliers directory + Contacts
|
||||
- Members management
|
||||
- Members/Membership management
|
||||
- Products and/or Services catalog
|
||||
- Commercial proposals management
|
||||
- Customer & Supplier Orders management
|
||||
@ -112,6 +112,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
|
||||
- Shared calendar/agenda (with ical and vcal export for third party tools integration)
|
||||
- Opportunities or Leads management
|
||||
- Projects & Tasks management
|
||||
- Ticket System
|
||||
- Contracts management
|
||||
- Interventions management
|
||||
- Employee's leave requests management
|
||||
@ -160,7 +161,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog)
|
||||
- Canadian double taxes (federal/province) and other countries using cumulative VAT
|
||||
- Tunisian tax stamp
|
||||
- Argentina invoice numbering using A,B,C...
|
||||
- Compatible with [European directives](http://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
|
||||
- Compatible with [European directives] (https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE)
|
||||
- Compatible with European GDPR rules
|
||||
- ...
|
||||
- Flexible PDF & ODT generation for invoices, proposals, orders...
|
||||
|
||||
17
SECURITY.md
17
SECURITY.md
@ -12,7 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a vulnerability, please use GitHub security advisory (alternatively send an email to security@dolibarr.org)
|
||||
To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody)
|
||||
|
||||
|
||||
## Hunting vulnerabilities on Dolibarr
|
||||
@ -55,23 +55,23 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us
|
||||
* $dolibarr_nocsrfcheck must be kept to the value 0 into conf.php (this is the default value)
|
||||
* $dolibarr_main_force_https must be set to something else than 0.
|
||||
* The constant MAIN_SECURITY_CSRF_WITH_TOKEN must be set to 1 into backoffice menu Home - Setup - Other (this protection should be set to 1 soon by default)
|
||||
* The module DebugBar must NOT be enabled (by default, this module is not enabled. This is a developer tool)
|
||||
* The module ModuleBuilder must NOT be enabled (by default, this module is not enabled. This is a developer tool)
|
||||
* The module DebugBar and ModuleBuilder must NOT be enabled (by default, these modules are not enabled. They are developer tools)
|
||||
* ONLY security reports on modules provided by default and with the "stable" status are valid (troubles into "experimental", "developement" or external modules are not valid vulnerabilities).
|
||||
* The root of web server must link to htdocs and the documents directory must be outside of the web server root (this is the default when using the default installer but may differs with external installer).
|
||||
* The web server setup must be done so only the documents directory is in write mode. The root directory called htdocs must be readonly.
|
||||
* CSRF attacks are accepted for all when using a POST URL, but when using GET URL, they are validated only for creating or updating data resctricted to the admin user.
|
||||
* CSRF attacks are accepted when using a POST URL, but when using GET URL, they are validated only for creating, updating or deleting data resctricted from pages restricted to admin users.
|
||||
* Ability for a high level user to edit web site pages into the CMS by including HTML or Javascript is an expected feature. Vulnerabilities into the website module are validated only if HTML or Javascript injection can be done by a non allowed user.
|
||||
|
||||
Scope is the web application (back office) and the APIs.
|
||||
|
||||
|
||||
## Qualifying vulnerabilities for Bug bounty programs
|
||||
## Qualifying vulnerabilities for reporting
|
||||
|
||||
* Remote code execution (RCE)
|
||||
* Local files access and manipulation (LFI, RFI, XXE, SSRF, XSPA)
|
||||
* Code injections (HTML, JS, SQL, PHP, ...)
|
||||
* Cross-Site Scripting (XSS)
|
||||
* Cross-Site Requests Forgery (CSRF) with real security impact
|
||||
* Cross-Site Scripting (XSS), except from setup page of module "External web site" (allowing any content here, editable by admin user only, is accepted on purpose or into module "Web site" when permission to edit website content is allowed).
|
||||
* Cross-Site Requests Forgery (CSRF) with real security impact (when using GET URLs, CSRF are qualified only for creating, updating or deleting data from pages restricted to admin users)
|
||||
* Open redirect
|
||||
* Broken authentication & session management
|
||||
* Insecure direct object references
|
||||
@ -82,7 +82,8 @@ Scope is the web application (back office) and the APIs.
|
||||
* Stack traces or path disclosure (for non admin users only)
|
||||
|
||||
|
||||
## Non-qualifying vulnerabilities for Bug bounty programs, but qualified for reporting
|
||||
## Non-qualifying vulnerabilities for reporting
|
||||
|
||||
* "Self" XSS
|
||||
* SSL/TLS best practices
|
||||
* Denial of Service attacks
|
||||
|
||||
102
build.xml
102
build.xml
@ -1,102 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Script build for hudson CI -->
|
||||
<project name="dolibarr" default="hudson" basedir=".">
|
||||
<!-- Exclude/ignore paths -->
|
||||
<property name="ignorepaths" value="${basedir}/htdocs/conf,${basedir}/htdocs/core/filemanagerdol,${basedir}/htdocs/includes" />
|
||||
<property name="ignoreregexp" value="**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*" />
|
||||
|
||||
<target name="clean">
|
||||
<!-- Clean up -->
|
||||
<delete dir="${basedir}/hudson"/>
|
||||
<delete dir="${basedir}/generatedJUnitFiles"/>
|
||||
|
||||
<!-- Create build directories -->
|
||||
<mkdir dir="${basedir}/hudson/doxygen"/>
|
||||
<mkdir dir="${basedir}/hudson/logs"/>
|
||||
<mkdir dir="${basedir}/hudson/coverage"/>
|
||||
</target>
|
||||
|
||||
<!-- Run phpmd, phpcpd, phpcs, doxygen and phploc in parallel -->
|
||||
<target name="parallelTasks">
|
||||
<parallel>
|
||||
<!-- <antcall target="phpmd"/> -->
|
||||
<antcall target="phpcpd"/>
|
||||
<!-- <antcall target="phpcs"/> -->
|
||||
<antcall target="doxygen"/>
|
||||
<antcall target="phploc"/>
|
||||
</parallel>
|
||||
</target>
|
||||
|
||||
<!-- Generate pmd.xml -->
|
||||
<!--
|
||||
<target name="phpmd">
|
||||
<exec executable="phpmd">
|
||||
<arg line="htdocs xml codesize,unusedcode
|
||||
-\-reportfile '${basedir}/hudson/logs/pmd.xml'
|
||||
-\-ignore=${ignorepaths}
|
||||
" />
|
||||
</exec>
|
||||
</target>
|
||||
-->
|
||||
|
||||
<!-- Generate pmd-cpd.xml -->
|
||||
<target name="phpcpd">
|
||||
<exec executable="phpcpd">
|
||||
<arg line=" --log-pmd '${basedir}/hudson/logs/pmd-cpd.xml'
|
||||
--exclude '${basedir}/htdocs/conf'
|
||||
--exclude '${basedir}/htdocs/core/filemanagerdol'
|
||||
--exclude '${basedir}/htdocs/includes'
|
||||
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*'
|
||||
--min-tokens 70
|
||||
--min-lines 20
|
||||
htdocs
|
||||
" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Generate phploc.csv -->
|
||||
<target name="phploc">
|
||||
<exec executable="phploc">
|
||||
<arg line=" --log-csv '${basedir}/hudson/logs/phploc.csv'
|
||||
--exclude '${basedir}/htdocs/conf'
|
||||
--exclude '${basedir}/htdocs/core/filemanagerdol'
|
||||
--exclude '${basedir}/htdocs/includes'
|
||||
--exclude '**/PEAR/*,**/NET/*,**/HTTP/*,**/zendgdata/*,**/reportico/*'
|
||||
htdocs
|
||||
" />
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Generate checkstyle.xml -->
|
||||
<target name="phpcs">
|
||||
<exec executable="phpcs" dir="${basedir}">
|
||||
<arg line=" --standard=${basedir}/dev/codesniffer/jenkins_ruleset.xml
|
||||
--report=checkstyle
|
||||
--report-file=${basedir}/hudson/logs/checkstyle.xml
|
||||
--ignore=${ignorepaths},${ignoreregexp}
|
||||
htdocs
|
||||
"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Run unit tests and generate junit.xml and clover.xml -->
|
||||
<target name="phpunit">
|
||||
<exec executable="phpunit" dir="${basedir}" failonerror="true">
|
||||
<arg line=" --configuration ${basedir}/test/phpunit/phpunittest.xml
|
||||
--log-junit ${basedir}/hudson/logs/junit.xml
|
||||
--coverage-clover ${basedir}/hudson/coverage/clover.xml
|
||||
--coverage-html ${basedir}/hudson/coverage/
|
||||
test/phpunit/AllTests.php
|
||||
"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<!-- Generate Doxygen documentation -->
|
||||
<target name="doxygen" description="Dolibarr documentation" >
|
||||
<exec executable="doxygen" dir="${basedir}" failonerror="false">
|
||||
<arg value="${basedir}/build/doxygen/jenkins_doxygen.doxyfile"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
<target name="hudson" depends="clean,phpunit,phpcs,parallelTasks"/>
|
||||
</project>
|
||||
10
build/README
10
build/README
@ -7,6 +7,9 @@ Building packages
|
||||
##################################################
|
||||
|
||||
All sub-directories of "build" directory contains files (setup or binary tools) required to build automatically Dolibarr packages.
|
||||
The build directory and all its contents is absolutely not required to make Dolibarr working.
|
||||
It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory.
|
||||
|
||||
|
||||
There are several tools:
|
||||
|
||||
@ -17,8 +20,7 @@ There are several tools:
|
||||
--------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Prerequisites to build tgz, debian, rpm package:
|
||||
|
||||
Prerequisites to build tgz, debian and rpm packages:
|
||||
> apt-get install tar dpkg dpatch p7zip-full rpm zip
|
||||
|
||||
|
||||
@ -58,10 +60,6 @@ Prerequisites to build autoexe DoliWamp package:
|
||||
|
||||
--------------------------------------------------------------------------------------------------
|
||||
|
||||
Note:
|
||||
The build directory and all its contents is absolutely not required to make Dolibarr working.
|
||||
It is here only to build Dolibarr packages, and those generated packages will not contains this "build" directory.
|
||||
|
||||
|
||||
You can find in "build", following sub-directories:
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ Priority: optional
|
||||
Maintainer: Laurent Destailleur (eldy) <eldy@users.sourceforge.net>
|
||||
# Uploaders: Laurent Destailleur (eldy) <eldy@users.sourceforge.net> # Only if differs from Maintainer
|
||||
Standards-Version: 3.9.6
|
||||
Homepage: http://www.dolibarr.org
|
||||
Homepage: https://www.dolibarr.org
|
||||
Build-Depends: debhelper (>= 9), po-debconf
|
||||
# This package need at least debian 7 or ubuntu 13.04 or any distribution based on this version
|
||||
|
||||
@ -33,7 +33,7 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm |
|
||||
Recommends: apache2 | lighttpd | httpd,
|
||||
mariadb-server | virtual-mysql-server,
|
||||
# Required PHP extensions for debian 9 but we can't add them into a Depends, it does not exists on debian 7 and 8
|
||||
php-xml, php-mbstring
|
||||
php-xml, php-mbstring, php-intl
|
||||
Suggests: www-browser, php5-geoip
|
||||
Description: Web based software to manage a company or foundation
|
||||
Dolibarr ERP & CRM is an easy to use open source/free software package for
|
||||
|
||||
@ -23,7 +23,7 @@ setup_empty_conf() {
|
||||
mkdir -p /etc/dolibarr
|
||||
touch /etc/dolibarr/conf.php
|
||||
chown root:www-data /etc/dolibarr/conf.php
|
||||
chmod 664 /etc/dolibarr/conf.php
|
||||
chmod 660 /etc/dolibarr/conf.php
|
||||
}
|
||||
|
||||
is_new_upstream_version() {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>$title</title>
|
||||
<title>Dolibarr source code documentation</title>
|
||||
<!-- from dolibarr.org -->
|
||||
<meta http-equiv="Content-Type" content="text/html" charset=utf-8 />
|
||||
<meta name="verify-v1"
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
* \brief This script create a xml checksum file
|
||||
*/
|
||||
|
||||
if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Do not create database handler $db
|
||||
if (! defined('NOREQUIREDB')) {
|
||||
define('NOREQUIREDB', '1'); // Do not create database handler $db
|
||||
}
|
||||
|
||||
$sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
@ -30,8 +32,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once $path."../htdocs/master.inc.php";
|
||||
@ -46,30 +48,33 @@ $includecustom=0;
|
||||
$includeconstants=array();
|
||||
|
||||
if (empty($argv[1])) {
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
|
||||
exit -1;
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
|
||||
exit -1;
|
||||
}
|
||||
|
||||
parse_str($argv[1]);
|
||||
|
||||
$i=0;
|
||||
while ($i < $argc) {
|
||||
if (! empty($argv[$i])) parse_str($argv[$i]);
|
||||
if (preg_match('/includeconstant=/', $argv[$i])) {
|
||||
$tmp=explode(':', $includeconstant, 3);
|
||||
if (count($tmp) != 3) {
|
||||
print "Error: Bad parameter includeconstant ".$includeconstant."\n";
|
||||
exit -1;
|
||||
}
|
||||
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
|
||||
}
|
||||
$i++;
|
||||
if (! empty($argv[$i])) {
|
||||
parse_str($argv[$i]);
|
||||
}
|
||||
if (preg_match('/includeconstant=/', $argv[$i])) {
|
||||
$tmp=explode(':', $includeconstant, 3); // $includeconstant has been set with previous parse_str()
|
||||
if (count($tmp) != 3) {
|
||||
print "Error: Bad parameter includeconstant=".$includeconstant."\n";
|
||||
exit -1;
|
||||
}
|
||||
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
if (empty($release)) {
|
||||
print "Error: Missing release paramater\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
print "Error: Missing release paramater\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
|
||||
$savrelease = $release;
|
||||
@ -77,42 +82,44 @@ $savrelease = $release;
|
||||
// If release is auto, we take current version
|
||||
$tmpver=explode('-', $release, 2);
|
||||
if ($tmpver[0] == 'auto' || $tmpver[0] == 'autostable') {
|
||||
$release=DOL_VERSION;
|
||||
if ($tmpver[1] && $tmpver[0] == 'auto') $release.='-'.$tmpver[1];
|
||||
$release=DOL_VERSION;
|
||||
if ($tmpver[1] && $tmpver[0] == 'auto') {
|
||||
$release.='-'.$tmpver[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($includecustom)) {
|
||||
$tmpverbis=explode('-', $release, 2);
|
||||
if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') {
|
||||
if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') {
|
||||
print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
} else {
|
||||
$tmpverter=explode('-', DOL_VERSION, 2);
|
||||
if ($tmpverter[0] != $tmpverbis[0]) {
|
||||
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
}
|
||||
$tmpverbis=explode('-', $release, 2);
|
||||
if (empty($tmpverbis[1]) || $tmpver[0] == 'autostable') {
|
||||
if (DOL_VERSION != $tmpverbis[0] && $savrelease != 'auto') {
|
||||
print 'Error: When parameter "includecustom" is not set and there is no suffix in release parameter, version declared into filefunc.in.php ('.DOL_VERSION.') must be exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
} else {
|
||||
$tmpverter=explode('-', DOL_VERSION, 2);
|
||||
if ($tmpverter[0] != $tmpverbis[0]) {
|
||||
print 'Error: When parameter "includecustom" is not set, version declared into filefunc.in.php ('.DOL_VERSION.') must have value without prefix ('.$tmpverter[0].') that is exact same value than "release" parameter ('.$tmpverbis[0].')'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (! preg_match('/'.preg_quote(DOL_VERSION, '/').'-/', $release)) {
|
||||
print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
if (! preg_match('/'.preg_quote(DOL_VERSION, '/').'-/', $release)) {
|
||||
print 'Error: When parameter "includecustom" is set, version declared into filefunc.inc.php ('.DOL_VERSION.') must be used with a suffix into "release" parameter (ex: '.DOL_VERSION.'-mydistrib).'."\n";
|
||||
print "Usage: ".$script_file." release=autostable|auto[-mybuild]|x.y.z[-mybuild] [includecustom=1] [includeconstant=CC:MY_CONF_NAME:value]\n";
|
||||
exit -1;
|
||||
}
|
||||
}
|
||||
|
||||
print "Release : ".$release."\n";
|
||||
print "Working on files into : ".DOL_DOCUMENT_ROOT."\n";
|
||||
print "Release : ".$release."\n";
|
||||
print "Include custom in signature : ".$includecustom."\n";
|
||||
print "Include constants in signature : ";
|
||||
foreach ($includeconstants as $countrycode => $tmp) {
|
||||
foreach ($tmp as $constname => $constvalue) {
|
||||
print $constname.'='.$constvalue." ";
|
||||
}
|
||||
foreach ($tmp as $constname => $constvalue) {
|
||||
print $constname.'='.$constvalue." ";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
@ -134,13 +141,13 @@ fputs($fp, '<?xml version="1.0" encoding="UTF-8" ?>'."\n");
|
||||
fputs($fp, '<checksum_list version="'.$release.'" date="'.dol_print_date(dol_now(), 'dayhourrfc').'" generator="'.$script_file.'">'."\n");
|
||||
|
||||
foreach ($includeconstants as $countrycode => $tmp) {
|
||||
fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n");
|
||||
foreach ($tmp as $constname => $constvalue) {
|
||||
$valueforchecksum=(empty($constvalue)?'0':$constvalue);
|
||||
$checksumconcat[]=$valueforchecksum;
|
||||
fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n");
|
||||
}
|
||||
fputs($fp, '</dolibarr_constants>'."\n");
|
||||
fputs($fp, '<dolibarr_constants country="'.$countrycode.'">'."\n");
|
||||
foreach ($tmp as $constname => $constvalue) {
|
||||
$valueforchecksum=(empty($constvalue)?'0':$constvalue);
|
||||
$checksumconcat[]=$valueforchecksum;
|
||||
fputs($fp, ' <constant name="'.$constname.'">'.$valueforchecksum.'</constant>'."\n");
|
||||
}
|
||||
fputs($fp, '</dolibarr_constants>'."\n");
|
||||
}
|
||||
|
||||
fputs($fp, '<dolibarr_htdocs_dir includecustom="'.$includecustom.'">'."\n");
|
||||
@ -151,26 +158,28 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1);
|
||||
$files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
|
||||
*/
|
||||
$regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
|
||||
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
|
||||
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
|
||||
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
|
||||
|
||||
$dir='';
|
||||
$needtoclose=0;
|
||||
foreach ($files as $filetmp) {
|
||||
$file = $filetmp['fullname'];
|
||||
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
|
||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||
if ($newdir!=$dir) {
|
||||
if ($needtoclose)
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
|
||||
$dir = $newdir;
|
||||
$needtoclose=1;
|
||||
}
|
||||
if (filetype($file)=="file") {
|
||||
$md5=md5_file($file);
|
||||
$checksumconcat[]=$md5;
|
||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||
}
|
||||
$file = $filetmp['fullname'];
|
||||
//$newdir = str_replace(dirname(__FILE__).'/../htdocs', '', dirname($file));
|
||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||
if ($newdir!=$dir) {
|
||||
if ($needtoclose) {
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
}
|
||||
fputs($fp, ' <dir name="'.$newdir.'">'."\n");
|
||||
$dir = $newdir;
|
||||
$needtoclose=1;
|
||||
}
|
||||
if (filetype($file)=="file") {
|
||||
$md5=md5_file($file);
|
||||
$checksumconcat[]=$md5;
|
||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||
}
|
||||
}
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
fputs($fp, '</dolibarr_htdocs_dir>'."\n");
|
||||
@ -198,22 +207,23 @@ $files = dol_dir_list(dirname(__FILE__).'/../scripts/', 'files', 1, $regextoincl
|
||||
$dir='';
|
||||
$needtoclose=0;
|
||||
foreach ($files as $filetmp) {
|
||||
$file = $filetmp['fullname'];
|
||||
//$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||
$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||
if ($newdir!=$dir) {
|
||||
if ($needtoclose)
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
|
||||
$dir = $newdir;
|
||||
$needtoclose=1;
|
||||
}
|
||||
if (filetype($file)=="file") {
|
||||
$md5=md5_file($file);
|
||||
$checksumconcat[]=$md5;
|
||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||
}
|
||||
$file = $filetmp['fullname'];
|
||||
//$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||
$newdir = str_replace(DOL_DOCUMENT_ROOT, '', dirname($file));
|
||||
$newdir = str_replace(dirname(__FILE__).'/../scripts', '', dirname($file));
|
||||
if ($newdir!=$dir) {
|
||||
if ($needtoclose) {
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
}
|
||||
fputs($fp, ' <dir name="'.$newdir.'" >'."\n");
|
||||
$dir = $newdir;
|
||||
$needtoclose=1;
|
||||
}
|
||||
if (filetype($file)=="file") {
|
||||
$md5=md5_file($file);
|
||||
$checksumconcat[]=$md5;
|
||||
fputs($fp, ' <md5file name="'.basename($file).'" size="'.filesize($file).'">'.$md5.'</md5file>'."\n");
|
||||
}
|
||||
}
|
||||
fputs($fp, ' </dir>'."\n");
|
||||
fputs($fp, '</dolibarr_script_dir>'."\n");
|
||||
|
||||
@ -390,6 +390,9 @@ if ($nboftargetok) {
|
||||
$olddir=getcwd();
|
||||
chdir("$SOURCE");
|
||||
|
||||
print "Clean $SOURCE/htdocs\n";
|
||||
$ret=`rm -f $SOURCE/htdocs/includes/autoload.php`;
|
||||
|
||||
$ret=`git ls-files . --exclude-standard --others`;
|
||||
if ($ret)
|
||||
{
|
||||
@ -579,7 +582,6 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/webmail*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/workstation*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/allscreen*`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/theme/common/octicons/LICENSE`;
|
||||
@ -614,7 +616,6 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/parsedown/LICENSE.txt`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
|
||||
@ -624,8 +625,6 @@ if ($nboftargetok) {
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
|
||||
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
|
||||
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#HTMLDOC 1.8.27
|
||||
-t pdf14 -f "../../doc/dolibarr_en.pdf" --webpage --no-title --logoimage "../../doc/images/dolibarr_256x256.png" --linkcolor #2200c0 --linkstyle plain --size Universal --left 0.30in --right 0.30in --top 0.40in --bottom 0.30in --header ... --header1 ... --footer c/d --nup 1 --tocheader ... --tocfooter ... --portrait --color --no-pscommands --no-xrxcomments --compression=9 --jpeg=50 --fontsize 10.0 --fontspacing 1.0 --headingfont Helvetica --bodyfont Helvetica --headfootsize 9.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode document --pagelayout single --firstpage p1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680 --no-strict --no-overflow
|
||||
http://wiki.dolibarr.org/index.php/Main_Page
|
||||
http://wiki.dolibarr.org/index.php/What_Dolibarr_Do
|
||||
https://wiki.dolibarr.org/index.php/Home
|
||||
https://wiki.dolibarr.org/index.php/What_Dolibarr_Does
|
||||
|
||||
@ -212,6 +212,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -292,6 +292,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -209,6 +209,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -220,6 +220,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/product
|
||||
%_datadir/dolibarr/htdocs/projet
|
||||
%_datadir/dolibarr/htdocs/public
|
||||
%_datadir/dolibarr/htdocs/recruitment
|
||||
%_datadir/dolibarr/htdocs/reception
|
||||
%_datadir/dolibarr/htdocs/resource
|
||||
%_datadir/dolibarr/htdocs/salaries
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# Format of sitemap file is available at
|
||||
# http://www.sitemaps.org/protocol.html
|
||||
# https://www.sitemaps.org/protocol.html
|
||||
|
||||
# To build a sitemap from urllist-bing.txt, run
|
||||
# google-sitemapgen --config=config-bing.xml --testing
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
"ckeditor/ckeditor" : "4.12.1",
|
||||
"mike42/escpos-php" : "2.2",
|
||||
"mobiledetect/mobiledetectlib" : "2.8.34",
|
||||
"phpoffice/phpexcel" : "1.8.1",
|
||||
"phpoffice/phpexcel" : "1.8.2",
|
||||
"restler/framework" : "3.0.0-RC6",
|
||||
"tecnickcom/tcpdf" : "6.3.2",
|
||||
"nnnick/chartjs" : "^2.9",
|
||||
|
||||
57
composer.lock
generated
57
composer.lock
generated
@ -328,6 +328,63 @@
|
||||
},
|
||||
"time": "2020-03-23T09:12:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoffice/phpexcel",
|
||||
"version": "1.8.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHPOffice/PHPExcel.git",
|
||||
"reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHPOffice/PHPExcel/zipball/1441011fb7ecdd8cc689878f54f8b58a6805f870",
|
||||
"reference": "1441011fb7ecdd8cc689878f54f8b58a6805f870",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-mbstring": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-xmlwriter": "*",
|
||||
"php": "^5.2|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"squizlabs/php_codesniffer": "2.*"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"LGPL-2.1"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Maarten Balliauw",
|
||||
"homepage": "http://blog.maartenballiauw.be"
|
||||
},
|
||||
{
|
||||
"name": "Erik Tilt"
|
||||
},
|
||||
{
|
||||
"name": "Franck Lefevre",
|
||||
"homepage": "http://rootslabs.net"
|
||||
},
|
||||
{
|
||||
"name": "Mark Baker",
|
||||
"homepage": "http://markbakeruk.net"
|
||||
}
|
||||
],
|
||||
"description": "PHPExcel - OpenXML - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine",
|
||||
"homepage": "https://github.com/PHPOffice/PHPExcel",
|
||||
"keywords": [
|
||||
"OpenXML",
|
||||
"excel",
|
||||
"xlsx"
|
||||
],
|
||||
"abandoned": "phpoffice/phpspreadsheet",
|
||||
"time": "2018-11-22T23:07:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "restler/framework",
|
||||
"version": "3.0.0-RC6",
|
||||
|
||||
15
dev/README
15
dev/README
@ -1,13 +1,14 @@
|
||||
README (English)
|
||||
--------------------------------
|
||||
This directory contains sub-directories to provide tools or
|
||||
documentation for developers.
|
||||
Note: All files in this directory are in VCS only and are not
|
||||
provided with a standard release.
|
||||
|
||||
This directory contains sub-directories to provide tools or documentation for developers.
|
||||
|
||||
Note: All files in this directory are in the source repository only and are not provided with a standard release. They are useless to make Dolibarr working.
|
||||
|
||||
You may find a more complete documentation on Dolibarr on the wiki:
|
||||
|
||||
There is also some documentation on Dolibarr Wiki:
|
||||
https://wiki.dolibarr.org/
|
||||
and
|
||||
https://doxygen.dolibarr.org/
|
||||
|
||||
and on
|
||||
|
||||
https://doxygen.dolibarr.org/
|
||||
|
||||
@ -50,6 +50,13 @@ Replace call to serialize_val with no bugged value
|
||||
|
||||
* In all files, replace constructor names into __construct. Replace also parent::constructor_name with parent::__construct
|
||||
|
||||
* Line 4222 of file nusoap.php
|
||||
|
||||
$rev = array();
|
||||
preg_match('/\$Revision: ([^ ]+)/', $this->revision, $rev);
|
||||
$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
|
||||
|
||||
|
||||
|
||||
|
||||
TCPDF:
|
||||
@ -126,17 +133,15 @@ with
|
||||
}
|
||||
}
|
||||
elseif (($imgsrc[0] === '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {
|
||||
|
||||
|
||||
|
||||
* In tecnickcom/tcpdf/include/tcpdf_static, in function fopenLocal, replace
|
||||
* In tecnickcom/tcpdf/include/tcpdf_static.php, in function fopenLocal, replace
|
||||
|
||||
if (strpos($filename, '://') === false) {
|
||||
|
||||
with
|
||||
|
||||
if (strpos($filename, '//') === 0)
|
||||
{
|
||||
if (strpos($filename, '//') === 0) {
|
||||
// Share folder on a (windows) server
|
||||
// e.g.: "//[MyServerName]/[MySharedFolder]/"
|
||||
//
|
||||
@ -168,17 +173,17 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
|
||||
|
||||
TCPDI:
|
||||
------
|
||||
Add fpdf_tpl.php 1.2
|
||||
Add file fpdf_tpl.php 1.2
|
||||
|
||||
Add tcpdi.php
|
||||
Add file tcpdi.php
|
||||
|
||||
Add tcpdi_parser.php and replace:
|
||||
require_once(dirname(__FILE__).'/include/tcpdf_filters.php');
|
||||
Add file tcpdi_parser.php and replace:
|
||||
require_once(dirname(__FILE__).'/include/tcpdf_filters.php');
|
||||
with:
|
||||
require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php');
|
||||
require_once(dirname(__FILE__).'/../tecnickcom/tcpdf/include/tcpdf_filters.php');
|
||||
|
||||
|
||||
* Fix by replacing
|
||||
* Fix syntax error by replacing
|
||||
} elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1] >= 2))) {
|
||||
with
|
||||
} elseif (($key == '/Index') AND ($v[0] == PDF_TYPE_ARRAY AND count($v[1]) >= 2)) {
|
||||
@ -188,23 +193,23 @@ with
|
||||
JSGANTT:
|
||||
--------
|
||||
* Replace in function JSGantt.taskLink
|
||||
var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth);
|
||||
var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth);
|
||||
with
|
||||
// LDR To open in same window
|
||||
//var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth);
|
||||
window.location.href=pRef
|
||||
// LDR To open in same window
|
||||
//var OpenWindow=window.open(pRef, "newwin", "height="+vHeight+",width="+vWidth);
|
||||
window.location.href=pRef
|
||||
|
||||
* Replace
|
||||
vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource());
|
||||
vTmpDiv=this.newNode(vTmpCell, 'div', null, null, vTaskList[i].getResource());
|
||||
with
|
||||
var vTmpNode=this.newNode(vTmpCell, 'div', null, '');
|
||||
vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']);
|
||||
vTmpNode.setAttribute('href',vTaskList[i].getLink());
|
||||
var vTmpNode=this.newNode(vTmpCell, 'div', null, '');
|
||||
vTmpNode=this.newNode(vTmpNode, 'a', null, '', vLangs[vLang]['moreinfo']);
|
||||
vTmpNode.setAttribute('href',vTaskList[i].getLink());
|
||||
|
||||
* Replace '% Comp.' to have a smaller text column header
|
||||
'comp':'% Comp.'
|
||||
'comp':'% Comp.'
|
||||
with
|
||||
'comp':'%'
|
||||
'comp':'%'
|
||||
|
||||
|
||||
|
||||
@ -229,11 +234,21 @@ Change content of file htdocs/includes/restler/framework/Luracast/Restler/explor
|
||||
public static function getShortName($className)
|
||||
{
|
||||
// @CHANGE LDR
|
||||
if (! is_string($className)) return;
|
||||
if (!is_string($className)) return;
|
||||
//var_dump($className);
|
||||
|
||||
|
||||
|
||||
* Add line into Data/Text.php to complete function
|
||||
|
||||
public static function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
// @CHANGE LDR
|
||||
if (!is_string($haystack)) return false;
|
||||
|
||||
|
||||
PARSEDOWN
|
||||
---------
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@ -49,7 +49,10 @@ $langs->load("main"); // To load language file for default language
|
||||
|
||||
// Load user and its permissions
|
||||
$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||
if (! $result > 0) { dol_print_error('', $user->error); exit; }
|
||||
if (! $result > 0) {
|
||||
dol_print_error('', $user->error);
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
|
||||
@ -82,12 +85,12 @@ $obj->lines[]=$line1;
|
||||
|
||||
// Create invoice
|
||||
$idobject=$obj->create($user);
|
||||
if ($idobject > 0)
|
||||
{
|
||||
if ($idobject > 0) {
|
||||
// Change status to validated
|
||||
$result=$obj->validate($user);
|
||||
if ($result > 0) print "OK Object created with id ".$idobject."\n";
|
||||
else {
|
||||
if ($result > 0) {
|
||||
print "OK Object created with id ".$idobject."\n";
|
||||
} else {
|
||||
$error++;
|
||||
dol_print_error($db, $obj->error);
|
||||
}
|
||||
@ -99,8 +102,7 @@ if ($idobject > 0)
|
||||
|
||||
// -------------------- END OF YOUR CODE --------------------
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
print '--- end ok'."\n";
|
||||
} else {
|
||||
|
||||
@ -29,8 +29,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@ -49,7 +49,10 @@ $langs->load("main"); // To load language file for default language
|
||||
|
||||
// Load user and its permissions
|
||||
$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||
if (! $result > 0) { dol_print_error('', $user->error); exit; }
|
||||
if (! $result > 0) {
|
||||
dol_print_error('', $user->error);
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
|
||||
@ -80,12 +83,12 @@ $com->lines[]=$orderline1;
|
||||
|
||||
// Create order
|
||||
$idobject=$com->create($user);
|
||||
if ($idobject > 0)
|
||||
{
|
||||
if ($idobject > 0) {
|
||||
// Change status to validated
|
||||
$result=$com->valid($user);
|
||||
if ($result > 0) print "OK Object created with id ".$idobject."\n";
|
||||
else {
|
||||
if ($result > 0) {
|
||||
print "OK Object created with id ".$idobject."\n";
|
||||
} else {
|
||||
$error++;
|
||||
dol_print_error($db, $com->error);
|
||||
}
|
||||
@ -97,8 +100,7 @@ if ($idobject > 0)
|
||||
|
||||
// -------------------- END OF YOUR CODE --------------------
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
print '--- end ok'."\n";
|
||||
} else {
|
||||
|
||||
@ -29,8 +29,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@ -49,7 +49,10 @@ $langs->load("main"); // To load language file for default language
|
||||
|
||||
// Load user and its permissions
|
||||
$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||
if (! $result > 0) { dol_print_error('', $user->error); exit; }
|
||||
if (! $result > 0) {
|
||||
dol_print_error('', $user->error);
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
|
||||
@ -79,8 +82,7 @@ $myproduct->weight_units = 0;
|
||||
|
||||
// Create product in database
|
||||
$idobject = $myproduct->create($user);
|
||||
if ($idobject > 0)
|
||||
{
|
||||
if ($idobject > 0) {
|
||||
print "OK Object created with id ".$idobject."\n";
|
||||
} else {
|
||||
$error++;
|
||||
@ -89,8 +91,7 @@ if ($idobject > 0)
|
||||
|
||||
// -------------------- END OF YOUR CODE --------------------
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
print '--- end ok'."\n";
|
||||
} else {
|
||||
|
||||
@ -29,8 +29,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@ -49,7 +49,10 @@ $langs->load("main"); // To load language file for default language
|
||||
|
||||
// Load user and its permissions
|
||||
$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||
if (! $result > 0) { dol_print_error('', $user->error); exit; }
|
||||
if (! $result > 0) {
|
||||
dol_print_error('', $user->error);
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
|
||||
@ -69,18 +72,17 @@ $obj->nom = 'ABCDEF';
|
||||
|
||||
// Create user
|
||||
$idobject=$obj->create($user);
|
||||
if ($idobject > 0)
|
||||
{
|
||||
if ($idobject > 0) {
|
||||
// Change status to validated
|
||||
$result=$obj->setStatut(1);
|
||||
if ($result > 0) print "OK Object created with id ".$idobject."\n";
|
||||
else {
|
||||
if ($result > 0) {
|
||||
print "OK Object created with id ".$idobject."\n";
|
||||
} else {
|
||||
$error++;
|
||||
dol_print_error($db, $obj->error);
|
||||
}
|
||||
} elseif ($obj->error == 'ErrorLoginAlreadyExists')
|
||||
{
|
||||
print "User with login ".$obj->login." already exists\n";
|
||||
} elseif ($obj->error == 'ErrorLoginAlreadyExists') {
|
||||
print "User with login ".$obj->login." already exists\n";
|
||||
} else {
|
||||
$error++;
|
||||
dol_print_error($db, $obj->error);
|
||||
@ -89,8 +91,7 @@ if ($idobject > 0)
|
||||
|
||||
// -------------------- END OF YOUR CODE --------------------
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $error) {
|
||||
$db->commit();
|
||||
print '--- end ok'."\n";
|
||||
} else {
|
||||
|
||||
@ -29,8 +29,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Global variables
|
||||
@ -49,14 +49,17 @@ $langs->load("main"); // To load language file for default language
|
||||
|
||||
// Load user and its permissions
|
||||
$result=$user->fetch('', 'admin'); // Load user for login 'admin'. Comment line to run as anonymous user.
|
||||
if (! $result > 0) { dol_print_error('', $user->error); exit; }
|
||||
if (! $result > 0) {
|
||||
dol_print_error('', $user->error);
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
|
||||
print "***** ".$script_file." (".$version.") *****\n";
|
||||
if (! isset($argv[1])) { // Check parameters
|
||||
print "Usage: ".$script_file." id_thirdparty ...\n";
|
||||
exit;
|
||||
print "Usage: ".$script_file." id_thirdparty ...\n";
|
||||
exit;
|
||||
}
|
||||
print '--- start'."\n";
|
||||
print 'Argument id_thirdparty='.$argv[1]."\n";
|
||||
|
||||
@ -1,68 +1,6 @@
|
||||
# HOW TO BUILD
|
||||
|
||||
Take a look at the dolibarr wiki page of Zapier module:
|
||||
|
||||
## 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.
|
||||
https://wiki.dolibarr.org/index.php?title=Module_Zapier
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ $script_file = basename(__FILE__);
|
||||
|
||||
$path = dirname(__FILE__) . '/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -62,40 +62,40 @@ $startlinenb = empty($argv[3]) ? 1 : (int) $argv[3];
|
||||
$endlinenb = empty($argv[4]) ? 0 : (int) $argv[4];
|
||||
|
||||
if (empty($filepath)) {
|
||||
print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n";
|
||||
print "Example: php $script_file myfilepath.dbf 0 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Usage: php $script_file myfilepath.dbf [removeChatColumnName] [startlinenb] [endlinenb]\n";
|
||||
print "Example: php $script_file myfilepath.dbf 0 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
if (!file_exists($filepath)) {
|
||||
print "Error: File " . $filepath . " not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: File " . $filepath . " not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret = $user->fetch('', 'admin');
|
||||
if (!$ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
// Ask confirmation
|
||||
if (!$confirmed) {
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
$fhandle = dbase_open($filepath, 0);
|
||||
if (!$fhandle) {
|
||||
print 'Error: Failed to open file ' . $filepath . "\n";
|
||||
exit(1);
|
||||
print 'Error: Failed to open file ' . $filepath . "\n";
|
||||
exit(1);
|
||||
}
|
||||
$fhandleerr = fopen($filepatherr, 'w');
|
||||
if (!$fhandleerr) {
|
||||
print 'Error: Failed to open file ' . $filepatherr . "\n";
|
||||
exit(1);
|
||||
print 'Error: Failed to open file ' . $filepatherr . "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$langs->setDefaultLang($defaultlang);
|
||||
@ -105,23 +105,23 @@ $table_name = substr(basename($filepath), 0, strpos(basename($filepath), '.'));
|
||||
print 'Info: ' . $record_numbers . " lines in file \n";
|
||||
$header = dbase_get_header_info($fhandle);
|
||||
if ($deleteTable) {
|
||||
$db->query("DROP TABLE IF EXISTS `$table_name`");
|
||||
$db->query("DROP TABLE IF EXISTS `$table_name`");
|
||||
}
|
||||
$sqlCreate = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` INT(11) NOT NULL AUTO_INCREMENT ";
|
||||
$fieldArray = array("`id`");
|
||||
foreach ($header as $value) {
|
||||
$fieldName = substr(str_replace('_', '', $value['name']), $startchar);
|
||||
$fieldArray[] = "`$fieldName`";
|
||||
$sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL ";
|
||||
$fieldName = substr(str_replace('_', '', $value['name']), $startchar);
|
||||
$fieldArray[] = "`$fieldName`";
|
||||
$sqlCreate .= ", `" . $fieldName . "` VARCHAR({$value['length']}) NULL DEFAULT NULL ";
|
||||
}
|
||||
$sqlCreate .= ", PRIMARY KEY (`id`)) ENGINE = InnoDB";
|
||||
$resql = $db->query($sqlCreate);
|
||||
if ($resql !== false) {
|
||||
print "Table $table_name created\n";
|
||||
print "Table $table_name created\n";
|
||||
} else {
|
||||
var_dump($db->errno());
|
||||
print "Impossible : " . $sqlCreate . "\n";
|
||||
die();
|
||||
var_dump($db->errno());
|
||||
print "Impossible : " . $sqlCreate . "\n";
|
||||
die();
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
@ -131,30 +131,33 @@ $fields = implode(',', $fieldArray);
|
||||
//var_dump($fieldArray);die();
|
||||
$maxLength = 0;
|
||||
for ($i = 1; $i <= $record_numbers; $i++) {
|
||||
if ($startlinenb && $i < $startlinenb)
|
||||
continue;
|
||||
if ($endlinenb && $i > $endlinenb)
|
||||
continue;
|
||||
$row = dbase_get_record_with_names($fhandle, $i);
|
||||
if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1'))
|
||||
continue;
|
||||
$sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,";
|
||||
array_shift($row); // remove delete column
|
||||
foreach ($row as $value) {
|
||||
$sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', ";
|
||||
}
|
||||
replaceable_echo(implode("\t", $row));
|
||||
$sqlInsert = rtrim($sqlInsert, ', ');
|
||||
$sqlInsert .= ")";
|
||||
$resql = $db->query($sqlInsert);
|
||||
if ($resql === false) {
|
||||
print "Impossible : " . $sqlInsert . "\n";
|
||||
var_dump($row, $db->errno());
|
||||
die();
|
||||
}
|
||||
if ($startlinenb && $i < $startlinenb) {
|
||||
continue;
|
||||
}
|
||||
if ($endlinenb && $i > $endlinenb) {
|
||||
continue;
|
||||
}
|
||||
$row = dbase_get_record_with_names($fhandle, $i);
|
||||
if ($row === false || (isset($row["deleted"]) && $row["deleted"] == '1')) {
|
||||
continue;
|
||||
}
|
||||
$sqlInsert = "INSERT INTO `$table_name`($fields) VALUES (null,";
|
||||
array_shift($row); // remove delete column
|
||||
foreach ($row as $value) {
|
||||
$sqlInsert .= "'" . $db->escape(utf8_encode($value)) . "', ";
|
||||
}
|
||||
replaceable_echo(implode("\t", $row));
|
||||
$sqlInsert = rtrim($sqlInsert, ', ');
|
||||
$sqlInsert .= ")";
|
||||
$resql = $db->query($sqlInsert);
|
||||
if ($resql === false) {
|
||||
print "Impossible : " . $sqlInsert . "\n";
|
||||
var_dump($row, $db->errno());
|
||||
die();
|
||||
}
|
||||
// $fields = (object) $row;
|
||||
// var_dump($fields);
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
die();
|
||||
|
||||
@ -166,11 +169,11 @@ die();
|
||||
print "Nb of lines qualified: " . $nboflines . "\n";
|
||||
print "Nb of errors: " . $error . "\n";
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
} else {
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
@ -189,43 +192,43 @@ exit($error);
|
||||
*/
|
||||
function replaceable_echo($message, $force_clear_lines = null)
|
||||
{
|
||||
static $last_lines = 0;
|
||||
static $last_lines = 0;
|
||||
|
||||
if (!is_null($force_clear_lines)) {
|
||||
$last_lines = $force_clear_lines;
|
||||
}
|
||||
if (!is_null($force_clear_lines)) {
|
||||
$last_lines = $force_clear_lines;
|
||||
}
|
||||
|
||||
$toss = array();
|
||||
$status = 0;
|
||||
$term_width = exec('tput cols', $toss, $status);
|
||||
if ($status) {
|
||||
$term_width = 64; // Arbitrary fall-back term width.
|
||||
}
|
||||
$toss = array();
|
||||
$status = 0;
|
||||
$term_width = exec('tput cols', $toss, $status);
|
||||
if ($status) {
|
||||
$term_width = 64; // Arbitrary fall-back term width.
|
||||
}
|
||||
|
||||
$line_count = 0;
|
||||
foreach (explode("\n", $message) as $line) {
|
||||
$line_count += count(str_split($line, $term_width));
|
||||
}
|
||||
$line_count = 0;
|
||||
foreach (explode("\n", $message) as $line) {
|
||||
$line_count += count(str_split($line, $term_width));
|
||||
}
|
||||
|
||||
// Erasure MAGIC: Clear as many lines as the last output had.
|
||||
for ($i = 0; $i < $last_lines; $i++) {
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Erase to the end of the line
|
||||
echo "\033[K";
|
||||
// Move cursor Up a line
|
||||
echo "\033[1A";
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Erase to the end of the line
|
||||
echo "\033[K";
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Can be consolodated into
|
||||
// echo "\r\033[K\033[1A\r\033[K\r";
|
||||
}
|
||||
// Erasure MAGIC: Clear as many lines as the last output had.
|
||||
for ($i = 0; $i < $last_lines; $i++) {
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Erase to the end of the line
|
||||
echo "\033[K";
|
||||
// Move cursor Up a line
|
||||
echo "\033[1A";
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Erase to the end of the line
|
||||
echo "\033[K";
|
||||
// Return to the beginning of the line
|
||||
echo "\r";
|
||||
// Can be consolodated into
|
||||
// echo "\r\033[K\033[1A\r\033[K\r";
|
||||
}
|
||||
|
||||
$last_lines = $line_count;
|
||||
$last_lines = $line_count;
|
||||
|
||||
echo $message . "\n";
|
||||
echo $message . "\n";
|
||||
}
|
||||
|
||||
@ -29,8 +29,8 @@ $sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path = dirname(__FILE__) . '/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -50,18 +50,18 @@ $confirmed = 1;
|
||||
$error = 0;
|
||||
|
||||
$tvas = [
|
||||
'1' => "20.00",
|
||||
'2' => "5.50",
|
||||
'3' => "0.00",
|
||||
'4' => "20.60",
|
||||
'5' => "19.60",
|
||||
'1' => "20.00",
|
||||
'2' => "5.50",
|
||||
'3' => "0.00",
|
||||
'4' => "20.60",
|
||||
'5' => "19.60",
|
||||
];
|
||||
$tvasD = [
|
||||
'1' => "20",
|
||||
'2' => "5.5",
|
||||
'3' => "0",
|
||||
'4' => "20",
|
||||
'5' => "20",
|
||||
'1' => "20",
|
||||
'2' => "5.5",
|
||||
'3' => "0",
|
||||
'4' => "20",
|
||||
'5' => "20",
|
||||
];
|
||||
|
||||
/*
|
||||
@ -75,159 +75,167 @@ dol_syslog($script_file . " launched with arg " . implode(',', $argv));
|
||||
$table = $argv[1];
|
||||
|
||||
if (empty($argv[1])) {
|
||||
print "Error: Which table ?\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: Which table ?\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret = $user->fetch('', 'admin');
|
||||
if (!$ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `$table` WHERE 1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
while ($fields = $db->fetch_array($resql)) {
|
||||
$errorrecord = 0;
|
||||
if ($fields === false)
|
||||
continue;
|
||||
$nboflines++;
|
||||
|
||||
$produit = new Product($db);
|
||||
$produit->type = 0;
|
||||
$produit->status = 1;
|
||||
$produit->ref = trim($fields['REF']);
|
||||
if ($produit->ref == '')
|
||||
continue;
|
||||
print "Process line nb " . $j . ", ref " . $produit->ref;
|
||||
$produit->label = trim($fields['LIBELLE']);
|
||||
if ($produit->label == '')
|
||||
$produit->label = $produit->ref;
|
||||
if (empty($produit->label))
|
||||
continue;
|
||||
//$produit->description = trim($fields[4] . "\n" . ($fields[5] ? $fields[5] . ' x ' . $fields[6] . ' x ' . $fields[7] : ''));
|
||||
// $produit->volume = price2num($fields[8]);
|
||||
// $produit->volume_unit = 0;
|
||||
$produit->weight = price2num($fields['MASSE']);
|
||||
$produit->weight_units = 0; // -3 = g
|
||||
//$produit->customcode = $fields[10];
|
||||
$produit->barcode = str_pad($fields['CODE'], 12, "0", STR_PAD_LEFT);
|
||||
$produit->barcode_type = '2';
|
||||
$produit->import_key = $fields['CODE'];
|
||||
|
||||
$produit->status = 1;
|
||||
$produit->status_buy = 1;
|
||||
|
||||
$produit->finished = 1;
|
||||
|
||||
// $produit->multiprices[0] = price2num($fields['TARIF0']);
|
||||
// $produit->multiprices[1] = price2num($fields['TARIF1']);
|
||||
// $produit->multiprices[2] = price2num($fields['TARIF2']);
|
||||
// $produit->multiprices[3] = price2num($fields['TARIF3']);
|
||||
// $produit->multiprices[4] = price2num($fields['TARIF4']);
|
||||
// $produit->multiprices[5] = price2num($fields['TARIF5']);
|
||||
// $produit->multiprices[6] = price2num($fields['TARIF6']);
|
||||
// $produit->multiprices[7] = price2num($fields['TARIF7']);
|
||||
// $produit->multiprices[8] = price2num($fields['TARIF8']);
|
||||
// $produit->multiprices[9] = price2num($fields['TARIF9']);
|
||||
// $produit->price_min = null;
|
||||
// $produit->price_min_ttc = null;
|
||||
// $produit->price = price2num($fields[11]);
|
||||
// $produit->price_ttc = price2num($fields[12]);
|
||||
// $produit->price_base_type = 'TTC';
|
||||
// $produit->tva_tx = price2num($fields[13]);
|
||||
$produit->tva_tx = (int) ($tvas[$fields['CODTVA']]);
|
||||
$produit->tva_npr = 0;
|
||||
// $produit->cost_price = price2num($fields[16]);
|
||||
//compta
|
||||
|
||||
$produit->accountancy_code_buy = trim($fields['COMACH']);
|
||||
$produit->accountancy_code_sell = trim($fields['COMVEN']);
|
||||
// $produit->accountancy_code_sell_intra=trim($fields['COMVEN']);
|
||||
// $produit->accountancy_code_sell_export=trim($fields['COMVEN']);
|
||||
// Extrafields
|
||||
// $produit->array_options['options_ecotaxdeee'] = price2num($fields[17]);
|
||||
|
||||
$produit->seuil_stock_alerte = $fields['STALERTE'];
|
||||
$ret = $produit->create($user, 0);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = " . $ret . " - " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with ref " . $produit->ref . " - id = " . $ret;
|
||||
}
|
||||
|
||||
dol_syslog("Add prices");
|
||||
|
||||
// If we use price level, insert price for each level
|
||||
if (!$errorrecord && 1) {
|
||||
//$ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
|
||||
$ret1 = false;
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
if ($fields['TARIF' . ($i)] == 0)
|
||||
continue;
|
||||
$ret1 = $ret1 || $produit->updatePrice(price2num($fields['TARIF' . ($i)]), 'HT', $user, $produit->tva_tx, $produit->price_min, $i + 1, $produit->tva_npr, 0, 0, array()) < 0;
|
||||
if ($resql) {
|
||||
while ($fields = $db->fetch_array($resql)) {
|
||||
$errorrecord = 0;
|
||||
if ($fields === false) {
|
||||
continue;
|
||||
}
|
||||
if ($ret1) {
|
||||
print " - Error in updatePrice result " . $produit->errorsToString();
|
||||
$nboflines++;
|
||||
|
||||
$produit = new Product($db);
|
||||
$produit->type = 0;
|
||||
$produit->status = 1;
|
||||
$produit->ref = trim($fields['REF']);
|
||||
if ($produit->ref == '') {
|
||||
continue;
|
||||
}
|
||||
print "Process line nb " . $j . ", ref " . $produit->ref;
|
||||
$produit->label = trim($fields['LIBELLE']);
|
||||
if ($produit->label == '') {
|
||||
$produit->label = $produit->ref;
|
||||
}
|
||||
if (empty($produit->label)) {
|
||||
continue;
|
||||
}
|
||||
//$produit->description = trim($fields[4] . "\n" . ($fields[5] ? $fields[5] . ' x ' . $fields[6] . ' x ' . $fields[7] : ''));
|
||||
// $produit->volume = price2num($fields[8]);
|
||||
// $produit->volume_unit = 0;
|
||||
$produit->weight = price2num($fields['MASSE']);
|
||||
$produit->weight_units = 0; // -3 = g
|
||||
//$produit->customcode = $fields[10];
|
||||
$produit->barcode = str_pad($fields['CODE'], 12, "0", STR_PAD_LEFT);
|
||||
$produit->barcode_type = '2';
|
||||
$produit->import_key = $fields['CODE'];
|
||||
|
||||
$produit->status = 1;
|
||||
$produit->status_buy = 1;
|
||||
|
||||
$produit->finished = 1;
|
||||
|
||||
// $produit->multiprices[0] = price2num($fields['TARIF0']);
|
||||
// $produit->multiprices[1] = price2num($fields['TARIF1']);
|
||||
// $produit->multiprices[2] = price2num($fields['TARIF2']);
|
||||
// $produit->multiprices[3] = price2num($fields['TARIF3']);
|
||||
// $produit->multiprices[4] = price2num($fields['TARIF4']);
|
||||
// $produit->multiprices[5] = price2num($fields['TARIF5']);
|
||||
// $produit->multiprices[6] = price2num($fields['TARIF6']);
|
||||
// $produit->multiprices[7] = price2num($fields['TARIF7']);
|
||||
// $produit->multiprices[8] = price2num($fields['TARIF8']);
|
||||
// $produit->multiprices[9] = price2num($fields['TARIF9']);
|
||||
// $produit->price_min = null;
|
||||
// $produit->price_min_ttc = null;
|
||||
// $produit->price = price2num($fields[11]);
|
||||
// $produit->price_ttc = price2num($fields[12]);
|
||||
// $produit->price_base_type = 'TTC';
|
||||
// $produit->tva_tx = price2num($fields[13]);
|
||||
$produit->tva_tx = (int) ($tvas[$fields['CODTVA']]);
|
||||
$produit->tva_npr = 0;
|
||||
// $produit->cost_price = price2num($fields[16]);
|
||||
//compta
|
||||
|
||||
$produit->accountancy_code_buy = trim($fields['COMACH']);
|
||||
$produit->accountancy_code_sell = trim($fields['COMVEN']);
|
||||
// $produit->accountancy_code_sell_intra=trim($fields['COMVEN']);
|
||||
// $produit->accountancy_code_sell_export=trim($fields['COMVEN']);
|
||||
// Extrafields
|
||||
// $produit->array_options['options_ecotaxdeee'] = price2num($fields[17]);
|
||||
|
||||
$produit->seuil_stock_alerte = $fields['STALERTE'];
|
||||
$ret = $produit->create($user, 0);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = " . $ret . " - " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - updatePrice OK";
|
||||
print " - Creation OK with ref " . $produit->ref . " - id = " . $ret;
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("Add prices");
|
||||
|
||||
// dol_syslog("Add multilangs");
|
||||
// Add alternative languages
|
||||
// if (!$errorrecord && 1) {
|
||||
// $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private);
|
||||
// $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private);
|
||||
//
|
||||
// $ret = $produit->setMultiLangs($user);
|
||||
// if ($ret < 0) {
|
||||
// print " - Error in setMultiLangs result code = " . $ret . " - " . $produit->errorsToString();
|
||||
// $errorrecord++;
|
||||
// } else {
|
||||
// print " - setMultiLangs OK";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
dol_syslog("Add stocks");
|
||||
// stocks
|
||||
if (!$errorrecord && $fields['STOCK'] != 0) {
|
||||
$rets = $produit->correct_stock($user, 1, $fields['STOCK'], 0, 'Stock importé');
|
||||
if ($rets < 0) {
|
||||
print " - Error in correct_stock result " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - correct_stock OK";
|
||||
// If we use price level, insert price for each level
|
||||
if (!$errorrecord && 1) {
|
||||
//$ret1 = $produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
|
||||
$ret1 = false;
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
if ($fields['TARIF' . ($i)] == 0) {
|
||||
continue;
|
||||
}
|
||||
$ret1 = $ret1 || $produit->updatePrice(price2num($fields['TARIF' . ($i)]), 'HT', $user, $produit->tva_tx, $produit->price_min, $i + 1, $produit->tva_npr, 0, 0, array()) < 0;
|
||||
}
|
||||
if ($ret1) {
|
||||
print " - Error in updatePrice result " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - updatePrice OK";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//update date créa
|
||||
if (!$errorrecord) {
|
||||
$date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2);
|
||||
$retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id");
|
||||
if ($retd < 1) {
|
||||
print " - Error in update date créa result " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - update date créa OK";
|
||||
|
||||
// dol_syslog("Add multilangs");
|
||||
// Add alternative languages
|
||||
// if (!$errorrecord && 1) {
|
||||
// $produit->multilangs['fr_FR'] = array('label' => $produit->label, 'description' => $produit->description, 'note' => $produit->note_private);
|
||||
// $produit->multilangs['en_US'] = array('label' => $fields[3], 'description' => $produit->description, 'note' => $produit->note_private);
|
||||
//
|
||||
// $ret = $produit->setMultiLangs($user);
|
||||
// if ($ret < 0) {
|
||||
// print " - Error in setMultiLangs result code = " . $ret . " - " . $produit->errorsToString();
|
||||
// $errorrecord++;
|
||||
// } else {
|
||||
// print " - setMultiLangs OK";
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
dol_syslog("Add stocks");
|
||||
// stocks
|
||||
if (!$errorrecord && $fields['STOCK'] != 0) {
|
||||
$rets = $produit->correct_stock($user, 1, $fields['STOCK'], 0, 'Stock importé');
|
||||
if ($rets < 0) {
|
||||
print " - Error in correct_stock result " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - correct_stock OK";
|
||||
}
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord) {
|
||||
print( 'Error on record nb ' . $i . " - " . $produit->errorsToString() . "\n");
|
||||
var_dump($db);
|
||||
die();
|
||||
$error++; // $errorrecord will be reset
|
||||
//update date créa
|
||||
if (!$errorrecord) {
|
||||
$date = substr($fields['DATCREA'], 0, 4) . '-' . substr($fields['DATCREA'], 4, 2) . '-' . substr($fields['DATCREA'], 6, 2);
|
||||
$retd = $db->query("UPDATE `llx_product` SET `datec` = '$date 00:00:00' WHERE `llx_product`.`rowid` = $produit->id");
|
||||
if ($retd < 1) {
|
||||
print " - Error in update date créa result " . $produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - update date créa OK";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord) {
|
||||
print( 'Error on record nb ' . $i . " - " . $produit->errorsToString() . "\n");
|
||||
var_dump($db);
|
||||
die();
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
$j++;
|
||||
} else die("error : $sql");
|
||||
} else {
|
||||
die("error : $sql");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@ $sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path = dirname(__FILE__) . '/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -50,73 +50,73 @@ $confirmed = 1;
|
||||
$error = 0;
|
||||
|
||||
$civilPrivate = array("MLLE",
|
||||
"MM",
|
||||
"MM/MADAME",
|
||||
"MME",
|
||||
"MME.",
|
||||
"MME²",
|
||||
"MMONSIEUR",
|
||||
"MMR",
|
||||
"MOBNSIEUR",
|
||||
"MOMSIEUR",
|
||||
"MON SIEUR",
|
||||
"MONDIAL",
|
||||
"MONIEUR",
|
||||
"MONJSIEUR",
|
||||
"MONNSIEUR",
|
||||
"MONRIEUR",
|
||||
"MONS",
|
||||
"MONSIEÕR",
|
||||
"MONSIER",
|
||||
"MONSIERU",
|
||||
"MONSIEU",
|
||||
"monsieue",
|
||||
"MONSIEUR",
|
||||
"Monsieur \"",
|
||||
"MONSIEUR \"",
|
||||
"MONSIEUR E",
|
||||
"MONSIEUR DENIS",
|
||||
"MONSIEUR ET MME",
|
||||
"MONSIEUR!",
|
||||
"MONSIEUR.",
|
||||
"MONSIEUR.MADAME",
|
||||
"MONSIEUR3",
|
||||
"MONSIEURN",
|
||||
"MONSIEURT",
|
||||
"MONSIEUR£",
|
||||
"MONSIEYR",
|
||||
"Monsigur",
|
||||
"MONSIIEUR",
|
||||
"MONSIUER",
|
||||
"MONSIZEUR",
|
||||
"MOPNSIEUR",
|
||||
"MOSIEUR",
|
||||
"MR",
|
||||
"Mr Mme",
|
||||
"Mr - MME",
|
||||
"MR BLANC",
|
||||
"MR ET MME",
|
||||
"mr mm",
|
||||
"MR OU MME",
|
||||
"Mr.",
|
||||
"MR/MME",
|
||||
"MRME",
|
||||
"MRR",
|
||||
"Mrs",
|
||||
"Mademoiselle",
|
||||
"MADAOME",
|
||||
"madamme",
|
||||
"MADAME",
|
||||
"M0NSIEUR",
|
||||
"M.et Madame",
|
||||
"M. ET MR",
|
||||
"M.",
|
||||
"M%",
|
||||
"M MME",
|
||||
"M ET MME",
|
||||
"M",
|
||||
"M CROCE",
|
||||
"M DIEVART",
|
||||
"MM",
|
||||
"MM/MADAME",
|
||||
"MME",
|
||||
"MME.",
|
||||
"MME²",
|
||||
"MMONSIEUR",
|
||||
"MMR",
|
||||
"MOBNSIEUR",
|
||||
"MOMSIEUR",
|
||||
"MON SIEUR",
|
||||
"MONDIAL",
|
||||
"MONIEUR",
|
||||
"MONJSIEUR",
|
||||
"MONNSIEUR",
|
||||
"MONRIEUR",
|
||||
"MONS",
|
||||
"MONSIEÕR",
|
||||
"MONSIER",
|
||||
"MONSIERU",
|
||||
"MONSIEU",
|
||||
"monsieue",
|
||||
"MONSIEUR",
|
||||
"Monsieur \"",
|
||||
"MONSIEUR \"",
|
||||
"MONSIEUR E",
|
||||
"MONSIEUR DENIS",
|
||||
"MONSIEUR ET MME",
|
||||
"MONSIEUR!",
|
||||
"MONSIEUR.",
|
||||
"MONSIEUR.MADAME",
|
||||
"MONSIEUR3",
|
||||
"MONSIEURN",
|
||||
"MONSIEURT",
|
||||
"MONSIEUR£",
|
||||
"MONSIEYR",
|
||||
"Monsigur",
|
||||
"MONSIIEUR",
|
||||
"MONSIUER",
|
||||
"MONSIZEUR",
|
||||
"MOPNSIEUR",
|
||||
"MOSIEUR",
|
||||
"MR",
|
||||
"Mr Mme",
|
||||
"Mr - MME",
|
||||
"MR BLANC",
|
||||
"MR ET MME",
|
||||
"mr mm",
|
||||
"MR OU MME",
|
||||
"Mr.",
|
||||
"MR/MME",
|
||||
"MRME",
|
||||
"MRR",
|
||||
"Mrs",
|
||||
"Mademoiselle",
|
||||
"MADAOME",
|
||||
"madamme",
|
||||
"MADAME",
|
||||
"M0NSIEUR",
|
||||
"M.et Madame",
|
||||
"M. ET MR",
|
||||
"M.",
|
||||
"M%",
|
||||
"M MME",
|
||||
"M ET MME",
|
||||
"M",
|
||||
"M CROCE",
|
||||
"M DIEVART",
|
||||
);
|
||||
|
||||
/*
|
||||
@ -130,128 +130,134 @@ dol_syslog($script_file . " launched with arg " . implode(',', $argv));
|
||||
$table = $argv[1];
|
||||
|
||||
if (empty($argv[1])) {
|
||||
print "Error: Quelle table ?\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: Quelle table ?\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret = $user->fetch('', 'admin');
|
||||
if (!$ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.' . "\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM `$table` WHERE 1 "; //ORDER BY REMISE DESC,`LCIVIL` DESC";
|
||||
$resql = $db->query($sql);
|
||||
//$db->begin();
|
||||
if ($resql)
|
||||
while ($fields = $db->fetch_array($resql)) {
|
||||
$i++;
|
||||
$errorrecord = 0;
|
||||
if ($resql) {
|
||||
while ($fields = $db->fetch_array($resql)) {
|
||||
$i++;
|
||||
$errorrecord = 0;
|
||||
|
||||
if ($startlinenb && $i < $startlinenb)
|
||||
continue;
|
||||
if ($endlinenb && $i > $endlinenb)
|
||||
continue;
|
||||
|
||||
$nboflines++;
|
||||
|
||||
$object = new Societe($db);
|
||||
$object->import_key = $fields['CODE'];
|
||||
$object->state = 1;
|
||||
$object->client = 3;
|
||||
$object->fournisseur = 0;
|
||||
|
||||
$object->name = $fields['FCIVIL'] . ' ' . $fields['FNOM'];
|
||||
//$object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : '';
|
||||
|
||||
$date = $fields['DATCREA'] ? $fields['DATCREA'] : ($fields['DATMOD'] ? $fields['DATMOD'] : '20200101');
|
||||
$object->code_client = 'CU' . substr($date, 2, 2) . substr($date, 4, 2) . '-' . str_pad(substr($fields['CODE'], 0, 5), 5, "0", STR_PAD_LEFT);
|
||||
|
||||
|
||||
$object->address = trim($fields['FADR1']);
|
||||
if ($fields['FADR2'])
|
||||
$object->address .= "\n" . trim($fields['FADR2']);
|
||||
if ($fields['FADR3'])
|
||||
$object->address .= "\n" . trim($fields['FADR3']);
|
||||
|
||||
$object->zip = trim($fields['FPOSTE']);
|
||||
$object->town = trim($fields['FVILLE']);
|
||||
if ($fields['FPAYS'])
|
||||
$object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid');
|
||||
else $object->country_id = 1;
|
||||
$object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']);
|
||||
$object->phone = substr($object->phone, 0, 20);
|
||||
$object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']);
|
||||
$object->fax = substr($object->fax, 0, 20);
|
||||
$object->email = trim($fields['FMAIL']);
|
||||
// $object->idprof2 = trim($fields[29]);
|
||||
$object->tva_intra = str_replace(['.', ' '], '', $fields['TVAINTRA']);
|
||||
$object->tva_intra = substr($object->tva_intra, 0, 20);
|
||||
$object->default_lang = 'fr_FR';
|
||||
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, 'PT_ORDER', 'c_payment_term', 'code', 'rowid', 1);
|
||||
$object->multicurrency_code = 'EUR';
|
||||
|
||||
if ($fields['REMISE'] != '0.00') {
|
||||
$object->remise_percent = abs($fields['REMISE']);
|
||||
}
|
||||
|
||||
// $object->code_client = $fields[9];
|
||||
// $object->code_fournisseur = $fields[10];
|
||||
|
||||
|
||||
if ($fields['FCIVIL']) {
|
||||
$labeltype = in_array($fields['FCIVIL'], $civilPrivate) ? 'TE_PRIVATE' : 'TE_SMALL';
|
||||
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'code');
|
||||
}
|
||||
|
||||
// Set price level
|
||||
$object->price_level = $fields['TARIF'] + 1;
|
||||
// if ($labeltype == 'Revendeur')
|
||||
// $object->price_level = 2;
|
||||
|
||||
print "Process line nb " . $i . ", code " . $fields['CODE'] . ", name " . $object->name;
|
||||
|
||||
|
||||
// Extrafields
|
||||
$object->array_options['options_banque'] = $fields['BANQUE'];
|
||||
$object->array_options['options_banque2'] = $fields['BANQUE2'];
|
||||
$object->array_options['options_banquevalid'] = $fields['VALID'];
|
||||
|
||||
if (!$errorrecord) {
|
||||
$ret = $object->create($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = " . $ret . " - " . $object->errorsToString();
|
||||
$errorrecord++;
|
||||
var_dump($object->code_client, $db);
|
||||
die();
|
||||
} else {
|
||||
print " - Creation OK with name " . $object->name . " - id = " . $ret;
|
||||
if ($startlinenb && $i < $startlinenb) {
|
||||
continue;
|
||||
}
|
||||
if ($endlinenb && $i > $endlinenb) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$errorrecord) {
|
||||
dol_syslog("Set price level");
|
||||
$object->set_price_level($object->price_level, $user);
|
||||
}
|
||||
if (!$errorrecord && @$object->remise_percent) {
|
||||
dol_syslog("Set remise client");
|
||||
$object->set_remise_client($object->remise_percent, 'Importé', $user);
|
||||
}
|
||||
$nboflines++;
|
||||
|
||||
dol_syslog("Add contact");
|
||||
// Insert an invoice contact if there is an invoice email != standard email
|
||||
if (!$errorrecord && ($fields['LCIVIL'] || $fields['LNOM'])) {
|
||||
$madame = array("MADAME",
|
||||
$object = new Societe($db);
|
||||
$object->import_key = $fields['CODE'];
|
||||
$object->state = 1;
|
||||
$object->client = 3;
|
||||
$object->fournisseur = 0;
|
||||
|
||||
$object->name = $fields['FCIVIL'] . ' ' . $fields['FNOM'];
|
||||
//$object->name_alias = $fields[0] != $fields[13] ? trim($fields[0]) : '';
|
||||
|
||||
$date = $fields['DATCREA'] ? $fields['DATCREA'] : ($fields['DATMOD'] ? $fields['DATMOD'] : '20200101');
|
||||
$object->code_client = 'CU' . substr($date, 2, 2) . substr($date, 4, 2) . '-' . str_pad(substr($fields['CODE'], 0, 5), 5, "0", STR_PAD_LEFT);
|
||||
|
||||
|
||||
$object->address = trim($fields['FADR1']);
|
||||
if ($fields['FADR2']) {
|
||||
$object->address .= "\n" . trim($fields['FADR2']);
|
||||
}
|
||||
if ($fields['FADR3']) {
|
||||
$object->address .= "\n" . trim($fields['FADR3']);
|
||||
}
|
||||
|
||||
$object->zip = trim($fields['FPOSTE']);
|
||||
$object->town = trim($fields['FVILLE']);
|
||||
if ($fields['FPAYS']) {
|
||||
$object->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['FPAYS']))), 'c_country', 'label', 'rowid');
|
||||
} else {
|
||||
$object->country_id = 1;
|
||||
}
|
||||
$object->phone = trim($fields['FTEL']) ? trim($fields['FTEL']) : trim($fields['FCONTACT']);
|
||||
$object->phone = substr($object->phone, 0, 20);
|
||||
$object->fax = trim($fields['FFAX']) ? trim($fields['FFAX']) : trim($fields['FCONTACT']);
|
||||
$object->fax = substr($object->fax, 0, 20);
|
||||
$object->email = trim($fields['FMAIL']);
|
||||
// $object->idprof2 = trim($fields[29]);
|
||||
$object->tva_intra = str_replace(['.', ' '], '', $fields['TVAINTRA']);
|
||||
$object->tva_intra = substr($object->tva_intra, 0, 20);
|
||||
$object->default_lang = 'fr_FR';
|
||||
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, 'PT_ORDER', 'c_payment_term', 'code', 'rowid', 1);
|
||||
$object->multicurrency_code = 'EUR';
|
||||
|
||||
if ($fields['REMISE'] != '0.00') {
|
||||
$object->remise_percent = abs($fields['REMISE']);
|
||||
}
|
||||
|
||||
// $object->code_client = $fields[9];
|
||||
// $object->code_fournisseur = $fields[10];
|
||||
|
||||
|
||||
if ($fields['FCIVIL']) {
|
||||
$labeltype = in_array($fields['FCIVIL'], $civilPrivate) ? 'TE_PRIVATE' : 'TE_SMALL';
|
||||
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'code');
|
||||
}
|
||||
|
||||
// Set price level
|
||||
$object->price_level = $fields['TARIF'] + 1;
|
||||
// if ($labeltype == 'Revendeur')
|
||||
// $object->price_level = 2;
|
||||
|
||||
print "Process line nb " . $i . ", code " . $fields['CODE'] . ", name " . $object->name;
|
||||
|
||||
|
||||
// Extrafields
|
||||
$object->array_options['options_banque'] = $fields['BANQUE'];
|
||||
$object->array_options['options_banque2'] = $fields['BANQUE2'];
|
||||
$object->array_options['options_banquevalid'] = $fields['VALID'];
|
||||
|
||||
if (!$errorrecord) {
|
||||
$ret = $object->create($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = " . $ret . " - " . $object->errorsToString();
|
||||
$errorrecord++;
|
||||
var_dump($object->code_client, $db);
|
||||
die();
|
||||
} else {
|
||||
print " - Creation OK with name " . $object->name . " - id = " . $ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$errorrecord) {
|
||||
dol_syslog("Set price level");
|
||||
$object->set_price_level($object->price_level, $user);
|
||||
}
|
||||
if (!$errorrecord && @$object->remise_percent) {
|
||||
dol_syslog("Set remise client");
|
||||
$object->set_remise_client($object->remise_percent, 'Importé', $user);
|
||||
}
|
||||
|
||||
dol_syslog("Add contact");
|
||||
// Insert an invoice contact if there is an invoice email != standard email
|
||||
if (!$errorrecord && ($fields['LCIVIL'] || $fields['LNOM'])) {
|
||||
$madame = array("MADAME",
|
||||
"MADEMOISELLE",
|
||||
"MELLE",
|
||||
"MLLE",
|
||||
"MM",
|
||||
"Mme",
|
||||
"MNE",
|
||||
);
|
||||
$monsieur = array("M",
|
||||
);
|
||||
$monsieur = array("M",
|
||||
"M ET MME",
|
||||
"M MME",
|
||||
"M.",
|
||||
@ -268,77 +274,84 @@ while ($fields = $db->fetch_array($resql)) {
|
||||
"MONSIUER",
|
||||
"MONSKIEUR",
|
||||
"MR",
|
||||
);
|
||||
$ret1 = $ret2 = 0;
|
||||
);
|
||||
$ret1 = $ret2 = 0;
|
||||
|
||||
$contact = new Contact($db);
|
||||
if (in_array($fields['LCIVIL'], $madame)) {
|
||||
// une dame
|
||||
$contact->civility_id = 'MME';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} elseif (in_array($fields['LCIVIL'], $monsieur)) {
|
||||
// un monsieur
|
||||
$contact->civility_id = 'MR';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) {
|
||||
// un monsieur
|
||||
$contact->civility_id = 'DR';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} else {
|
||||
// un a rattraper
|
||||
$contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM'];
|
||||
}
|
||||
$contact->address = trim($fields['LADR1']);
|
||||
if ($fields['LADR2'])
|
||||
$contact->address .= "\n" . trim($fields['LADR2']);
|
||||
if ($fields['LADR3'])
|
||||
$contact->address .= "\n" . trim($fields['LADR3']);
|
||||
$contact = new Contact($db);
|
||||
if (in_array($fields['LCIVIL'], $madame)) {
|
||||
// une dame
|
||||
$contact->civility_id = 'MME';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} elseif (in_array($fields['LCIVIL'], $monsieur)) {
|
||||
// un monsieur
|
||||
$contact->civility_id = 'MR';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} elseif (in_array($fields['LCIVIL'], ['DOCTEUR'])) {
|
||||
// un monsieur
|
||||
$contact->civility_id = 'DR';
|
||||
$contact->lastname = $fields['LNOM'];
|
||||
} else {
|
||||
// un a rattraper
|
||||
$contact->lastname = $fields['LCIVIL'] . " " . $fields['LNOM'];
|
||||
}
|
||||
$contact->address = trim($fields['LADR1']);
|
||||
if ($fields['LADR2']) {
|
||||
$contact->address .= "\n" . trim($fields['LADR2']);
|
||||
}
|
||||
if ($fields['LADR3']) {
|
||||
$contact->address .= "\n" . trim($fields['LADR3']);
|
||||
}
|
||||
|
||||
$contact->zip = trim($fields['LPOSTE']);
|
||||
$contact->town = trim($fields['LVILLE']);
|
||||
if ($fields['FPAYS'])
|
||||
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
|
||||
else $contact->country_id = 1;
|
||||
$contact->email = $fields['LMAIL'];
|
||||
$contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']);
|
||||
$contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']);
|
||||
$contact->socid = $object->id;
|
||||
$contact->zip = trim($fields['LPOSTE']);
|
||||
$contact->town = trim($fields['LVILLE']);
|
||||
if ($fields['FPAYS']) {
|
||||
$contact->country_id = dol_getIdFromCode($db, trim(ucwords(strtolower($fields['LPAYS']))), 'c_country', 'label', 'rowid');
|
||||
} else {
|
||||
$contact->country_id = 1;
|
||||
}
|
||||
$contact->email = $fields['LMAIL'];
|
||||
$contact->phone = trim($fields['LTEL']) ? trim($fields['LTEL']) : trim($fields['LCONTACT']);
|
||||
$contact->fax = trim($fields['LFAX']) ? trim($fields['LFAX']) : trim($fields['LCONTACT']);
|
||||
$contact->socid = $object->id;
|
||||
|
||||
$ret1 = $contact->create($user);
|
||||
if ($ret1 > 0) {
|
||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
||||
$ret1 = $contact->create($user);
|
||||
if ($ret1 > 0) {
|
||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0) {
|
||||
print " - Error in create contact result code = " . $ret1 . " " . $ret2 . " - " . $contact->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
}
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0) {
|
||||
print " - Error in create contact result code = " . $ret1 . " " . $ret2 . " - " . $contact->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
|
||||
|
||||
//update date créa
|
||||
if (!$errorrecord) {
|
||||
$datec = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
|
||||
$retd = $db->query("UPDATE `llx_societe` SET `datec` = '$datec 00:00:00' WHERE `rowid` = $object->id");
|
||||
if ($retd < 1) {
|
||||
print " - Error in update date créa result " . $object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - update date créa OK";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord) {
|
||||
print( 'Error on record nb ' . $i . " - " . $object->errorsToString() . "\n");
|
||||
var_dump($db, $object, $contact);
|
||||
// $db->rollback();
|
||||
die();
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
|
||||
|
||||
//update date créa
|
||||
if (!$errorrecord) {
|
||||
$datec = substr($date, 0, 4) . '-' . substr($date, 4, 2) . '-' . substr($date, 6, 2);
|
||||
$retd = $db->query("UPDATE `llx_societe` SET `datec` = '$datec 00:00:00' WHERE `rowid` = $object->id");
|
||||
if ($retd < 1) {
|
||||
print " - Error in update date créa result " . $object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - update date créa OK";
|
||||
}
|
||||
}
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord) {
|
||||
print( 'Error on record nb ' . $i . " - " . $object->errorsToString() . "\n");
|
||||
var_dump($db, $object, $contact);
|
||||
// $db->rollback();
|
||||
die();
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
$j++;
|
||||
} else die("error : $sql");
|
||||
} else {
|
||||
die("error : $sql");
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
|
||||
|
||||
@ -18,382 +18,582 @@ define('DBASE_TYPE_FOXPRO', 1);
|
||||
*/
|
||||
class DBase
|
||||
{
|
||||
private $fd;
|
||||
private $headerLength = 0;
|
||||
private $fields = array();
|
||||
private $fieldCount = 0;
|
||||
private $recordLength = 0;
|
||||
private $recordCount = 0;
|
||||
private $fd;
|
||||
private $headerLength = 0;
|
||||
private $fields = array();
|
||||
private $fieldCount = 0;
|
||||
private $recordLength = 0;
|
||||
private $recordCount = 0;
|
||||
|
||||
//resource dbase_open ( string $filename , int $mode )
|
||||
public static function open($filename, $mode)
|
||||
/**
|
||||
* resource dbase_open
|
||||
* @param string $filename filename
|
||||
* @param int $mode mode
|
||||
* @return DBase
|
||||
*/
|
||||
public static function open($filename, $mode)
|
||||
{
|
||||
if (!file_exists($filename))
|
||||
return false;
|
||||
$modes = array('r', 'w', 'r+');
|
||||
$mode = $modes[$mode];
|
||||
$fd = fopen($filename, $mode);
|
||||
if (!$fd)
|
||||
return false;
|
||||
return new DBase($fd);
|
||||
}
|
||||
if (!file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
$modes = array('r', 'w', 'r+');
|
||||
$mode = $modes[$mode];
|
||||
$fd = fopen($filename, $mode);
|
||||
if (!$fd) {
|
||||
return false;
|
||||
}
|
||||
return new DBase($fd);
|
||||
}
|
||||
|
||||
//resource dbase_create ( string $filename , array $fields [, int $type = DBASE_TYPE_DBASE ] )
|
||||
public static function create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||
/**
|
||||
* resource dbase_create
|
||||
* @param string $filename filename
|
||||
* @param array $fields fields
|
||||
* @param int $type DBASE_TYPE_DBASE
|
||||
* @return DBase
|
||||
*/
|
||||
public static function create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||
{
|
||||
if (file_exists($filename))
|
||||
return false;
|
||||
$fd = fopen($filename, 'c+');
|
||||
if (!$fd)
|
||||
return false;
|
||||
// Byte 0 (1 byte): Valid dBASE for DOS file; bits 0-2 indicate version number, bit 3
|
||||
// indicates the presence of a dBASE for DOS memo file, bits 4-6 indicate the
|
||||
// presence of a SQL table, bit 7 indicates the presence of any memo file
|
||||
// (either dBASE m PLUS or dBASE for DOS)
|
||||
self::putChar8($fd, 5);
|
||||
// Byte 1-3 (3 bytes): Date of last update; formatted as YYMMDD
|
||||
self::putChar8($fd, date('Y') - 1900);
|
||||
self::putChar8($fd, date('m'));
|
||||
self::putChar8($fd, date('d'));
|
||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||
self::putInt32($fd, 0);
|
||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||
self::putInt16($fd, 32 + (32 * count($fields)) + 1);
|
||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||
// Make sure the include the byte for deleted flag
|
||||
$len = 1;
|
||||
foreach ($fields as &$field)
|
||||
$len += self::length($field);
|
||||
self::putInt16($fd, $len);
|
||||
// Byte 12-13 (2 bytes): Reserved, 0 filled.
|
||||
self::putInt16($fd, 0);
|
||||
// Byte 14 (1 byte): Flag indicating incomplete transaction
|
||||
// The ISMARKEDO function checks this flag. BEGIN TRANSACTION sets it to 1, END TRANSACTION and ROLLBACK reset it to 0.
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 15 (1 byte): Encryption flag. If this flag is set to 1, the message Database encrypted appears. Changing this flag to 0 removes the message, but does not decrypt the file.
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 16-27 (12 bytes): Reserved for dBASE for DOS in a multi-user environment
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt32($fd, 0);
|
||||
// Byte 28 (1 byte): Production .mdx file flag; 0x01 if there is a production .mdx file, 0x00 if not
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 29 (1 byte): Language driver ID
|
||||
// (no clue what this is)
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 30-31 (2 bytes): Reserved, 0 filled.
|
||||
self::putInt16($fd, 0);
|
||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||
foreach ($fields as &$field) {
|
||||
self::putString($fd, $field[0], 11); // Byte 0 - 10 (11 bytes): Field name in ASCII (zero-filled)
|
||||
self::putString($fd, $field[1], 1); // Byte 11 (1 byte): Field type in ASCII (C, D, F, L, M, or N)
|
||||
self::putInt32($fd, 0); // Byte 12 - 15 (4 bytes): Reserved
|
||||
self::putChar8($fd, self::length($field)); // Byte 16 (1 byte): Field length in binary. The maximum length of a field is 254 (0xFE).
|
||||
self::putChar8($fd, $field[3]); // Byte 17 (1 byte): Field decimal count in binary
|
||||
self::putInt16($fd, 0); // Byte 18 - 19 (2 bytes): Work area ID
|
||||
self::putChar8($fd, 0); // Byte 20 (1 byte): Example (??)
|
||||
self::putInt32($fd, 0); // Byte 21 - 30 (10 bytes): Reserved
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt16($fd, 0);
|
||||
self::putChar8($fd, 0); // Byte 31 (1 byte): Production MDX field flag; 1 if field has an index tag in the production MDX file, 0 if not
|
||||
}
|
||||
// Byte n + 1 (1 byte): 0x0D as the field descriptor array terminator
|
||||
self::putChar8($fd, 0x0D);
|
||||
return new DBase($fd);
|
||||
}
|
||||
if (file_exists($filename)) {
|
||||
return false;
|
||||
}
|
||||
$fd = fopen($filename, 'c+');
|
||||
if (!$fd) {
|
||||
return false;
|
||||
}
|
||||
// Byte 0 (1 byte): Valid dBASE for DOS file; bits 0-2 indicate version number, bit 3
|
||||
// indicates the presence of a dBASE for DOS memo file, bits 4-6 indicate the
|
||||
// presence of a SQL table, bit 7 indicates the presence of any memo file
|
||||
// (either dBASE m PLUS or dBASE for DOS)
|
||||
self::putChar8($fd, 5);
|
||||
// Byte 1-3 (3 bytes): Date of last update; formatted as YYMMDD
|
||||
self::putChar8($fd, date('Y') - 1900);
|
||||
self::putChar8($fd, date('m'));
|
||||
self::putChar8($fd, date('d'));
|
||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||
self::putInt32($fd, 0);
|
||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||
self::putInt16($fd, 32 + (32 * count($fields)) + 1);
|
||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||
// Make sure the include the byte for deleted flag
|
||||
$len = 1;
|
||||
foreach ($fields as &$field) {
|
||||
$len += self::length($field);
|
||||
}
|
||||
self::putInt16($fd, $len);
|
||||
// Byte 12-13 (2 bytes): Reserved, 0 filled.
|
||||
self::putInt16($fd, 0);
|
||||
// Byte 14 (1 byte): Flag indicating incomplete transaction
|
||||
// The ISMARKEDO function checks this flag. BEGIN TRANSACTION sets it to 1, END TRANSACTION and ROLLBACK reset it to 0.
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 15 (1 byte): Encryption flag. If this flag is set to 1, the message Database encrypted appears. Changing this flag to 0 removes the message, but does not decrypt the file.
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 16-27 (12 bytes): Reserved for dBASE for DOS in a multi-user environment
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt32($fd, 0);
|
||||
// Byte 28 (1 byte): Production .mdx file flag; 0x01 if there is a production .mdx file, 0x00 if not
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 29 (1 byte): Language driver ID
|
||||
// (no clue what this is)
|
||||
self::putChar8($fd, 0);
|
||||
// Byte 30-31 (2 bytes): Reserved, 0 filled.
|
||||
self::putInt16($fd, 0);
|
||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||
foreach ($fields as &$field) {
|
||||
self::putString($fd, $field[0], 11); // Byte 0 - 10 (11 bytes): Field name in ASCII (zero-filled)
|
||||
self::putString($fd, $field[1], 1); // Byte 11 (1 byte): Field type in ASCII (C, D, F, L, M, or N)
|
||||
self::putInt32($fd, 0); // Byte 12 - 15 (4 bytes): Reserved
|
||||
self::putChar8($fd, self::length($field)); // Byte 16 (1 byte): Field length in binary. The maximum length of a field is 254 (0xFE).
|
||||
self::putChar8($fd, $field[3]); // Byte 17 (1 byte): Field decimal count in binary
|
||||
self::putInt16($fd, 0); // Byte 18 - 19 (2 bytes): Work area ID
|
||||
self::putChar8($fd, 0); // Byte 20 (1 byte): Example (??)
|
||||
self::putInt32($fd, 0); // Byte 21 - 30 (10 bytes): Reserved
|
||||
self::putInt32($fd, 0);
|
||||
self::putInt16($fd, 0);
|
||||
self::putChar8($fd, 0); // Byte 31 (1 byte): Production MDX field flag; 1 if field has an index tag in the production MDX file, 0 if not
|
||||
}
|
||||
// Byte n + 1 (1 byte): 0x0D as the field descriptor array terminator
|
||||
self::putChar8($fd, 0x0D);
|
||||
return new DBase($fd);
|
||||
}
|
||||
|
||||
// Create DBase instance
|
||||
private function __construct($fd)
|
||||
/**
|
||||
* Create DBase instance
|
||||
* @param mixed $fd file descriptor
|
||||
* @return void
|
||||
*/
|
||||
private function __construct($fd)
|
||||
{
|
||||
$this->fd = $fd;
|
||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||
fseek($this->fd, 4, SEEK_SET);
|
||||
$this->recordCount = self::getInt32($fd);
|
||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||
fseek($this->fd, 8, SEEK_SET);
|
||||
$this->headerLength = self::getInt16($fd);
|
||||
// Number of fields is (headerLength - 33) / 32)
|
||||
$this->fieldCount = ($this->headerLength - 33) / 32;
|
||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||
fseek($this->fd, 10, SEEK_SET);
|
||||
$this->recordLength = self::getInt16($fd);
|
||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||
fseek($fd, 32, SEEK_SET);
|
||||
for ($i = 0; $i < $this->fieldCount; $i++) {
|
||||
$data = fread($this->fd, 32);
|
||||
$field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data));
|
||||
$this->fields[] = $field;
|
||||
}
|
||||
}
|
||||
$this->fd = $fd;
|
||||
// Byte 4-7 (32-bit number): Number of records in the database file. Currently 0
|
||||
fseek($this->fd, 4, SEEK_SET);
|
||||
$this->recordCount = self::getInt32($fd);
|
||||
// Byte 8-9 (16-bit number): Number of bytes in the header.
|
||||
fseek($this->fd, 8, SEEK_SET);
|
||||
$this->headerLength = self::getInt16($fd);
|
||||
// Number of fields is (headerLength - 33) / 32)
|
||||
$this->fieldCount = ($this->headerLength - 33) / 32;
|
||||
// Byte 10-11 (16-bit number): Number of bytes in record.
|
||||
fseek($this->fd, 10, SEEK_SET);
|
||||
$this->recordLength = self::getInt16($fd);
|
||||
// Byte 32 - n (32 bytes each): Field descriptor array
|
||||
fseek($fd, 32, SEEK_SET);
|
||||
for ($i = 0; $i < $this->fieldCount; $i++) {
|
||||
$data = fread($this->fd, 32);
|
||||
$field = array_map('trim', unpack('a11name/a1type/c4/c1length/c1precision/s1workid/c1example/c10/c1production', $data));
|
||||
$this->fields[] = $field;
|
||||
}
|
||||
}
|
||||
|
||||
//bool dbase_close ( resource $dbase_identifier )
|
||||
public function close()
|
||||
/**
|
||||
* dbase_close
|
||||
* @return void
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
fclose($this->fd);
|
||||
}
|
||||
fclose($this->fd);
|
||||
}
|
||||
|
||||
//array dbase_get_header_info ( resource $dbase_identifier )
|
||||
public function get_header_info()
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_get_header_info
|
||||
* @return array
|
||||
*/
|
||||
public function get_header_info()
|
||||
{
|
||||
return $this->fields;
|
||||
}
|
||||
// phpcs:disable
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
//int dbase_numfields ( resource $dbase_identifier )
|
||||
public function numfields()
|
||||
/**
|
||||
* dbase_numfields
|
||||
* @return int
|
||||
*/
|
||||
public function numfields()
|
||||
{
|
||||
return $this->fieldCount;
|
||||
}
|
||||
return $this->fieldCount;
|
||||
}
|
||||
|
||||
//int dbase_numrecords ( resource $dbase_identifier )
|
||||
public function numrecords()
|
||||
/**
|
||||
* dbase_numrecords
|
||||
* @return int
|
||||
*/
|
||||
public function numrecords()
|
||||
{
|
||||
return $this->recordCount;
|
||||
}
|
||||
return $this->recordCount;
|
||||
}
|
||||
|
||||
//bool dbase_add_record ( resource $dbase_identifier , array $record )
|
||||
public function add_record($record)
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_add_record
|
||||
* @param array $record record
|
||||
* @return bool
|
||||
*/
|
||||
public function add_record($record)
|
||||
{
|
||||
if (count($record) != $this->fieldCount)
|
||||
return false;
|
||||
// Seek to end of file, minus the end of file marker
|
||||
fseek($this->fd, 0, SEEK_END);
|
||||
// Put the deleted flag
|
||||
self::putChar8($this->fd, 0x20);
|
||||
// Put the record
|
||||
if (!$this->putRecord($record))
|
||||
return false;
|
||||
// Update the record count
|
||||
fseek($this->fd, 4);
|
||||
self::putInt32($this->fd, ++$this->recordCount);
|
||||
return true;
|
||||
}
|
||||
// phpcs:enable
|
||||
if (count($record) != $this->fieldCount) {
|
||||
return false;
|
||||
}
|
||||
// Seek to end of file, minus the end of file marker
|
||||
fseek($this->fd, 0, SEEK_END);
|
||||
// Put the deleted flag
|
||||
self::putChar8($this->fd, 0x20);
|
||||
// Put the record
|
||||
if (!$this->putRecord($record)) {
|
||||
return false;
|
||||
}
|
||||
// Update the record count
|
||||
fseek($this->fd, 4);
|
||||
self::putInt32($this->fd, ++$this->recordCount);
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool dbase_replace_record ( resource $dbase_identifier , array $record , int $record_number )
|
||||
public function replace_record($record, $record_number)
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_replace_record
|
||||
* @param array $record record
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
public function replace_record($record, $record_number)
|
||||
{
|
||||
if (count($record) != $this->fieldCount)
|
||||
return false;
|
||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
||||
return false;
|
||||
// Skip to the record location, plus the 1 byte for the deleted flag
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)) + 1);
|
||||
return $this->putRecord($record);
|
||||
}
|
||||
// phpcs:enable
|
||||
if (count($record) != $this->fieldCount) {
|
||||
return false;
|
||||
}
|
||||
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||
return false;
|
||||
}
|
||||
// Skip to the record location, plus the 1 byte for the deleted flag
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)) + 1);
|
||||
return $this->putRecord($record);
|
||||
}
|
||||
|
||||
//bool dbase_delete_record ( resource $dbase_identifier , int $record_number )
|
||||
public function delete_record($record_number)
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_delete_record
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
public function delete_record($record_number)
|
||||
{
|
||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
||||
return false;
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
||||
self::putChar8($this->fd, 0x2A);
|
||||
return true;
|
||||
}
|
||||
// phpcs:enable
|
||||
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||
return false;
|
||||
}
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
||||
self::putChar8($this->fd, 0x2A);
|
||||
return true;
|
||||
}
|
||||
|
||||
//array dbase_get_record ( resource $dbase_identifier , int $record_number )
|
||||
public function get_record($record_number)
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_get_record
|
||||
* @param int $record_number record number
|
||||
* @return array
|
||||
*/
|
||||
public function get_record($record_number)
|
||||
{
|
||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
||||
return false;
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
||||
$record = array(
|
||||
'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0
|
||||
);
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$value = trim(fread($this->fd, $field['length']));
|
||||
if ($field['type'] == 'L') {
|
||||
$value = strtolower($value);
|
||||
if ($value == 't' || $value == 'y')
|
||||
$value = true;
|
||||
elseif ($value == 'f' || $value == 'n')
|
||||
$value = false;
|
||||
else $value = null;
|
||||
}
|
||||
$record[$i] = $value;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
// phpcs:enable
|
||||
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||
return false;
|
||||
}
|
||||
fseek($this->fd, $this->headerLength + ($this->recordLength * ($record_number - 1)));
|
||||
$record = array(
|
||||
'deleted' => self::getChar8($this->fd) == 0x2A ? 1 : 0
|
||||
);
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$value = trim(fread($this->fd, $field['length']));
|
||||
if ($field['type'] == 'L') {
|
||||
$value = strtolower($value);
|
||||
if ($value == 't' || $value == 'y') {
|
||||
$value = true;
|
||||
} elseif ($value == 'f' || $value == 'n') {
|
||||
$value = false;
|
||||
} else {
|
||||
$value = null;
|
||||
}
|
||||
}
|
||||
$record[$i] = $value;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
//array dbase_get_record_with_names ( resource $dbase_identifier , int $record_number )
|
||||
public function get_record_with_names($record_number)
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* dbase_get_record_with_names
|
||||
* @param int $record_number record number
|
||||
* @return array
|
||||
*/
|
||||
public function get_record_with_names($record_number)
|
||||
{
|
||||
if ($record_number < 1 || $record_number > $this->recordCount)
|
||||
return false;
|
||||
$record = $this->get_record($record_number);
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$record[$field['name']] = $record[$i];
|
||||
unset($record[$i]);
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
// phpcs:enable
|
||||
if ($record_number < 1 || $record_number > $this->recordCount) {
|
||||
return false;
|
||||
}
|
||||
$record = $this->get_record($record_number);
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$record[$field['name']] = $record[$i];
|
||||
unset($record[$i]);
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
|
||||
//bool dbase_pack ( resource $dbase_identifier )
|
||||
public function pack()
|
||||
/**
|
||||
* dbase_pack
|
||||
* @return void
|
||||
*/
|
||||
public function pack()
|
||||
{
|
||||
$in_offset = $out_offset = $this->headerLength;
|
||||
$new_count = 0;
|
||||
$rec_count = $this->recordCount;
|
||||
while ($rec_count > 0) {
|
||||
fseek($this->fd, $in_offset, SEEK_SET);
|
||||
$record = fread($this->fd, $this->recordLength);
|
||||
$deleted = substr($record, 0, 1);
|
||||
if ($deleted != '*') {
|
||||
fseek($this->fd, $out_offset, SEEK_SET);
|
||||
fwrite($this->fd, $record);
|
||||
$out_offset += $this->recordLength;
|
||||
$new_count++;
|
||||
}
|
||||
$in_offset += $this->recordLength;
|
||||
$rec_count--;
|
||||
}
|
||||
ftruncate($this->fd, $out_offset);
|
||||
// Update the record count
|
||||
fseek($this->fd, 4);
|
||||
self::putInt32($this->fd, $new_count);
|
||||
}
|
||||
$in_offset = $out_offset = $this->headerLength;
|
||||
$new_count = 0;
|
||||
$rec_count = $this->recordCount;
|
||||
while ($rec_count > 0) {
|
||||
fseek($this->fd, $in_offset, SEEK_SET);
|
||||
$record = fread($this->fd, $this->recordLength);
|
||||
$deleted = substr($record, 0, 1);
|
||||
if ($deleted != '*') {
|
||||
fseek($this->fd, $out_offset, SEEK_SET);
|
||||
fwrite($this->fd, $record);
|
||||
$out_offset += $this->recordLength;
|
||||
$new_count++;
|
||||
}
|
||||
$in_offset += $this->recordLength;
|
||||
$rec_count--;
|
||||
}
|
||||
ftruncate($this->fd, $out_offset);
|
||||
// Update the record count
|
||||
fseek($this->fd, 4);
|
||||
self::putInt32($this->fd, $new_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* A few utilitiy functions
|
||||
*/
|
||||
/*
|
||||
* A few utilitiy functions
|
||||
*/
|
||||
|
||||
private static function length($field)
|
||||
/**
|
||||
* @param string $field field
|
||||
* @return int
|
||||
*/
|
||||
private static function length($field)
|
||||
{
|
||||
switch ($field[1]) {
|
||||
case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format)
|
||||
return 8;
|
||||
case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro)
|
||||
return 18;
|
||||
case 'M': // Memo (ignored): All ASCII characters (stored internally as 10 digits representing a .dbt block number, right justified, padded with whitespaces)
|
||||
case 'N': // Number: -.0123456789 (right justified, padded with whitespaces)
|
||||
case 'F': // Float: -.0123456789 (right justified, padded with whitespaces)
|
||||
case 'C': // String: All ASCII characters (padded with whitespaces up to the field's length)
|
||||
return $field[2];
|
||||
case 'L': // Boolean: YyNnTtFf? (? when not initialized)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
switch ($field[1]) {
|
||||
case 'D': // Date: Numbers and a character to separate month, day, and year (stored internally as 8 digits in YYYYMMDD format)
|
||||
return 8;
|
||||
case 'T': // DateTime (YYYYMMDDhhmmss.uuu) (FoxPro)
|
||||
return 18;
|
||||
case 'M': // Memo (ignored): All ASCII characters (stored internally as 10 digits representing a .dbt block number, right justified, padded with whitespaces)
|
||||
case 'N': // Number: -.0123456789 (right justified, padded with whitespaces)
|
||||
case 'F': // Float: -.0123456789 (right justified, padded with whitespaces)
|
||||
case 'C': // String: All ASCII characters (padded with whitespaces up to the field's length)
|
||||
return $field[2];
|
||||
case 'L': // Boolean: YyNnTtFf? (? when not initialized)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions for reading and writing bytes
|
||||
*/
|
||||
/*
|
||||
* Functions for reading and writing bytes
|
||||
*/
|
||||
|
||||
private static function getChar8($fd)
|
||||
/**
|
||||
* getChar8
|
||||
* @param mixed $fd file descriptor
|
||||
* @return int
|
||||
*/
|
||||
private static function getChar8($fd)
|
||||
{
|
||||
return ord(fread($fd, 1));
|
||||
}
|
||||
return ord(fread($fd, 1));
|
||||
}
|
||||
|
||||
private static function putChar8($fd, $value)
|
||||
/**
|
||||
* putChar8
|
||||
* @param mixed $fd file descriptor
|
||||
* @param mixed $value value
|
||||
* @return bool
|
||||
*/
|
||||
private static function putChar8($fd, $value)
|
||||
{
|
||||
return fwrite($fd, chr($value));
|
||||
}
|
||||
return fwrite($fd, chr($value));
|
||||
}
|
||||
|
||||
private static function getInt16($fd, $n = 1)
|
||||
/**
|
||||
* getInt16
|
||||
* @param mixed $fd file descriptor
|
||||
* @param int $n n
|
||||
* @return bool
|
||||
*/
|
||||
private static function getInt16($fd, $n = 1)
|
||||
{
|
||||
$data = fread($fd, 2 * $n);
|
||||
$i = unpack("S$n", $data);
|
||||
if ($n == 1)
|
||||
return (int) $i[1];
|
||||
else return array_merge($i);
|
||||
}
|
||||
$data = fread($fd, 2 * $n);
|
||||
$i = unpack("S$n", $data);
|
||||
if ($n == 1) {
|
||||
return (int) $i[1];
|
||||
} else {
|
||||
return array_merge($i);
|
||||
}
|
||||
}
|
||||
|
||||
private static function putInt16($fd, $value)
|
||||
/**
|
||||
* putInt16
|
||||
* @param mixed $fd file descriptor
|
||||
* @param mixed $value value
|
||||
* @return bool
|
||||
*/
|
||||
private static function putInt16($fd, $value)
|
||||
{
|
||||
return fwrite($fd, pack('S', $value));
|
||||
}
|
||||
return fwrite($fd, pack('S', $value));
|
||||
}
|
||||
|
||||
private static function getInt32($fd, $n = 1)
|
||||
/**
|
||||
* getInt32
|
||||
* @param mixed $fd file descriptor
|
||||
* @param int $n n
|
||||
* @return bool
|
||||
*/
|
||||
private static function getInt32($fd, $n = 1)
|
||||
{
|
||||
$data = fread($fd, 4 * $n);
|
||||
$i = unpack("L$n", $data);
|
||||
if ($n == 1)
|
||||
return (int) $i[1];
|
||||
else return array_merge($i);
|
||||
}
|
||||
$data = fread($fd, 4 * $n);
|
||||
$i = unpack("L$n", $data);
|
||||
if ($n == 1) {
|
||||
return (int) $i[1];
|
||||
} else {
|
||||
return array_merge($i);
|
||||
}
|
||||
}
|
||||
|
||||
private static function putInt32($fd, $value)
|
||||
/**
|
||||
* putint32
|
||||
* @param mixed $fd file descriptor
|
||||
* @param mixed $value value
|
||||
* @return bool
|
||||
*/
|
||||
private static function putInt32($fd, $value)
|
||||
{
|
||||
return fwrite($fd, pack('L', $value));
|
||||
}
|
||||
return fwrite($fd, pack('L', $value));
|
||||
}
|
||||
|
||||
private static function putString($fd, $value, $length = 254)
|
||||
/**
|
||||
* putString
|
||||
* @param mixed $fd file descriptor
|
||||
* @param mixed $value value
|
||||
* @param int $length length
|
||||
* @return bool
|
||||
*/
|
||||
private static function putString($fd, $value, $length = 254)
|
||||
{
|
||||
$ret = fwrite($fd, pack('A' . $length, $value));
|
||||
}
|
||||
$ret = fwrite($fd, pack('A' . $length, $value));
|
||||
}
|
||||
|
||||
private function putRecord($record)
|
||||
/**
|
||||
* putRecord
|
||||
* @param mixed $record record
|
||||
* @return bool
|
||||
*/
|
||||
private function putRecord($record)
|
||||
{
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$value = $record[$i];
|
||||
// Number types are right aligned with spaces
|
||||
if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) {
|
||||
$value = str_repeat(' ', $field['length'] - strlen($value)) . $value;
|
||||
}
|
||||
self::putString($this->fd, $value, $field['length']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
foreach ($this->fields as $i => &$field) {
|
||||
$value = $record[$i];
|
||||
// Number types are right aligned with spaces
|
||||
if ($field['type'] == 'N' || $field['type'] == 'F' && strlen($value) < $field['length']) {
|
||||
$value = str_repeat(' ', $field['length'] - strlen($value)) . $value;
|
||||
}
|
||||
self::putString($this->fd, $value, $field['length']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dbase_open')) {
|
||||
|
||||
function dbase_open($filename, $mode)
|
||||
/**
|
||||
* dbase_open
|
||||
* @param string $filename filename
|
||||
* @param int $mode mode
|
||||
* @return DBase
|
||||
*/
|
||||
function dbase_open($filename, $mode)
|
||||
{
|
||||
return DBase::open($filename, $mode);
|
||||
}
|
||||
return DBase::open($filename, $mode);
|
||||
}
|
||||
|
||||
function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||
/**
|
||||
* dbase_create
|
||||
* @param string $filename filename
|
||||
* @param array $fields fields
|
||||
* @param int $type type
|
||||
* @return DBase
|
||||
*/
|
||||
function dbase_create($filename, $fields, $type = DBASE_TYPE_DBASE)
|
||||
{
|
||||
return DBase::create($filename, $fields, $type);
|
||||
}
|
||||
return DBase::create($filename, $fields, $type);
|
||||
}
|
||||
|
||||
function dbase_close($dbase_identifier)
|
||||
/**
|
||||
* dbase_close
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_close($dbase_identifier)
|
||||
{
|
||||
return $dbase_identifier->close();
|
||||
}
|
||||
return $dbase_identifier->close();
|
||||
}
|
||||
|
||||
function dbase_get_header_info($dbase_identifier)
|
||||
/**
|
||||
* dbase_get_header_info
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @return string
|
||||
*/
|
||||
function dbase_get_header_info($dbase_identifier)
|
||||
{
|
||||
return $dbase_identifier->get_header_info();
|
||||
}
|
||||
return $dbase_identifier->get_header_info();
|
||||
}
|
||||
|
||||
function dbase_numfields($dbase_identifier)
|
||||
/**
|
||||
* dbase_numfields
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @return int
|
||||
*/
|
||||
function dbase_numfields($dbase_identifier)
|
||||
{
|
||||
$dbase_identifier->numfields();
|
||||
}
|
||||
$dbase_identifier->numfields();
|
||||
}
|
||||
|
||||
function dbase_numrecords($dbase_identifier)
|
||||
/**
|
||||
* dbase_numrecords
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @return int
|
||||
*/
|
||||
function dbase_numrecords($dbase_identifier)
|
||||
{
|
||||
return $dbase_identifier->numrecords();
|
||||
}
|
||||
return $dbase_identifier->numrecords();
|
||||
}
|
||||
|
||||
function dbase_add_record($dbase_identifier, $record)
|
||||
/**
|
||||
* dbase_add_record
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @param array $record record
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_add_record($dbase_identifier, $record)
|
||||
{
|
||||
return $dbase_identifier->add_record($record);
|
||||
}
|
||||
return $dbase_identifier->add_record($record);
|
||||
}
|
||||
|
||||
function dbase_delete_record($dbase_identifier, $record_number)
|
||||
/**
|
||||
* dbase_delete_record
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_delete_record($dbase_identifier, $record_number)
|
||||
{
|
||||
return $dbase_identifier->delete_record($record_number);
|
||||
}
|
||||
return $dbase_identifier->delete_record($record_number);
|
||||
}
|
||||
|
||||
function dbase_replace_record($dbase_identifier, $record, $record_number)
|
||||
/**
|
||||
* dbase_replace_record
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @param array $record record
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_replace_record($dbase_identifier, $record, $record_number)
|
||||
{
|
||||
return $dbase_identifier->replace_record($record, $record_number);
|
||||
}
|
||||
return $dbase_identifier->replace_record($record, $record_number);
|
||||
}
|
||||
|
||||
function dbase_get_record($dbase_identifier, $record_number)
|
||||
/**
|
||||
* dbase_get_record
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_get_record($dbase_identifier, $record_number)
|
||||
{
|
||||
return $dbase_identifier->get_record($record_number);
|
||||
}
|
||||
return $dbase_identifier->get_record($record_number);
|
||||
}
|
||||
|
||||
function dbase_get_record_with_names($dbase_identifier, $record_number)
|
||||
/**
|
||||
* dbase_get_record_with_names
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @param int $record_number record number
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_get_record_with_names($dbase_identifier, $record_number)
|
||||
{
|
||||
return $dbase_identifier->get_record_with_names($record_number);
|
||||
}
|
||||
return $dbase_identifier->get_record_with_names($record_number);
|
||||
}
|
||||
|
||||
function dbase_pack($dbase_identifier)
|
||||
/**
|
||||
* dbase_pack
|
||||
* @param Resource $dbase_identifier dbase identifier
|
||||
* @return bool
|
||||
*/
|
||||
function dbase_pack($dbase_identifier)
|
||||
{
|
||||
return $dbase_identifier->pack();
|
||||
}
|
||||
return $dbase_identifier->pack();
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,60 +48,59 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
||||
define(GEN_NUMBER_FACTURE, 1);
|
||||
$year = 2016;
|
||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
);
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
@ -111,12 +110,10 @@ $user->getrights();
|
||||
$socids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1, 3)";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_thirdparties = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_thirdparties)
|
||||
{
|
||||
while ($i < $num_thirdparties) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$socids[$i] = $row[0];
|
||||
@ -126,12 +123,10 @@ if ($resql)
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
while ($i < $num_prods) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
@ -140,8 +135,7 @@ if ($resql)
|
||||
|
||||
$i=0;
|
||||
$result=0;
|
||||
while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||
{
|
||||
while ($i < GEN_NUMBER_FACTURE && $result >= 0) {
|
||||
$i++;
|
||||
$socid = mt_rand(1, $num_thirdparties);
|
||||
|
||||
@ -153,31 +147,27 @@ while ($i < GEN_NUMBER_FACTURE && $result >= 0)
|
||||
$object->cond_reglement_id = 3;
|
||||
$object->mode_reglement_id = 3;
|
||||
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch(mt_rand(1, 2));
|
||||
$fuser->getRights();
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch(mt_rand(1, 2));
|
||||
$fuser->getRights();
|
||||
|
||||
$result=$object->create($fuser);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
$nbp = mt_rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
while ($xnbp < $nbp) {
|
||||
$prodid = mt_rand(1, $num_prods);
|
||||
$product=new Product($db);
|
||||
$result=$product->fetch($prodids[$prodid]);
|
||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, '', '', 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type);
|
||||
if ($result < 0)
|
||||
{
|
||||
dol_print_error($db, $propal->error);
|
||||
}
|
||||
$xnbp++;
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $propal->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
|
||||
$result=$object->validate($fuser);
|
||||
if ($result)
|
||||
{
|
||||
$result=$object->validate($fuser);
|
||||
if ($result) {
|
||||
print " OK with ref ".$object->ref."\n";;
|
||||
} else {
|
||||
dol_print_error($db, $object->error);
|
||||
|
||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -54,62 +54,61 @@ require_once DOL_DOCUMENT_ROOT."/commande/class/commande.class.php";
|
||||
define(GEN_NUMBER_COMMANDE, 10);
|
||||
$year = 2016;
|
||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
);
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if ($ret <= 0)
|
||||
{
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
if ($ret <= 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
@ -117,101 +116,100 @@ $societesid = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe where client in (1, 3)";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num_thirdparties = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_thirdparties) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$societesid[$i] = $row[0];
|
||||
}
|
||||
} else { print "err"; }
|
||||
$num_thirdparties = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_thirdparties) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$societesid[$i] = $row[0];
|
||||
}
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
$commandesid = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$commandesid[$i] = $row[0];
|
||||
}
|
||||
} else { print "err"; }
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$commandesid[$i] = $row[0];
|
||||
}
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods) {
|
||||
$i++;
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods) {
|
||||
$i++;
|
||||
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "Build ".GEN_NUMBER_COMMANDE." orders\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_COMMANDE ; $s++)
|
||||
{
|
||||
print "Process order ".$s."\n";
|
||||
for ($s = 0; $s < GEN_NUMBER_COMMANDE; $s++) {
|
||||
print "Process order ".$s."\n";
|
||||
|
||||
$object = new Commande($db);
|
||||
$object = new Commande($db);
|
||||
|
||||
$object->socid = $societesid[mt_rand(1, $num_thirdparties)];
|
||||
$object->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
||||
$object->note = 'My small comment about this order. Hum. Nothing.';
|
||||
$object->source = 1;
|
||||
$object->fk_project = 0;
|
||||
$object->remise_percent = 0;
|
||||
$object->shipping_method_id = mt_rand(1, 2);
|
||||
$object->cond_reglement_id = mt_rand(0, 2);
|
||||
$object->more_reglement_id = mt_rand(0, 7);
|
||||
$object->availability_id = mt_rand(0, 1);
|
||||
$object->socid = $societesid[mt_rand(1, $num_thirdparties)];
|
||||
$object->date_commande = $dates[mt_rand(1, count($dates)-1)];
|
||||
$object->note = 'My small comment about this order. Hum. Nothing.';
|
||||
$object->source = 1;
|
||||
$object->fk_project = 0;
|
||||
$object->remise_percent = 0;
|
||||
$object->shipping_method_id = mt_rand(1, 2);
|
||||
$object->cond_reglement_id = mt_rand(0, 2);
|
||||
$object->more_reglement_id = mt_rand(0, 7);
|
||||
$object->availability_id = mt_rand(0, 1);
|
||||
|
||||
$listofuserid=array(12,13,16);
|
||||
$listofuserid=array(12,13,16);
|
||||
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($listofuserid[mt_rand(0, 2)]);
|
||||
$fuser->getRights();
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($listofuserid[mt_rand(0, 2)]);
|
||||
$fuser->getRights();
|
||||
|
||||
$db->begin();
|
||||
$db->begin();
|
||||
|
||||
$result=$object->create($fuser);
|
||||
if ($result >= 0)
|
||||
{
|
||||
$nbp = mt_rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
$prodid = mt_rand(1, $num_prods);
|
||||
$product=new Product($db);
|
||||
$result=$product->fetch($prodids[$prodid]);
|
||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
$result=$object->create($fuser);
|
||||
if ($result >= 0) {
|
||||
$nbp = mt_rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp) {
|
||||
$prodid = mt_rand(1, $num_prods);
|
||||
$product=new Product($db);
|
||||
$result=$product->fetch($prodids[$prodid]);
|
||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0, 0, 0, $product->price_base_type, $product->price_ttc, '', '', $product->type);
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
|
||||
$result=$object->valid($fuser);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
print " OK with ref ".$object->ref."\n";
|
||||
} else {
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
} else {
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
$result=$object->valid($fuser);
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
print " OK with ref ".$object->ref."\n";
|
||||
} else {
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
} else {
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -54,8 +54,7 @@ define(GEN_NUMBER_PRODUIT, 100000);
|
||||
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
@ -65,38 +64,50 @@ $user->getrights();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++; }
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql); $productsid[$i] = $row[0]; $i++;
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++; }
|
||||
} else { print "err"; }
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql); $societesid[$i] = $row[0]; $i++;
|
||||
}
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) { $row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++; }
|
||||
} else { print "err"; }
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql); $commandesid[$i] = $row[0]; $i++;
|
||||
}
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
|
||||
print "Generates ".GEN_NUMBER_PRODUIT." products\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_PRODUIT ; $s++)
|
||||
{
|
||||
print "Product ".$s;
|
||||
$produit = new Product($db);
|
||||
$produit->type = mt_rand(0, 1);
|
||||
$produit->status = 1;
|
||||
$produit->ref = ($produit->type?'S':'P').time().$s;
|
||||
$produit->label = 'Label '.time().$s;
|
||||
$produit->description = 'Description '.time().$s;
|
||||
$produit->price = mt_rand(1, 1000);
|
||||
$produit->tva_tx = "19.6";
|
||||
$ret=$produit->create($user);
|
||||
if ($ret < 0) print "Error $ret - ".$produit->error."\n";
|
||||
else print " OK with ref ".$produit->ref."\n";
|
||||
for ($s = 0; $s < GEN_NUMBER_PRODUIT; $s++) {
|
||||
print "Product ".$s;
|
||||
$produit = new Product($db);
|
||||
$produit->type = mt_rand(0, 1);
|
||||
$produit->status = 1;
|
||||
$produit->ref = ($produit->type?'S':'P').time().$s;
|
||||
$produit->label = 'Label '.time().$s;
|
||||
$produit->description = 'Description '.time().$s;
|
||||
$produit->price = mt_rand(1, 999.99);
|
||||
$produit->tva_tx = "20.0";
|
||||
$ret=$produit->create($user);
|
||||
if ($ret < 0) {
|
||||
print "Error $ret - ".$produit->error."\n";
|
||||
} else {
|
||||
print " OK with ref ".$produit->ref."\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,60 +50,59 @@ require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
|
||||
define(GEN_NUMBER_PROPAL, 10);
|
||||
$year = 2016;
|
||||
$dates = array (mktime(12, 0, 0, 1, 3, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
mktime(12, 0, 0, 1, 9, $year),
|
||||
mktime(12, 0, 0, 2, 13, $year),
|
||||
mktime(12, 0, 0, 2, 23, $year),
|
||||
mktime(12, 0, 0, 3, 30, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 4, 3, $year),
|
||||
mktime(12, 0, 0, 5, 9, $year),
|
||||
mktime(12, 0, 0, 5, 1, $year),
|
||||
mktime(12, 0, 0, 5, 13, $year),
|
||||
mktime(12, 0, 0, 5, 19, $year),
|
||||
mktime(12, 0, 0, 5, 23, $year),
|
||||
mktime(12, 0, 0, 6, 3, $year),
|
||||
mktime(12, 0, 0, 6, 19, $year),
|
||||
mktime(12, 0, 0, 6, 24, $year),
|
||||
mktime(12, 0, 0, 7, 3, $year),
|
||||
mktime(12, 0, 0, 7, 9, $year),
|
||||
mktime(12, 0, 0, 7, 23, $year),
|
||||
mktime(12, 0, 0, 7, 30, $year),
|
||||
mktime(12, 0, 0, 8, 9, $year),
|
||||
mktime(12, 0, 0, 9, 23, $year),
|
||||
mktime(12, 0, 0, 10, 3, $year),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 1, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 1, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 2, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 3, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 4, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 1, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 13, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 5, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 19, ($year - 1)),
|
||||
mktime(12, 0, 0, 6, 24, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 7, 30, ($year - 1)),
|
||||
mktime(12, 0, 0, 8, 9, ($year - 1)),
|
||||
mktime(12, 0, 0, 9, 23, ($year - 1)),
|
||||
mktime(12, 0, 0, 10, 3, ($year - 1)),
|
||||
mktime(12, 0, 0, 11, 12, $year),
|
||||
mktime(12, 0, 0, 11, 13, $year),
|
||||
mktime(12, 0, 0, 12, 12, $year),
|
||||
mktime(12, 0, 0, 12, 13, $year),
|
||||
);
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
@ -113,12 +112,10 @@ $user->getrights();
|
||||
$socids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe WHERE client in (1,3)";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_thirdparties = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_thirdparties)
|
||||
{
|
||||
while ($i < $num_thirdparties) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$socids[$i] = $row[0];
|
||||
@ -128,12 +125,10 @@ if ($resql)
|
||||
$contids = array();
|
||||
$sql = "SELECT rowid, fk_soc FROM ".MAIN_DB_PREFIX."socpeople";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_conts = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_conts)
|
||||
{
|
||||
while ($i < $num_conts) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$contids[$row[1]][0] = $row[0]; // A ameliorer
|
||||
@ -143,12 +138,10 @@ if ($resql)
|
||||
$prodids = array();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product WHERE tosell=1";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num_prods = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num_prods)
|
||||
{
|
||||
while ($i < $num_prods) {
|
||||
$i++;
|
||||
$row = $db->fetch_row($resql);
|
||||
$prodids[$i] = $row[0];
|
||||
@ -159,15 +152,13 @@ $user->rights->propal->creer=1;
|
||||
$user->rights->propal->propal_advance->validate=1;
|
||||
|
||||
|
||||
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
|
||||
{
|
||||
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) {
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php";
|
||||
}
|
||||
|
||||
$i=0;
|
||||
$result=0;
|
||||
while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
{
|
||||
while ($i < GEN_NUMBER_PROPAL && $result >= 0) {
|
||||
$i++;
|
||||
$socid = mt_rand(1, $num_thirdparties);
|
||||
print "Proposal ".$i." for socid ".$socid;
|
||||
@ -177,9 +168,9 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
|
||||
$object = new Propal($db);
|
||||
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch(mt_rand(1, 2));
|
||||
$fuser->getRights();
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch(mt_rand(1, 2));
|
||||
$fuser->getRights();
|
||||
|
||||
$object->contactid = $contids[$socids[$socid]][0];
|
||||
$object->socid = $socids[$socid];
|
||||
@ -188,32 +179,28 @@ while ($i < GEN_NUMBER_PROPAL && $result >= 0)
|
||||
$object->mode_reglement_id = 3;
|
||||
|
||||
$result=$object->create($fuser);
|
||||
if ($result >= 0)
|
||||
{
|
||||
if ($result >= 0) {
|
||||
$nbp = mt_rand(2, 5);
|
||||
$xnbp = 0;
|
||||
while ($xnbp < $nbp)
|
||||
{
|
||||
while ($xnbp < $nbp) {
|
||||
$prodid = mt_rand(1, $num_prods);
|
||||
$product=new Product($db);
|
||||
$result=$product->fetch($prodids[$prodid]);
|
||||
$result=$object->addline($product->description, $product->price, mt_rand(1, 5), 0, 0, 0, $prodids[$prodid], 0);
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
$xnbp++;
|
||||
}
|
||||
|
||||
$result=$object->valid($fuser);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
print " OK with ref ".$object->ref."\n";
|
||||
if ($result > 0) {
|
||||
$db->commit();
|
||||
print " OK with ref ".$object->ref."\n";
|
||||
} else {
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
print " KO\n";
|
||||
$db->rollback();
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db, $object->error);
|
||||
|
||||
@ -31,8 +31,8 @@ $path=dirname(__FILE__).'/';
|
||||
// Test si mode batch
|
||||
$sapi_type = php_sapi_name();
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -57,8 +57,7 @@ define(GEN_NUMBER_SOCIETE, 10);
|
||||
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
@ -68,8 +67,8 @@ $user->getrights();
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
$productsid[$i] = $row[0];
|
||||
$i++;
|
||||
@ -80,63 +79,65 @@ $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) {
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
$societesid[$i] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
} else { print "err"; }
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
|
||||
$resql=$db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql); $i = 0;
|
||||
while ($i < $num) {
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
$commandesid[$i] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
} else { print "err"; }
|
||||
} else {
|
||||
print "err";
|
||||
}
|
||||
|
||||
|
||||
|
||||
print "Generates ".GEN_NUMBER_SOCIETE." companies\n";
|
||||
for ($s = 0 ; $s < GEN_NUMBER_SOCIETE ; $s++)
|
||||
{
|
||||
print "Company $s\n";
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "Company num ".time()."$s";
|
||||
$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
|
||||
$soc->client = mt_rand(1, 2); // Une societe sur 2 est prospect, l'autre client
|
||||
$soc->fournisseur = mt_rand(0, 1); // Une societe sur 2 est fournisseur
|
||||
$soc->code_client='CU'.time()."$s";
|
||||
$soc->code_fournisseur='SU'.time()."$s";
|
||||
$soc->tva_assuj=1;
|
||||
$soc->country_id=1;
|
||||
$soc->country_code='FR';
|
||||
for ($s = 0; $s < GEN_NUMBER_SOCIETE; $s++) {
|
||||
print "Company $s\n";
|
||||
$soc = new Societe($db);
|
||||
$soc->name = "Company num ".time()."$s";
|
||||
$soc->town = $listoftown[mt_rand(0, count($listoftown)-1)];
|
||||
$soc->client = mt_rand(1, 2); // Une societe sur 2 est prospect, l'autre client
|
||||
$soc->fournisseur = mt_rand(0, 1); // Une societe sur 2 est fournisseur
|
||||
$soc->code_client='CU'.time()."$s";
|
||||
$soc->code_fournisseur='SU'.time()."$s";
|
||||
$soc->tva_assuj=1;
|
||||
$soc->country_id=1;
|
||||
$soc->country_code='FR';
|
||||
// Un client sur 3 a une remise de 5%
|
||||
$user_remise=mt_rand(1, 3); if ($user_remise==3) $soc->remise_percent=5;
|
||||
$user_remise=mt_rand(1, 3); if ($user_remise==3) {
|
||||
$soc->remise_percent=5;
|
||||
}
|
||||
print "> client=".$soc->client.", fournisseur=".$soc->fournisseur.", remise=".$soc->remise_percent."\n";
|
||||
$soc->note_private = 'Company created by the script generate-societe.php';
|
||||
$socid = $soc->create();
|
||||
$soc->note_private = 'Company created by the script generate-societe.php';
|
||||
$socid = $soc->create();
|
||||
|
||||
if ($socid >= 0)
|
||||
{
|
||||
$rand = mt_rand(1, 4);
|
||||
print "> Generates $rand contact(s)\n";
|
||||
for ($c = 0 ; $c < $rand ; $c++)
|
||||
{
|
||||
$contact = new Contact($db);
|
||||
$contact->socid = $soc->id;
|
||||
$contact->lastname = "Lastname".$c;
|
||||
$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)];
|
||||
if ( $contact->create($user) )
|
||||
{
|
||||
}
|
||||
}
|
||||
if ($socid >= 0) {
|
||||
$rand = mt_rand(1, 4);
|
||||
print "> Generates $rand contact(s)\n";
|
||||
for ($c = 0; $c < $rand; $c++) {
|
||||
$contact = new Contact($db);
|
||||
$contact->socid = $soc->id;
|
||||
$contact->lastname = "Lastname".$c;
|
||||
$contact->firstname = $listoflastname[mt_rand(0, count($listoflastname)-1)];
|
||||
if ($contact->create($user)) {
|
||||
}
|
||||
}
|
||||
|
||||
print "Company ".$s." created nom=".$soc->name."\n";
|
||||
} else {
|
||||
print "Error: ".$soc->error."\n";
|
||||
}
|
||||
print "Company ".$s." created nom=".$soc->name."\n";
|
||||
} else {
|
||||
print "Error: ".$soc->error."\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[4])?1:$argv[4];
|
||||
$endlinenb = empty($argv[5])?0:$argv[5];
|
||||
|
||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [defaultlang] [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv fr_FR 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
// Ask confirmation
|
||||
if (! $confirmed)
|
||||
{
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
if (! $confirmed) {
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
$fhandle = fopen($filepath, 'r');
|
||||
if (! $fhandle)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
if (! $fhandle) {
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
}
|
||||
$fhandleerr = fopen($filepatherr, 'w');
|
||||
if (! $fhandleerr)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
if (! $fhandleerr) {
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$langs->setDefaultLang($defaultlang);
|
||||
@ -114,99 +110,96 @@ $db->begin();
|
||||
|
||||
$i=0;
|
||||
$nboflines++;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
{
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
|
||||
if ($startlinenb && $i < $startlinenb) continue;
|
||||
if ($endlinenb && $i > $endlinenb) continue;
|
||||
if ($startlinenb && $i < $startlinenb) {
|
||||
continue;
|
||||
}
|
||||
if ($endlinenb && $i > $endlinenb) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nboflines++;
|
||||
$nboflines++;
|
||||
|
||||
$produit = new Product($db);
|
||||
$produit->type = 0;
|
||||
$produit->status = 1;
|
||||
$produit->ref = trim($fields[0]);
|
||||
$produit = new Product($db);
|
||||
$produit->type = 0;
|
||||
$produit->status = 1;
|
||||
$produit->ref = trim($fields[0]);
|
||||
|
||||
print "Process line nb ".$i.", ref ".$produit->ref;
|
||||
$produit->label = trim($fields[2]);
|
||||
$produit->description = trim($fields[4]."\n".($fields[5] ? $fields[5].' x '.$fields[6].' x '.$fields[7] : ''));
|
||||
$produit->volume = price2num($fields[8]);
|
||||
$produit->volume_unit = 0;
|
||||
$produit->weight = price2num($fields[9]);
|
||||
$produit->weight_units = 0; // -3 = g
|
||||
print "Process line nb ".$i.", ref ".$produit->ref;
|
||||
$produit->label = trim($fields[2]);
|
||||
$produit->description = trim($fields[4]."\n".($fields[5] ? $fields[5].' x '.$fields[6].' x '.$fields[7] : ''));
|
||||
$produit->volume = price2num($fields[8]);
|
||||
$produit->volume_unit = 0;
|
||||
$produit->weight = price2num($fields[9]);
|
||||
$produit->weight_units = 0; // -3 = g
|
||||
|
||||
$produit->customcode = $fields[10];
|
||||
$produit->barcode = $fields[1];
|
||||
$produit->customcode = $fields[10];
|
||||
$produit->barcode = $fields[1];
|
||||
|
||||
$produit->status = 1;
|
||||
$produit->status_buy = 1;
|
||||
$produit->status = 1;
|
||||
$produit->status_buy = 1;
|
||||
|
||||
$produit->finished = 1;
|
||||
$produit->finished = 1;
|
||||
|
||||
$produit->price_min = null;
|
||||
$produit->price_min_ttc = null;
|
||||
$produit->price = price2num($fields[11]);
|
||||
$produit->price_ttc = price2num($fields[12]);
|
||||
$produit->price_base_type = 'TTC';
|
||||
$produit->tva_tx = price2num($fields[13]);
|
||||
$produit->tva_npr = 0;
|
||||
$produit->price_min = null;
|
||||
$produit->price_min_ttc = null;
|
||||
$produit->price = price2num($fields[11]);
|
||||
$produit->price_ttc = price2num($fields[12]);
|
||||
$produit->price_base_type = 'TTC';
|
||||
$produit->tva_tx = price2num($fields[13]);
|
||||
$produit->tva_npr = 0;
|
||||
|
||||
$produit->cost_price = price2num($fields[16]);
|
||||
$produit->cost_price = price2num($fields[16]);
|
||||
|
||||
// Extrafields
|
||||
$produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
|
||||
// Extrafields
|
||||
$produit->array_options['options_ecotaxdeee']=price2num($fields[17]);
|
||||
|
||||
$ret=$produit->create($user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with ref ".$produit->ref." - id = ".$ret;
|
||||
$ret=$produit->create($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = ".$ret." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with ref ".$produit->ref." - id = ".$ret;
|
||||
}
|
||||
|
||||
dol_syslog("Add prices");
|
||||
|
||||
// If we use price level, insert price for each level
|
||||
if (! $errorrecord && 1)
|
||||
{
|
||||
$ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
|
||||
$ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
|
||||
if ($ret1 < 0 || $ret2 < 0)
|
||||
{
|
||||
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - updatePrice OK";
|
||||
}
|
||||
// If we use price level, insert price for each level
|
||||
if (! $errorrecord && 1) {
|
||||
$ret1=$produit->updatePrice($produit->price_ttc, $produit->price_base_type, $user, $produit->tva_tx, $produit->price_min, 1, $produit->tva_npr, 0, 0, array());
|
||||
$ret2=$produit->updatePrice(price2num($fields[14]), 'HT', $user, $produit->tva_tx, $produit->price_min, 2, $produit->tva_npr, 0, 0, array());
|
||||
if ($ret1 < 0 || $ret2 < 0) {
|
||||
print " - Error in updatePrice result code = ".$ret1." ".$ret2." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - updatePrice OK";
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("Add multilangs");
|
||||
|
||||
// Add alternative languages
|
||||
if (! $errorrecord && 1)
|
||||
{
|
||||
$produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
|
||||
$produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
|
||||
if (! $errorrecord && 1) {
|
||||
$produit->multilangs['fr_FR']=array('label'=>$produit->label, 'description'=>$produit->description, 'note'=>$produit->note_private);
|
||||
$produit->multilangs['en_US']=array('label'=>$fields[3], 'description'=>$produit->description, 'note'=>$produit->note_private);
|
||||
|
||||
$ret=$produit->setMultiLangs($user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - setMultiLangs OK";
|
||||
}
|
||||
$ret=$produit->setMultiLangs($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in setMultiLangs result code = ".$ret." - ".$produit->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - setMultiLangs OK";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord)
|
||||
{
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
if ($errorrecord) {
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$produit->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,13 +210,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
// commit or rollback
|
||||
print "Nb of lines qualified: ".$nboflines."\n";
|
||||
print "Nb of errors: ".$error."\n";
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
||||
{
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
} else {
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[3])?1:$argv[3];
|
||||
$endlinenb = empty($argv[4])?0:$argv[4];
|
||||
|
||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
// Ask confirmation
|
||||
if (! $confirmed)
|
||||
{
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
if (! $confirmed) {
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
$fhandle = fopen($filepath, 'r');
|
||||
if (! $fhandle)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
if (! $fhandle) {
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
}
|
||||
$fhandleerr = fopen($filepatherr, 'w');
|
||||
if (! $fhandleerr)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
if (! $fhandleerr) {
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//$langs->setDefaultLang($defaultlang);
|
||||
@ -114,175 +110,173 @@ $db->begin();
|
||||
|
||||
$i=0;
|
||||
$nboflines=0;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
{
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
|
||||
if ($startlinenb && $i < $startlinenb) continue;
|
||||
if ($endlinenb && $i > $endlinenb) continue;
|
||||
if ($startlinenb && $i < $startlinenb) {
|
||||
continue;
|
||||
}
|
||||
if ($endlinenb && $i > $endlinenb) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nboflines++;
|
||||
$nboflines++;
|
||||
|
||||
$object = new Societe($db);
|
||||
$object->state = $fields[6];
|
||||
$object->client = $fields[7];
|
||||
$object->fournisseur = $fields[8];
|
||||
$object = new Societe($db);
|
||||
$object->state = $fields[6];
|
||||
$object->client = $fields[7];
|
||||
$object->fournisseur = $fields[8];
|
||||
|
||||
$object->name = $fields[13]?trim($fields[13]):$fields[0];
|
||||
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
|
||||
$object->name = $fields[13]?trim($fields[13]):$fields[0];
|
||||
$object->name_alias = $fields[0]!=$fields[13]?trim($fields[0]):'';
|
||||
|
||||
$object->address = trim($fields[14]);
|
||||
$object->zip = trim($fields[15]);
|
||||
$object->town = trim($fields[16]);
|
||||
$object->country_id = dol_getIdFromCode($db, trim($fields[21]), 'c_country', 'code', 'rowid');
|
||||
$object->phone = trim($fields[22]);
|
||||
$object->fax = trim($fields[23]);
|
||||
$object->email = trim($fields[26]);
|
||||
$object->idprof2 = trim($fields[29]);
|
||||
$object->tva_intra = trim($fields[34]);
|
||||
$object->default_lang = trim($fields[43]);
|
||||
$object->address = trim($fields[14]);
|
||||
$object->zip = trim($fields[15]);
|
||||
$object->town = trim($fields[16]);
|
||||
$object->country_id = dol_getIdFromCode($db, trim($fields[21]), 'c_country', 'code', 'rowid');
|
||||
$object->phone = trim($fields[22]);
|
||||
$object->fax = trim($fields[23]);
|
||||
$object->email = trim($fields[26]);
|
||||
$object->idprof2 = trim($fields[29]);
|
||||
$object->tva_intra = trim($fields[34]);
|
||||
$object->default_lang = trim($fields[43]);
|
||||
|
||||
//$condpayment = dol_string_unaccent(trim($fields[36]));
|
||||
if ($fields[36])
|
||||
{
|
||||
$condpayment = trim($fields[36]);
|
||||
if ($condpayment == 'A la commande') $condpayment = 'A réception de commande';
|
||||
if ($condpayment == 'A reception facture') $condpayment = 'Réception de facture';
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
|
||||
if (empty($object->cond_reglement_id))
|
||||
{
|
||||
print " - Error cant find payment mode for ".$condpayment."\n";
|
||||
$errorrecord++;
|
||||
}
|
||||
}
|
||||
//$condpayment = dol_string_unaccent(trim($fields[36]));
|
||||
if ($fields[36]) {
|
||||
$condpayment = trim($fields[36]);
|
||||
if ($condpayment == 'A la commande') {
|
||||
$condpayment = 'A réception de commande';
|
||||
}
|
||||
if ($condpayment == 'A reception facture') {
|
||||
$condpayment = 'Réception de facture';
|
||||
}
|
||||
$object->cond_reglement_id = dol_getIdFromCode($db, $condpayment, 'c_payment_term', 'libelle_facture', 'rowid', 1);
|
||||
if (empty($object->cond_reglement_id)) {
|
||||
print " - Error cant find payment mode for ".$condpayment."\n";
|
||||
$errorrecord++;
|
||||
}
|
||||
}
|
||||
|
||||
$object->code_client = $fields[9];
|
||||
$object->code_fournisseur = $fields[10];
|
||||
$object->code_client = $fields[9];
|
||||
$object->code_fournisseur = $fields[10];
|
||||
|
||||
$labeltype = trim($fields[1]);
|
||||
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'libelle');
|
||||
$labeltype = trim($fields[1]);
|
||||
$object->typent_id = dol_getIdFromCode($db, $labeltype, 'c_typent', 'libelle');
|
||||
|
||||
// Set price level
|
||||
$object->price_level = 1;
|
||||
if ($labeltype == 'Revendeur') $object->price_level = 2;
|
||||
// Set price level
|
||||
$object->price_level = 1;
|
||||
if ($labeltype == 'Revendeur') {
|
||||
$object->price_level = 2;
|
||||
}
|
||||
|
||||
print "Process line nb ".$i.", name ".$object->name;
|
||||
print "Process line nb ".$i.", name ".$object->name;
|
||||
|
||||
|
||||
// Extrafields
|
||||
$object->array_options['options_anastate']=price2num($fields[20]);
|
||||
$object->array_options['options_anaregion']=price2num($fields[17]);
|
||||
// Extrafields
|
||||
$object->array_options['options_anastate']=price2num($fields[20]);
|
||||
$object->array_options['options_anaregion']=price2num($fields[17]);
|
||||
|
||||
if (! $errorrecord)
|
||||
{
|
||||
$ret=$object->create($user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with name ".$object->name." - id = ".$ret;
|
||||
}
|
||||
}
|
||||
if (! $errorrecord) {
|
||||
$ret=$object->create($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with name ".$object->name." - id = ".$ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $errorrecord)
|
||||
{
|
||||
dol_syslog("Set price level");
|
||||
$object->set_price_level($object->price_level, $user);
|
||||
}
|
||||
if (! $errorrecord) {
|
||||
dol_syslog("Set price level");
|
||||
$object->set_price_level($object->price_level, $user);
|
||||
}
|
||||
|
||||
// Assign sales representative
|
||||
if (! $errorrecord && $fields[3])
|
||||
{
|
||||
$salesrep=new User($db);
|
||||
if (! $errorrecord && $fields[3]) {
|
||||
$salesrep=new User($db);
|
||||
|
||||
$tmp=explode(' ', $fields[3], 2);
|
||||
$salesrep->firstname = trim($tmp[0]);
|
||||
$salesrep->lastname = trim($tmp[1]);
|
||||
if ($salesrep->lastname) $salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
|
||||
else $salesrep->login=strtolower($salesrep->firstname);
|
||||
$salesrep->login=preg_replace('/ /', '', $salesrep->login);
|
||||
$salesrep->fetch(0, $salesrep->login);
|
||||
$tmp=explode(' ', $fields[3], 2);
|
||||
$salesrep->firstname = trim($tmp[0]);
|
||||
$salesrep->lastname = trim($tmp[1]);
|
||||
if ($salesrep->lastname) {
|
||||
$salesrep->login = strtolower(substr($salesrep->firstname, 0, 1)) . strtolower(substr($salesrep->lastname, 0));
|
||||
} else {
|
||||
$salesrep->login=strtolower($salesrep->firstname);
|
||||
}
|
||||
$salesrep->login=preg_replace('/ /', '', $salesrep->login);
|
||||
$salesrep->fetch(0, $salesrep->login);
|
||||
|
||||
$result = $object->add_commercial($user, $salesrep->id);
|
||||
if ($result < 0)
|
||||
{
|
||||
print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create link sale representative OK";
|
||||
}
|
||||
$result = $object->add_commercial($user, $salesrep->id);
|
||||
if ($result < 0) {
|
||||
print " - Error in create link with sale representative result code = ".$result." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create link sale representative OK";
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("Add invoice contacts");
|
||||
// Insert an invoice contact if there is an invoice email != standard email
|
||||
if (! $errorrecord && $fields[27] && $fields[26] != $fields[27])
|
||||
{
|
||||
$ret1=$ret2=0;
|
||||
if (! $errorrecord && $fields[27] && $fields[26] != $fields[27]) {
|
||||
$ret1=$ret2=0;
|
||||
|
||||
$contact = new Contact($db);
|
||||
$contact->lastname = $object->name;
|
||||
$contact->address=$object->address;
|
||||
$contact->zip=$object->zip;
|
||||
$contact->town=$object->town;
|
||||
$contact->country_id=$object->country_id;
|
||||
$contact->email=$fields[27];
|
||||
$contact->socid=$object->id;
|
||||
$contact = new Contact($db);
|
||||
$contact->lastname = $object->name;
|
||||
$contact->address=$object->address;
|
||||
$contact->zip=$object->zip;
|
||||
$contact->town=$object->town;
|
||||
$contact->country_id=$object->country_id;
|
||||
$contact->email=$fields[27];
|
||||
$contact->socid=$object->id;
|
||||
|
||||
$ret1=$contact->create($user);
|
||||
if ($ret1 > 0)
|
||||
{
|
||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0)
|
||||
{
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
}
|
||||
$ret1=$contact->create($user);
|
||||
if ($ret1 > 0) {
|
||||
//$ret2=$contact->add_contact($object->id, 'BILLING');
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0) {
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog("Add delivery contacts");
|
||||
// Insert a delivery contact
|
||||
if (! $errorrecord && $fields[47])
|
||||
{
|
||||
$ret1=$ret2=0;
|
||||
if (! $errorrecord && $fields[47]) {
|
||||
$ret1=$ret2=0;
|
||||
|
||||
$contact2 = new Contact($db);
|
||||
$contact2->lastname = 'Service livraison - '.$fields[47];
|
||||
$contact2->address = $fields[48];
|
||||
$contact2->zip = $fields[50];
|
||||
$contact2->town = $fields[51];
|
||||
$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
|
||||
$contact2->note_public=$fields[54];
|
||||
$contact2->socid=$object->id;
|
||||
$contact2 = new Contact($db);
|
||||
$contact2->lastname = 'Service livraison - '.$fields[47];
|
||||
$contact2->address = $fields[48];
|
||||
$contact2->zip = $fields[50];
|
||||
$contact2->town = $fields[51];
|
||||
$contact2->country_id=dol_getIdFromCode($db, trim($fields[52]), 'c_country', 'code', 'rowid');
|
||||
$contact2->note_public=$fields[54];
|
||||
$contact2->socid=$object->id;
|
||||
|
||||
// Extrafields
|
||||
$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
|
||||
// Extrafields
|
||||
$contact2->array_options['options_anazoneliv']=price2num($fields[53]);
|
||||
|
||||
$ret1=$contact2->create($user);
|
||||
if ($ret1 > 0)
|
||||
{
|
||||
//$ret2=$contact2->add_contact($object->id, 'SHIPPING');
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0)
|
||||
{
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
}
|
||||
$ret1=$contact2->create($user);
|
||||
if ($ret1 > 0) {
|
||||
//$ret2=$contact2->add_contact($object->id, 'SHIPPING');
|
||||
}
|
||||
if ($ret1 < 0 || $ret2 < 0) {
|
||||
print " - Error in create contact result code = ".$ret1." ".$ret2." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - create contact OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord)
|
||||
{
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
if ($errorrecord) {
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,13 +287,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
// commit or rollback
|
||||
print "Nb of lines qualified: ".$nboflines."\n";
|
||||
print "Nb of errors: ".$error."\n";
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
||||
{
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
} else {
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -30,8 +30,8 @@ $sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -67,44 +67,40 @@ $startlinenb = empty($argv[3])?1:$argv[3];
|
||||
$endlinenb = empty($argv[4])?0:$argv[4];
|
||||
|
||||
if (empty($mode) || ! in_array($mode, array('test','confirm','confirmforced')) || empty($filepath)) {
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Usage: $script_file (test|confirm|confirmforced) filepath.csv [startlinenb] [endlinenb]\n";
|
||||
print "Usage: $script_file test myfilepath.csv 2 1002\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
if (! file_exists($filepath)) {
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
print "Error: File ".$filepath." not found.\n";
|
||||
print "\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'A user with login "admin" and all permissions must be created to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
$user->getrights();
|
||||
|
||||
// Ask confirmation
|
||||
if (! $confirmed)
|
||||
{
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
if (! $confirmed) {
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
$fhandle = fopen($filepath, 'r');
|
||||
if (! $fhandle)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
if (! $fhandle) {
|
||||
print 'Error: Failed to open file '.$filepath."\n";
|
||||
exit(1);
|
||||
}
|
||||
$fhandleerr = fopen($filepatherr, 'w');
|
||||
if (! $fhandleerr)
|
||||
{
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
if (! $fhandleerr) {
|
||||
print 'Error: Failed to open file '.$filepatherr."\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//$langs->setDefaultLang($defaultlang);
|
||||
@ -114,44 +110,48 @@ $db->begin();
|
||||
|
||||
$i=0;
|
||||
$nboflines=0;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
{
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape)) {
|
||||
$i++;
|
||||
$errorrecord=0;
|
||||
|
||||
if ($startlinenb && $i < $startlinenb) continue;
|
||||
if ($endlinenb && $i > $endlinenb) continue;
|
||||
if ($startlinenb && $i < $startlinenb) {
|
||||
continue;
|
||||
}
|
||||
if ($endlinenb && $i > $endlinenb) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nboflines++;
|
||||
$nboflines++;
|
||||
|
||||
$object = new User($db);
|
||||
$object->statut = 1;
|
||||
$object = new User($db);
|
||||
$object->statut = 1;
|
||||
|
||||
$tmp=explode(' ', $fields[3], 2);
|
||||
$object->firstname = trim($tmp[0]);
|
||||
$object->lastname = trim($tmp[1]);
|
||||
if ($object->lastname) $object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
|
||||
else $object->login=strtolower($object->firstname);
|
||||
$object->login=preg_replace('/ /', '', $object->login);
|
||||
$object->password = 'init';
|
||||
$tmp=explode(' ', $fields[3], 2);
|
||||
$object->firstname = trim($tmp[0]);
|
||||
$object->lastname = trim($tmp[1]);
|
||||
if ($object->lastname) {
|
||||
$object->login = strtolower(substr($object->firstname, 0, 1)) . strtolower(substr($object->lastname, 0));
|
||||
} else {
|
||||
$object->login=strtolower($object->firstname);
|
||||
}
|
||||
$object->login=preg_replace('/ /', '', $object->login);
|
||||
$object->password = 'init';
|
||||
|
||||
print "Process line nb ".$i.", login ".$object->login;
|
||||
print "Process line nb ".$i.", login ".$object->login;
|
||||
|
||||
$ret=$object->create($user);
|
||||
if ($ret < 0)
|
||||
{
|
||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with login ".$object->login." - id = ".$ret;
|
||||
$ret=$object->create($user);
|
||||
if ($ret < 0) {
|
||||
print " - Error in create result code = ".$ret." - ".$object->errorsToString();
|
||||
$errorrecord++;
|
||||
} else {
|
||||
print " - Creation OK with login ".$object->login." - id = ".$ret;
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
if ($errorrecord)
|
||||
{
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
if ($errorrecord) {
|
||||
fwrite($fhandleerr, 'Error on record nb '.$i." - ".$object->errorsToString()."\n");
|
||||
$error++; // $errorrecord will be reset
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,13 +162,12 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
|
||||
// commit or rollback
|
||||
print "Nb of lines qualified: ".$nboflines."\n";
|
||||
print "Nb of errors: ".$error."\n";
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm'))
|
||||
{
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
if ($mode != 'confirmforced' && ($error || $mode != 'confirm')) {
|
||||
print "Rollback any changes.\n";
|
||||
$db->rollback();
|
||||
} else {
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
@ -30,8 +30,8 @@ $path=__DIR__.'/';
|
||||
|
||||
// Test si mode batch
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit(-1);
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Recupere root dolibarr
|
||||
@ -52,121 +52,121 @@ $error=0;
|
||||
|
||||
// List of sql to execute
|
||||
$sqls=array(
|
||||
'user'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
|
||||
),
|
||||
'event'=>array(
|
||||
//"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE datec < '__DATE__'",
|
||||
),
|
||||
'payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement_facture where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement where rowid NOT IN (SELECT fk_paiement FROM ".MAIN_DB_PREFIX."paiement_facture)",
|
||||
),
|
||||
'supplier_payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn where fk_facturefourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn where rowid NOT IN (SELECT fk_paiementfourn FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn)",
|
||||
),
|
||||
'bank'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__'",
|
||||
),
|
||||
'bankaccount'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_account WHERE datec < '__DATE__'",
|
||||
),
|
||||
'invoice'=>array(
|
||||
'@payment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_source IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_line IN (select rowid FROM ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture IN (select rowid from ".MAIN_DB_PREFIX."facture where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_rec where datec < '__DATE__'",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"UPDATE ".MAIN_DB_PREFIX."facture SET fk_facture_source = NULL WHERE fk_facture_source IN (select f2.rowid FROM (select * from ".MAIN_DB_PREFIX."facture) as f2 where f2.datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__'",
|
||||
),
|
||||
'accounting'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."accounting_bookkeeping where doc_date < '__DATE__'",
|
||||
),
|
||||
'proposal'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."propal WHERE datec < '__DATE__'",
|
||||
),
|
||||
"supplier_proposal"=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal where datec < '__DATE__'",
|
||||
),
|
||||
'order'=>array(
|
||||
'@shipment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__'",
|
||||
),
|
||||
'supplier_order'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
||||
),
|
||||
'user'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."user_rights WHERE fk_user IN (SELECT rowid FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin') AND fk_user IN (select rowid FROM ".MAIN_DB_PREFIX."user where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."user WHERE admin = 0 and login != 'admin' AND datec < '__DATE__'",
|
||||
),
|
||||
'event'=>array(
|
||||
//"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."actioncomm WHERE datec < '__DATE__'",
|
||||
),
|
||||
'payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement_facture where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiement where rowid NOT IN (SELECT fk_paiement FROM ".MAIN_DB_PREFIX."paiement_facture)",
|
||||
),
|
||||
'supplier_payment'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn where fk_facturefourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."paiementfourn where rowid NOT IN (SELECT fk_paiementfourn FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn)",
|
||||
),
|
||||
'bank'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_class WHERE lineid IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_url WHERE fk_bank IN (SELECT rowid FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank WHERE datec < '__DATE__'",
|
||||
),
|
||||
'bankaccount'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."bank_account WHERE datec < '__DATE__'",
|
||||
),
|
||||
'invoice'=>array(
|
||||
'@payment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_source IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except where fk_facture_line IN (select rowid FROM ".MAIN_DB_PREFIX."facturedet as fd WHERE fd.fk_facture IN (select rowid from ".MAIN_DB_PREFIX."facture where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_rec where datec < '__DATE__'",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE fk_facture IN (select rowid FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__')",
|
||||
"UPDATE ".MAIN_DB_PREFIX."facture SET fk_facture_source = NULL WHERE fk_facture_source IN (select f2.rowid FROM (select * from ".MAIN_DB_PREFIX."facture) as f2 where f2.datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture where datec < '__DATE__'",
|
||||
),
|
||||
'accounting'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."accounting_bookkeeping where doc_date < '__DATE__'",
|
||||
),
|
||||
'proposal'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."propal WHERE datec < '__DATE__'",
|
||||
),
|
||||
"supplier_proposal"=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposaldet WHERE fk_supplier_proposal IN (select rowid FROM ".MAIN_DB_PREFIX."propal where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."supplier_proposal where datec < '__DATE__'",
|
||||
),
|
||||
'order'=>array(
|
||||
'@shipment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande where date_creation < '__DATE__'",
|
||||
),
|
||||
'supplier_order'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande IN (select rowid FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where date_creation < '__DATE__'",
|
||||
),
|
||||
'supplier_invoice'=>array(
|
||||
'@supplier_payment',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det WHERE fk_facture_fourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__'",
|
||||
),
|
||||
'shipment'=>array(
|
||||
'@delivery',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch WHERE fk_expeditiondet IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'",
|
||||
),
|
||||
'delivery'=>array(
|
||||
"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__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat WHERE datec < '__DATE__'",
|
||||
),
|
||||
'intervention'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter IN (select rowid FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__'",
|
||||
),
|
||||
'stock'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement WHERE datem < '__DATE__'",
|
||||
),
|
||||
'product'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lang WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty WHERE fk_product_price IN (select rowid FROM ".MAIN_DB_PREFIX."product_price where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE fk_product_stock IN (select rowid FROM ".MAIN_DB_PREFIX."product_stock where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lot WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
|
||||
),
|
||||
'project'=>array(
|
||||
// TODO set fk_project to null on object that refer to project
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
|
||||
),
|
||||
'contact'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople IN (select rowid FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__'",
|
||||
),
|
||||
'thirdparty'=>array(
|
||||
'@contact',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."cabinetmed_cons WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = NULL WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__'",
|
||||
)
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn_det WHERE fk_facture_fourn IN (select rowid FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."facture_fourn where datec < '__DATE__'",
|
||||
),
|
||||
'shipment'=>array(
|
||||
'@delivery',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_batch WHERE fk_expeditiondet IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."expedition where date_creation < '__DATE__'",
|
||||
),
|
||||
'delivery'=>array(
|
||||
"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__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contratdet WHERE fk_contrat IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat_extrafields WHERE fk_object IN (select rowid FROM ".MAIN_DB_PREFIX."contrat where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."contrat WHERE datec < '__DATE__'",
|
||||
),
|
||||
'intervention'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinterdet WHERE fk_fichinter IN (select rowid FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."fichinter where datec < '__DATE__'",
|
||||
),
|
||||
'stock'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement WHERE datem < '__DATE__'",
|
||||
),
|
||||
'product'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_product WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lang WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price_by_qty WHERE fk_product_price IN (select rowid FROM ".MAIN_DB_PREFIX."product_price where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_batch WHERE fk_product_stock IN (select rowid FROM ".MAIN_DB_PREFIX."product_stock where fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_stock WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product_lot WHERE fk_product IN (select rowid FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."product where datec < '__DATE__'",
|
||||
),
|
||||
'project'=>array(
|
||||
// TODO set fk_project to null on object that refer to project
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task_time WHERE fk_task IN (select rowid FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'))",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet_task WHERE fk_projet IN (select rowid FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."projet where datec < '__DATE__'",
|
||||
),
|
||||
'contact'=>array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_contact WHERE fk_socpeople IN (select rowid FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."socpeople where datec < '__DATE__'",
|
||||
),
|
||||
'thirdparty'=>array(
|
||||
'@contact',
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."cabinetmed_cons WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"UPDATE ".MAIN_DB_PREFIX."adherent SET fk_soc = NULL WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_fournisseur WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe_rib WHERE fk_soc IN (select rowid FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__')",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."societe where datec < '__DATE__'",
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@ -183,44 +183,42 @@ $option = $argv[2];
|
||||
$date = $argv[3];
|
||||
|
||||
if (empty($mode) || ! in_array($mode, array('test','confirm'))) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option can be ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option can be ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
}
|
||||
if (empty($option))
|
||||
{
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option must be defined with a value in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
if (empty($option)) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option must be defined with a value in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
}
|
||||
if ($option != 'all')
|
||||
{
|
||||
$listofoptions=explode(',', $option);
|
||||
foreach ($listofoptions as $cursoroption)
|
||||
{
|
||||
if (! in_array($cursoroption, array_keys($sqls))) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
if ($option != 'all') {
|
||||
$listofoptions=explode(',', $option);
|
||||
foreach ($listofoptions as $cursoroption) {
|
||||
if (! in_array($cursoroption, array_keys($sqls))) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "option '".$cursoroption."' must be in list ".implode(',', array_keys($sqls))."\n";
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($date) || (! preg_match('/\d\d\d\d\-\d\d\-\d\d$/', $date) && $date != 'all')) {
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
|
||||
exit(-1);
|
||||
print "Usage: $script_file (test|confirm) (all|option) (all|YYYY-MM-DD) [dbtype dbhost dbuser dbpassword dbname dbport]\n";
|
||||
print "\n";
|
||||
print "date can be 'all' or 'YYYY-MM-DD' to delete record before YYYY-MM-DD\n";
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if ($date == 'all') $date = '2199-01-01';
|
||||
if ($date == 'all') {
|
||||
$date = '2199-01-01';
|
||||
}
|
||||
|
||||
// Replace database handler
|
||||
if (! empty($argv[4]))
|
||||
{
|
||||
if (! empty($argv[4])) {
|
||||
$db->close();
|
||||
unset($db);
|
||||
$db=getDoliDBInstance($argv[4], $argv[5], $argv[6], $argv[7], $argv[8], $argv[9]);
|
||||
@ -229,8 +227,7 @@ if (! empty($argv[4]))
|
||||
|
||||
//var_dump($user->db->database_name);
|
||||
$ret=$user->fetch('', 'admin');
|
||||
if (! $ret > 0)
|
||||
{
|
||||
if (! $ret > 0) {
|
||||
print 'An admin user with login "admin" must exists to use this script.'."\n";
|
||||
exit;
|
||||
}
|
||||
@ -245,10 +242,9 @@ print "Database port = ".$db->database_port."\n";
|
||||
print "User = ".$db->database_user."\n";
|
||||
print "\n";
|
||||
|
||||
if (! $confirmed)
|
||||
{
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
if (! $confirmed) {
|
||||
print "Hit Enter to continue or CTRL+C to stop...\n";
|
||||
$input = trim(fgets(STDIN));
|
||||
}
|
||||
|
||||
|
||||
@ -261,73 +257,71 @@ if (! $confirmed)
|
||||
*/
|
||||
function processfamily($family, $date)
|
||||
{
|
||||
global $db, $sqls;
|
||||
global $db, $sqls;
|
||||
|
||||
$error=0;
|
||||
foreach ($sqls[$family] as $sql)
|
||||
{
|
||||
if (preg_match('/^@/', $sql))
|
||||
{
|
||||
$newfamily=preg_replace('/@/', '', $sql);
|
||||
processfamily($newfamily, $date);
|
||||
continue;
|
||||
}
|
||||
$error=0;
|
||||
foreach ($sqls[$family] as $sql) {
|
||||
if (preg_match('/^@/', $sql)) {
|
||||
$newfamily=preg_replace('/@/', '', $sql);
|
||||
processfamily($newfamily, $date);
|
||||
continue;
|
||||
}
|
||||
|
||||
$sql = preg_replace('/__DATE__/', $date, $sql);
|
||||
$sql = preg_replace('/__DATE__/', $date, $sql);
|
||||
|
||||
print "Run sql: ".$sql."\n";
|
||||
print "Run sql: ".$sql."\n";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
if ($db->errno() != 'DB_ERROR_NOSUCHTABLE')
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
$resql=$db->query($sql);
|
||||
if (! $resql) {
|
||||
if ($db->errno() != 'DB_ERROR_NOSUCHTABLE') {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
print $db->lasterror();
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
print $db->lasterror();
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) return -1;
|
||||
else return 1;
|
||||
if ($error) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$db->begin();
|
||||
|
||||
$listofoptions=explode(',', $option);
|
||||
foreach ($listofoptions as $cursoroption)
|
||||
{
|
||||
$oldfamily='';
|
||||
foreach ($sqls as $family => $familysql)
|
||||
{
|
||||
if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) continue;
|
||||
foreach ($listofoptions as $cursoroption) {
|
||||
$oldfamily='';
|
||||
foreach ($sqls as $family => $familysql) {
|
||||
if ($cursoroption && $cursoroption != 'all' && $cursoroption != $family) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($family != $oldfamily) print "Process action for family ".$family."\n";
|
||||
$oldfamily = $family;
|
||||
if ($family != $oldfamily) {
|
||||
print "Process action for family ".$family."\n";
|
||||
}
|
||||
$oldfamily = $family;
|
||||
|
||||
$result=processfamily($family, $date);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result=processfamily($family, $date);
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error || $mode != 'confirm')
|
||||
{
|
||||
print "\nRollback any changes.\n";
|
||||
$db->rollback();
|
||||
if ($error || $mode != 'confirm') {
|
||||
print "\nRollback any changes.\n";
|
||||
$db->rollback();
|
||||
} else {
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
print "Commit all changes.\n";
|
||||
$db->commit();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 172 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
@ -32,12 +32,14 @@ base=$2;
|
||||
port=$3;
|
||||
demologin=$4;
|
||||
demopass=$5;
|
||||
demopasshash=$6;
|
||||
|
||||
# ----------------------------- check params
|
||||
if [ "x$confirm" != "xconfirm" ]
|
||||
then
|
||||
echo "----- $0 -----"
|
||||
echo "Usage: initdemopassword.sh confirm [base port login pass]"
|
||||
echo "Usage: initdemopassword.sh confirm [base port login pass password_hash_algo]"
|
||||
echo "password_hash_algo can be md5 of password_hash"
|
||||
exit
|
||||
fi
|
||||
|
||||
@ -148,7 +150,15 @@ fi
|
||||
#echo "mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile"
|
||||
#mysql -P$port -u$admin $passwd $base < $mydir/$dumpfile
|
||||
echo "echo \"UPDATE llx_user SET pass_crypted = MD5('$demopass') WHERE login = '$demologin';\" | mysql -P$port $base"
|
||||
echo "UPDATE llx_user SET pass_crypted = MD5('$demopass') WHERE login = '$demologin';" | mysql -P$port $base
|
||||
|
||||
if [ "x$demopasshash" != "xpassword_hash" ]
|
||||
then
|
||||
newpass=`echo '<?php echo md5("$demopass"); ?>' | php`
|
||||
else
|
||||
newpass=`echo '<?php echo password_hash("$demopass", PASSWORD_DEFAULT); ?>' | php`
|
||||
fi
|
||||
|
||||
echo "UPDATE llx_user SET pass_crypted = '$newpass' WHERE login = '$demologin';" | mysql -P$port $base
|
||||
export res=$?
|
||||
|
||||
if [ $res -ne 0 ]; then
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -259,6 +259,7 @@ export list="
|
||||
--ignore-table=$base.llx_dolireport_plot
|
||||
--ignore-table=$base.llx_dolireport_report
|
||||
--ignore-table=$base.llx_domain
|
||||
--ignore-table=$base.llx_ecommerce_category
|
||||
--ignore-table=$base.llx_ecommerce_commande
|
||||
--ignore-table=$base.llx_ecommerce_facture
|
||||
--ignore-table=$base.llx_ecommerce_product
|
||||
|
||||
@ -41,14 +41,30 @@ $passwordbase=isset($argv[6])?$argv[6]:'';
|
||||
|
||||
// Include Dolibarr environment
|
||||
$res=0;
|
||||
if (! $res && file_exists($path."../../master.inc.php")) $res=@include $path."../../master.inc.php";
|
||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) $res=@include $path."../../htdocs/master.inc.php";
|
||||
if (! $res && file_exists("../master.inc.php")) $res=@include "../master.inc.php";
|
||||
if (! $res && file_exists("../../master.inc.php")) $res=@include "../../master.inc.php";
|
||||
if (! $res && file_exists("../../../master.inc.php")) $res=@include "../../../master.inc.php";
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
if (! $res) die("Failed to include master.inc.php file\n");
|
||||
if (! $res && file_exists($path."../../master.inc.php")) {
|
||||
$res=@include $path."../../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
|
||||
$res=@include $path."../../htdocs/master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../master.inc.php")) {
|
||||
$res=@include "../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../../master.inc.php")) {
|
||||
$res=@include "../../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../../../master.inc.php")) {
|
||||
$res=@include "../../../master.inc.php";
|
||||
}
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||
$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
}
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||
$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
}
|
||||
if (! $res) {
|
||||
die("Failed to include master.inc.php file\n");
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
|
||||
@ -58,15 +74,13 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$login='';
|
||||
$server='';
|
||||
if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg))
|
||||
{
|
||||
if (preg_match('/^(.*)@(.*):(.*)$/', $sourceserver, $reg)) {
|
||||
$login=$reg[1];
|
||||
$server=$reg[2];
|
||||
$sourcefile=$reg[3];
|
||||
$targetfile=basename($sourcefile);
|
||||
}
|
||||
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase))
|
||||
{
|
||||
if (empty($sourceserver) || empty($server) || empty($login) || empty($sourcefile) || empty($password) || empty($database) || empty($loginbase) || empty($passwordbase)) {
|
||||
print "Usage: $script_file login@server:/src/file.(sql|gz|bz2) passssh databaseserver databasename loginbase passbase\n";
|
||||
print "Return code: 0 if success, <>0 if error\n";
|
||||
print "Warning, this script may take a long time.\n";
|
||||
@ -88,14 +102,11 @@ if (! function_exists("ssh2_connect")) {
|
||||
}
|
||||
|
||||
$connection = ssh2_connect($server, 22);
|
||||
if ($connection)
|
||||
{
|
||||
if (! @ssh2_auth_password($connection, $login, $password))
|
||||
{
|
||||
if ($connection) {
|
||||
if (! @ssh2_auth_password($connection, $login, $password)) {
|
||||
dol_syslog("Could not authenticate with username ".$login." . and password ".preg_replace('/./', '*', $password), LOG_ERR);
|
||||
exit(-5);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//$stream = ssh2_exec($connection, '/usr/bin/php -i');
|
||||
/*
|
||||
print "Generate dump ".$filesys1.'.bz2'."\n";
|
||||
@ -111,12 +122,10 @@ if ($connection)
|
||||
ssh2_scp_recv($connection, $sourcefile, $targetdir.$targetfile);
|
||||
|
||||
$fullcommand="cat ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
if (preg_match('/\.bz2$/', $targetfile))
|
||||
{
|
||||
if (preg_match('/\.bz2$/', $targetfile)) {
|
||||
$fullcommand="bzip2 -c -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
}
|
||||
if (preg_match('/\.gz$/', $targetfile))
|
||||
{
|
||||
if (preg_match('/\.gz$/', $targetfile)) {
|
||||
$fullcommand="gzip -d ".$targetdir.$targetfile." | mysql -h".$databaseserver." -u".$loginbase." -p".$passwordbase." -D ".$database;
|
||||
}
|
||||
print "Load dump with ".$fullcommand."\n";
|
||||
@ -124,13 +133,14 @@ if ($connection)
|
||||
$return_var=0;
|
||||
print strftime("%Y%m%d-%H%M%S").' '.$fullcommand."\n";
|
||||
exec($fullcommand, $output, $return_var);
|
||||
foreach ($output as $line) print $line."\n";
|
||||
foreach ($output as $line) {
|
||||
print $line."\n";
|
||||
}
|
||||
|
||||
//ssh2_sftp_unlink($sftp, $fileinstalllock);
|
||||
//print $output;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print 'Failed to connect to ssh2 to '.$server;
|
||||
exit(-6);
|
||||
}
|
||||
|
||||
@ -36,14 +36,30 @@ $confirm=isset($argv[1])?$argv[1]:'';
|
||||
|
||||
// Include Dolibarr environment
|
||||
$res=0;
|
||||
if (! $res && file_exists($path."../../master.inc.php")) $res=@include $path."../../master.inc.php";
|
||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) $res=@include $path."../../htdocs/master.inc.php";
|
||||
if (! $res && file_exists("../master.inc.php")) $res=@include "../master.inc.php";
|
||||
if (! $res && file_exists("../../master.inc.php")) $res=@include "../../master.inc.php";
|
||||
if (! $res && file_exists("../../../master.inc.php")) $res=@include "../../../master.inc.php";
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) $res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
if (! $res) die("Failed to include master.inc.php file\n");
|
||||
if (! $res && file_exists($path."../../master.inc.php")) {
|
||||
$res=@include $path."../../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists($path."../../htdocs/master.inc.php")) {
|
||||
$res=@include $path."../../htdocs/master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../master.inc.php")) {
|
||||
$res=@include "../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../../master.inc.php")) {
|
||||
$res=@include "../../master.inc.php";
|
||||
}
|
||||
if (! $res && file_exists("../../../master.inc.php")) {
|
||||
$res=@include "../../../master.inc.php";
|
||||
}
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||
$res=@include $path."../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
}
|
||||
if (! $res && preg_match('/\/nltechno([^\/]*)\//', $_SERVER["PHP_SELF"], $reg)) {
|
||||
$res=@include "../../../dolibarr".$reg[1]."/htdocs/master.inc.php"; // Used on dev env only
|
||||
}
|
||||
if (! $res) {
|
||||
die("Failed to include master.inc.php file\n");
|
||||
}
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
|
||||
@ -53,8 +69,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
print "***** ".$script_file." *****\n";
|
||||
print "Update dates to current year for database name = ".$db->database_name."\n";
|
||||
if (empty($confirm))
|
||||
{
|
||||
if (empty($confirm)) {
|
||||
print "Usage: $script_file confirm\n";
|
||||
print "Return code: 0 if success, <>0 if error\n";
|
||||
exit(-1);
|
||||
@ -65,66 +80,65 @@ $tmp=dol_getdate(dol_now());
|
||||
|
||||
|
||||
$tables=array(
|
||||
'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'),
|
||||
'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'),
|
||||
'propal'=>array(0=>'datep', 1=>'fin_validite', 2=>'date_valid', 3=>'date_cloture'),
|
||||
'commande'=>array(0=>'date_commande', 1=>'date_valid', 2=>'date_cloture'),
|
||||
'facture'=>array(0=>'datec', 0=>'datef', 1=>'date_valid', 2=>'date_lim_reglement'),
|
||||
'paiement'=>array(0=>'datep'),
|
||||
'bank'=>array(0=>'datev', 1=>'dateo'),
|
||||
'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'),
|
||||
'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'),
|
||||
'paiement'=>array(0=>'datep'),
|
||||
'bank'=>array(0=>'datev', 1=>'dateo'),
|
||||
'commande_fournisseur'=>array(0=>'date_commande', 1=>'date_valid', 3=>'date_creation', 4=>'date_approve', 5=>'date_approve2', 6=>'date_livraison'),
|
||||
'supplier_proposal'=>array(0=>'datec', 1=>'date_valid', 2=>'date_cloture'),
|
||||
'expensereport'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 4=>'date_approve', 5=>'date_refuse', 6=>'date_cancel'),
|
||||
'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel')
|
||||
'holiday'=>array(0=>'date_debut', 1=>'date_fin', 2=>'date_create', 3=>'date_valid', 5=>'date_refuse', 6=>'date_cancel'),
|
||||
'ticket'=>array(0=>'datec', 1=>'date_read', 2=>'date_close')
|
||||
);
|
||||
|
||||
$year=2010;
|
||||
$currentyear=$tmp['year'];
|
||||
while ($year <= $currentyear)
|
||||
{
|
||||
//$year=2021;
|
||||
$delta1=($currentyear - $year);
|
||||
$delta2=($currentyear - $year - 1);
|
||||
//$delta=-1;
|
||||
while ($year <= $currentyear) {
|
||||
//$year=2021;
|
||||
$delta1=($currentyear - $year);
|
||||
$delta2=($currentyear - $year - 1);
|
||||
//$delta=-1;
|
||||
|
||||
if ($delta1)
|
||||
{
|
||||
foreach ($tables as $tablekey => $tableval)
|
||||
{
|
||||
print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
|
||||
$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
|
||||
//$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i=0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
if ($obj)
|
||||
{
|
||||
print ".";
|
||||
$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
|
||||
$j=0;
|
||||
foreach ($tableval as $field)
|
||||
{
|
||||
if ($j) $sql2.=", ";
|
||||
$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
|
||||
$j++;
|
||||
}
|
||||
$sql2.=" WHERE rowid = ".$obj->rowid;
|
||||
//print $sql2."\n";
|
||||
$resql2 = $db->query($sql2);
|
||||
if (! $resql2) dol_print_error($db);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else dol_print_error($db);
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
if ($delta1) {
|
||||
foreach ($tables as $tablekey => $tableval) {
|
||||
print "Correct ".$tablekey." for year ".$year." and move them to current year ".$currentyear." ";
|
||||
$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." < DATE_ADD(NOW(), INTERVAL -1 YEAR)";
|
||||
//$sql="select rowid from ".MAIN_DB_PREFIX.$tablekey." where ".$tableval[0]." between '".$year."-01-01' and '".$year."-12-31' and ".$tableval[0]." > NOW()";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i=0;
|
||||
while ($i < $num) {
|
||||
$obj=$db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
print ".";
|
||||
$sql2="UPDATE ".MAIN_DB_PREFIX.$tablekey." set ";
|
||||
$j=0;
|
||||
foreach ($tableval as $field) {
|
||||
if ($j) {
|
||||
$sql2.=", ";
|
||||
}
|
||||
$sql2.= $field." = ".$db->ifsql("DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR) > NOW()", "DATE_ADD(".$field.", INTERVAL ".$delta2." YEAR)", "DATE_ADD(".$field.", INTERVAL ".$delta1." YEAR)");
|
||||
$j++;
|
||||
}
|
||||
$sql2.=" WHERE rowid = ".$obj->rowid;
|
||||
//print $sql2."\n";
|
||||
$resql2 = $db->query($sql2);
|
||||
if (! $resql2) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$year++;
|
||||
$year++;
|
||||
}
|
||||
|
||||
print "\n";
|
||||
|
||||
Binary file not shown.
@ -1,3 +1,7 @@
|
||||
Barcode EAN 13
|
||||
|
||||
FR
|
||||
==
|
||||
Signification des chiffres.
|
||||
|
||||
- 2 chiffres pour le code pays ou code systeme
|
||||
@ -9,6 +13,24 @@ Cette regle subit de nombreuses entorses pour ameliorer l'usage des chiffres dis
|
||||
Voici la liste des codes pays ou systeme :
|
||||
|
||||
|
||||
|
||||
EN
|
||||
==
|
||||
Meaning of the numbers.
|
||||
|
||||
- 2 digits for the country code or system code
|
||||
- 5 digits for the company identifier
|
||||
- 5 digits for item identifier
|
||||
- 1 digit for checksum
|
||||
|
||||
This rule has been twisted many times to improve the use of the available numbers.
|
||||
Here is the list of country codes or system:
|
||||
|
||||
|
||||
|
||||
List
|
||||
====
|
||||
|
||||
00 <20> 13 UCC (Etats-Unis et Canada)
|
||||
20 <20> 29 Codification interne en magasin
|
||||
30 <20> 37 GENCOD-EAN France
|
||||
@ -104,4 +126,4 @@ Voici la liste des codes pays ou systeme :
|
||||
978 - 979 Livres (ISBN)
|
||||
980 Refus de remboursement
|
||||
981 - 982 Coupons (monnaie courante)
|
||||
99 Coupons
|
||||
99 Coupons
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
Spain https://incwell.eu/en/company-formation-spain/
|
||||
|
||||
France https://www.economie.gouv.fr/entreprises/numeros-identification-entreprise
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
* Page with license compatibility
|
||||
https://www.gnu.org/licenses/quick-guide-gplv3.fr.html
|
||||
[EN] https://www.gnu.org/licenses/quick-guide-gplv3.en.html
|
||||
[FR] https://www.gnu.org/licenses/quick-guide-gplv3.fr.html
|
||||
|
||||
* FAQ on GPL license
|
||||
https://www.fsf.org/licensing/licenses/gpl-faq.html
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<exclude-pattern type="relative">build/html</exclude-pattern>
|
||||
<exclude-pattern type="relative">build/aps</exclude-pattern>
|
||||
<exclude-pattern type="relative">dev/tools/test/namespacemig</exclude-pattern>
|
||||
<exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern>
|
||||
<!-- <exclude-pattern type="relative">dev/initdata/dbf/includes</exclude-pattern> -->
|
||||
<exclude-pattern type="relative">documents</exclude-pattern>
|
||||
<exclude-pattern type="relative">htdocs/core/class/lessc.class.php</exclude-pattern>
|
||||
<exclude-pattern type="relative">htdocs/custom</exclude-pattern>
|
||||
@ -104,9 +104,9 @@
|
||||
</rule>
|
||||
-->
|
||||
<!-- We want to allow 'if () { ...small code... }' on same line for better code compacity and readability -->
|
||||
<rule ref="Generic.Formatting.DisallowMultipleStatements">
|
||||
<!-- <rule ref="Generic.Formatting.DisallowMultipleStatements">
|
||||
<severity>0</severity>
|
||||
</rule>
|
||||
</rule> -->
|
||||
|
||||
|
||||
<!-- Check assignement have the = align on each line. Have 20 chars padding maximum and always show as errors -->
|
||||
@ -174,8 +174,8 @@
|
||||
<rule ref="Generic.Strings.UnnecessaryStringConcat.Found">
|
||||
</rule>
|
||||
|
||||
<!-- Disallow usage of tab -->
|
||||
<!-- <rule ref="Generic.WhiteSpace.DisallowTabIndent" /> -->
|
||||
<!-- Disallow usage of space -->
|
||||
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
|
||||
|
||||
<!-- Check indent are done with spaces and with correct number -->
|
||||
<!-- Disabled as this does not support tab -->
|
||||
@ -214,8 +214,8 @@
|
||||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
|
||||
<rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
|
||||
|
||||
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" /> -->
|
||||
<!-- <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" /> -->
|
||||
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis" />
|
||||
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace" />
|
||||
<rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword" />
|
||||
|
||||
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.SpaceAfterOpen" />
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
# Fail2Ban configuration file
|
||||
#
|
||||
# Regexp to catch known spambots and software alike. Please verify
|
||||
# that it is your intent to block IPs which were driven by
|
||||
# above mentioned bots.
|
||||
|
||||
|
||||
[Definition]
|
||||
|
||||
# To test, you can inject this example into log
|
||||
# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 functions_dolibarr::check_user_password_abcd Authentication KO" >> /mypath/documents/dolibarr.log
|
||||
#
|
||||
# then
|
||||
# fail2ban-client status web-dol-bruteforce
|
||||
#
|
||||
# To test rule file on a existing log file
|
||||
# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulesbruteforce.conf
|
||||
|
||||
failregex = ^ [A-Z\s]+ <HOST>\s+functions_dolibarr::check_user_password_.* Authentication KO
|
||||
ignoreregex =
|
||||
@ -0,0 +1,20 @@
|
||||
# Fail2Ban configuration file
|
||||
#
|
||||
# Regexp to catch known spambots and software alike. Please verify
|
||||
# that it is your intent to block IPs which were driven by
|
||||
# above mentioned bots.
|
||||
|
||||
|
||||
[Definition]
|
||||
|
||||
# To test, you can inject this example into log
|
||||
# echo `date +'%Y-%m-%d %H:%M:%S'`" INFO 1.2.3.4 --- Access to GET /passwordforgotten.php - action=buildnewpassword, massaction=" >> /mypath/documents/dolibarr.log
|
||||
#
|
||||
# then
|
||||
# fail2ban-client status web-dol-passforgotten
|
||||
#
|
||||
# To test rule file on a existing log file
|
||||
# fail2ban-regex /mypath/documents/dolibarr.log /etc/fail2ban/filter.d/web-dolibarr-rulespassforgotten.conf
|
||||
|
||||
failregex = ^ [A-Z\s]+ <HOST>\s+--- Access to .*/passwordforgotten.php - action=buildnewpassword
|
||||
ignoreregex =
|
||||
28
dev/setup/fail2ban/jail.local
Normal file
28
dev/setup/fail2ban/jail.local
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# Examle of rule you can add to fail2ban to restrict bruteforce attacks.
|
||||
#
|
||||
|
||||
[web-dol-passforgotten]
|
||||
|
||||
; rule against call of passwordforgottenpage
|
||||
enabled = true
|
||||
port = http,https
|
||||
filter = web-dolibarr-rulespassforgotten
|
||||
logpath = >> /mypath/documents/documents/dolibarr.log
|
||||
action = %(action_mw)s
|
||||
bantime = 4320000 ; 50 days
|
||||
findtime = 86400 ; 1 day
|
||||
maxretry = 10
|
||||
|
||||
[web-dol-bruteforce]
|
||||
|
||||
; rule against bruteforce hacking (login + api)
|
||||
enabled = true
|
||||
port = http,https
|
||||
filter = web-dolibarr-rulesbruteforce
|
||||
logpath = >> /mypath/documents/documents/dolibarr.log
|
||||
action = %(action_mw)s
|
||||
bantime = 86400 ; 1 day
|
||||
findtime = 3600 ; 1 hour
|
||||
maxretry = 10
|
||||
|
||||
73
dev/setup/git/hooks/pre-commit
Normal file
73
dev/setup/git/hooks/pre-commit
Normal file
@ -0,0 +1,73 @@
|
||||
#!/bin/sh
|
||||
# To install this precommit file: put this file in your local repo in .git/hooks directory and make it executable.
|
||||
# You may need to set th DIRPHPCS to the path to your phpcs install.
|
||||
# If phpcs check fail and AUTOFIX is set to 1, then it run phpcbf to fix automaticaly the syntax, and git commit is canceled.
|
||||
# If you have a multiprocessor computer, you can add to the option --parallel=xx
|
||||
# When running git commit, it first execute this file checking only modified files, so it is faster than running on all files
|
||||
# To run the fix manually: cd ~/git/dolibarr; phpcbf -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 "fileordir"
|
||||
|
||||
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
|
||||
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
|
||||
DIRPHPCS=""
|
||||
AUTOFIX=1
|
||||
|
||||
echo "Running precommit hook in .git/hooks/pre-commit" 1>&2;
|
||||
|
||||
# Determine if a file list is passed
|
||||
if [ "$#" -eq 1 ]
|
||||
then
|
||||
oIFS=$IFS
|
||||
IFS='
|
||||
'
|
||||
SFILES="$1"
|
||||
IFS=$oIFS
|
||||
fi
|
||||
SFILES=${SFILES:-$STAGED_FILES_CMD}
|
||||
|
||||
echo "Checking PHP Lint with php -l ..."
|
||||
|
||||
for FILE in $SFILES
|
||||
do
|
||||
php -l -d display_errors=0 $PROJECT/$FILE
|
||||
|
||||
result1=$?
|
||||
|
||||
if [ "x$result1" != "x0" ]
|
||||
then
|
||||
echo "Fix the error before commit." 1>&2;
|
||||
exit 1
|
||||
fi
|
||||
FILES="$FILES $PROJECT/$FILE"
|
||||
done
|
||||
|
||||
|
||||
if [ "$FILES" != "" ]
|
||||
then
|
||||
echo "Running PHPCS Code Sniffer..."
|
||||
|
||||
#~/vendor/bin/phpcs --version
|
||||
#phpcs --standard=PSR2 --encoding=utf-8 -n -p $FILES
|
||||
# Check Dolibarr standard
|
||||
${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
|
||||
# Check your own standard
|
||||
#${DIRPHPCS}phpcs -s -p -d memory_limit=-1 --parallel=2 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
|
||||
|
||||
result2=$?
|
||||
|
||||
if [ "x$result2" != "x0" ]
|
||||
then
|
||||
# Fix standard errors
|
||||
if [ "x$AUTOFIX" != "x0" ]
|
||||
then
|
||||
${DIRPHPCS}phpcbf -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 $FILES
|
||||
#${DIRPHPCS}phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=htdocs/custom/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true $FILES
|
||||
echo "Found some errors in syntax rules. An automatic fix has been applied. Check it before commit." 1>&2;
|
||||
exit 1
|
||||
else
|
||||
echo "Found some errors in syntax rules. Fix the error(s) before commit." 1>&2;
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@ -5,13 +5,13 @@ server {
|
||||
|
||||
root /path/to/your/htdocs;
|
||||
|
||||
# Optionnal
|
||||
# Optional
|
||||
error_log /path/to/your/log/directory/nginx.error.log;
|
||||
access_log /path/to/your/log/directory/nginx.access.log;
|
||||
|
||||
index index.php index.html index.htm;
|
||||
|
||||
# Optionnal
|
||||
# Optional
|
||||
server_name your-fqdn.tld;
|
||||
|
||||
location / {
|
||||
@ -23,6 +23,6 @@ server {
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_read_timeout 600;
|
||||
include fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock;
|
||||
fastcgi_pass unix:/var/run/php5-fpm.sock; // /var/run/php/php7.0-fpm.sock
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,8 +48,9 @@ if (! ($argv[1] && $argv[2])) {
|
||||
echo "Usage: php pg2mysql_cli.php <inputfilename> <outputfilename> [engine]\n";
|
||||
exit();
|
||||
} else {
|
||||
if (isset($argv[3]))
|
||||
if (isset($argv[3])) {
|
||||
$config['engine'] = $argv[3];
|
||||
}
|
||||
pg2mysql_large($argv[1], $argv[2]);
|
||||
|
||||
echo <<<XHTML
|
||||
@ -74,14 +75,18 @@ function getfieldname($l)
|
||||
// first check if its in nice quotes for us
|
||||
$regs = array();
|
||||
if (preg_match("/`(.*)`/", $l, $regs)) {
|
||||
if ($regs[1])
|
||||
if ($regs[1]) {
|
||||
return $regs[1];
|
||||
else return null;
|
||||
} // if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
|
||||
elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
|
||||
if ($regs[1])
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} elseif (preg_match("/([^\ ]*)/", trim($l), $regs)) {
|
||||
// if its not in quotes, then it should (we hope!) be the first "word" on the line, up to the first space.
|
||||
if ($regs[1]) {
|
||||
return $regs[1];
|
||||
else return null;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,13 +99,15 @@ function getfieldname($l)
|
||||
*/
|
||||
function formatsize($s)
|
||||
{
|
||||
if ($s < pow(2, 14))
|
||||
if ($s < pow(2, 14)) {
|
||||
return "{$s}B";
|
||||
elseif ($s < pow(2, 20))
|
||||
} elseif ($s < pow(2, 20)) {
|
||||
return sprintf("%.1f", round($s / 1024, 1)) . "K";
|
||||
elseif ($s < pow(2, 30))
|
||||
} elseif ($s < pow(2, 30)) {
|
||||
return sprintf("%.1f", round($s / 1024 / 1024, 1)) . "M";
|
||||
else return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
|
||||
} else {
|
||||
return sprintf("%.1f", round($s / 1024 / 1024 / 1024, 1)) . "G";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,9 +148,11 @@ function pg2mysql_large($infilename, $outfilename)
|
||||
$c = substr_count($instr, "'");
|
||||
// we have an odd number of ' marks
|
||||
if ($c % 2 != 0) {
|
||||
if ($inquotes)
|
||||
if ($inquotes) {
|
||||
$inquotes = false;
|
||||
else $inquotes = true;
|
||||
} else {
|
||||
$inquotes = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($linenum % 10000 == 0) {
|
||||
@ -323,9 +332,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
||||
$line = str_replace(" bool DEFAULT false", " bool DEFAULT 0", $line);
|
||||
if (preg_match("/ character varying\(([0-9]*)\)/", $line, $regs)) {
|
||||
$num = $regs[1];
|
||||
if ($num <= 255)
|
||||
if ($num <= 255) {
|
||||
$line = preg_replace("/ character varying\([0-9]*\)/", " varchar($num)", $line);
|
||||
else $line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
|
||||
} else {
|
||||
$line = preg_replace("/ character varying\([0-9]*\)/", " text", $line);
|
||||
}
|
||||
}
|
||||
// character varying with no size, we will default to varchar(255)
|
||||
if (preg_match("/ character varying/", $line)) {
|
||||
@ -345,9 +356,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
||||
$line = preg_replace("/::.*$/", "\n", $line);
|
||||
if (preg_match("/character\(([0-9]*)\)/", $line, $regs)) {
|
||||
$num = $regs[1];
|
||||
if ($num <= 255)
|
||||
if ($num <= 255) {
|
||||
$line = preg_replace("/ character\([0-9]*\)/", " varchar($num)", $line);
|
||||
else $line = preg_replace("/ character\([0-9]*\)/", " text", $line);
|
||||
} else {
|
||||
$line = preg_replace("/ character\([0-9]*\)/", " text", $line);
|
||||
}
|
||||
}
|
||||
// timestamps
|
||||
$line = str_replace(" timestamp with time zone", " datetime", $line);
|
||||
@ -457,9 +470,11 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
||||
$c = substr_count($line, "'");
|
||||
// we have an odd number of ' marks
|
||||
if ($c % 2 != 0) {
|
||||
if ($inquotes)
|
||||
if ($inquotes) {
|
||||
$inquotes = false;
|
||||
else $inquotes = true;
|
||||
} else {
|
||||
$inquotes = true;
|
||||
}
|
||||
// echo "inquotes=$inquotes\n";
|
||||
}
|
||||
} while (substr($lines[$linenumber], - 3, - 1) != ");" || $inquotes);
|
||||
@ -524,8 +539,9 @@ function pg2mysql(&$input, &$arrayofprimaryalreadyintabledef, $header = true)
|
||||
}
|
||||
}
|
||||
|
||||
if (substr($line, 0, 13) == 'DROP DATABASE')
|
||||
if (substr($line, 0, 13) == 'DROP DATABASE') {
|
||||
$output .= $line;
|
||||
}
|
||||
|
||||
if (substr($line, 0, 15) == 'CREATE DATABASE') {
|
||||
$matches = array();
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
use Dolibarr\Aaa as Aaa;
|
||||
use function Dolibarr\faaa as faaa; // Need php 5.6+
|
||||
|
||||
//use const Dolibarr\AAA;
|
||||
|
||||
//use Bbb as Bbb;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*spl_autoload_register(function ($class_name) {
|
||||
var_dump('class='.$class_name);
|
||||
require $class_name;
|
||||
var_dump('class='.$class_name);
|
||||
require $class_name;
|
||||
});
|
||||
*/
|
||||
|
||||
@ -3,10 +3,11 @@
|
||||
$a = microtime(true);
|
||||
|
||||
$i = 0;
|
||||
while ($i < 1000000)
|
||||
{
|
||||
while ($i < 1000000) {
|
||||
$key = '1234567890111213141516171819'.$i;
|
||||
if ($i == 1000) $key = 'MAIN_MODULE_AAAAAiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
|
||||
if ($i == 1000) {
|
||||
$key = 'MAIN_MODULE_AAAAAiiiiiiiiiiiiiiiiiiiiiiiiiiiii';
|
||||
}
|
||||
|
||||
//if (preg_match('/^MAIN_MODULE_/', $key)) {
|
||||
//if (substr($key, 0, 12) == 'MAIN_MODULE_') {
|
||||
|
||||
@ -38,25 +38,25 @@ $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',
|
||||
|
||||
/*
|
||||
The permission array is composed of values taken from the following ones (specify the ones you want to block):
|
||||
- print : Print the document;
|
||||
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
|
||||
- copy : Copy or otherwise extract text and graphics from the document;
|
||||
- annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
|
||||
- fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
|
||||
- extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
|
||||
- assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
|
||||
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
|
||||
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
|
||||
- print : Print the document;
|
||||
- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
|
||||
- copy : Copy or otherwise extract text and graphics from the document;
|
||||
- annot-forms : Add or modify text annotations, fill in interactive form fields, and, if 'modify' is also set, create or modify interactive form fields (including signature fields);
|
||||
- fill-forms : Fill in existing interactive form fields (including signature fields), even if 'annot-forms' is not specified;
|
||||
- extract : Extract text and graphics (in support of accessibility to users with disabilities or for other purposes);
|
||||
- assemble : Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if 'modify' is not set;
|
||||
- print-high : Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set, printing is limited to a low-level representation of the appearance, possibly of degraded quality.
|
||||
- owner : (inverted logic - only for public-key) when set permits change of encryption and enables all other permissions.
|
||||
|
||||
If you don't set any password, the document will open as usual.
|
||||
If you set a user password, the PDF viewer will ask for it before displaying the document.
|
||||
The master (owner) password, if different from the user one, can be used to get full document access.
|
||||
|
||||
Possible encryption modes are:
|
||||
0 = RSA 40 bit
|
||||
1 = RSA 128 bit
|
||||
2 = AES 128 bit
|
||||
3 = AES 256 bit
|
||||
0 = RSA 40 bit
|
||||
1 = RSA 128 bit
|
||||
2 = AES 128 bit
|
||||
3 = AES 256 bit
|
||||
|
||||
NOTES:
|
||||
- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
|
||||
@ -89,8 +89,8 @@ $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
||||
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 016', PDF_HEADER_STRING);
|
||||
|
||||
// set header and footer fonts
|
||||
$pdf->setHeaderFont(Array('helvetica', '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(Array('helvetica', '', PDF_FONT_SIZE_DATA));
|
||||
$pdf->setHeaderFont(array('helvetica', '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(array('helvetica', '', PDF_FONT_SIZE_DATA));
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
|
||||
@ -64,8 +64,8 @@ $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
||||
$pdf->SetHeaderData('', PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 038', PDF_HEADER_STRING);
|
||||
|
||||
// set header and footer fonts
|
||||
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
|
||||
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
|
||||
|
||||
// set default monospaced font
|
||||
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
||||
|
||||
@ -40,18 +40,18 @@ class autoTranslator
|
||||
const DIR_SEPARATOR = '/';
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $_destlang Destination lang
|
||||
* @param string $_refLang Ref lang
|
||||
* @param string $_langDir Dir lang
|
||||
* @param string $_limittofile Limit to file
|
||||
* @param string $_apikey Api key
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey)
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $_destlang Destination lang
|
||||
* @param string $_refLang Ref lang
|
||||
* @param string $_langDir Dir lang
|
||||
* @param string $_limittofile Limit to file
|
||||
* @param string $_apikey Api key
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey)
|
||||
{
|
||||
|
||||
// Set enviorment variables
|
||||
$this->_destlang = $_destlang;
|
||||
@ -59,7 +59,7 @@ class autoTranslator
|
||||
$this->_langDir = $_langDir.self::DIR_SEPARATOR;
|
||||
$this->_time = date('Y-m-d H:i:s');
|
||||
$this->_limittofile = $_limittofile;
|
||||
$this->_apikey = $_apikey;
|
||||
$this->_apikey = $_apikey;
|
||||
|
||||
// Translate
|
||||
//ini_set('default_charset','UTF-8');
|
||||
@ -77,9 +77,10 @@ class autoTranslator
|
||||
|
||||
$files = $this->getTranslationFilesArray($this->_refLang);
|
||||
$counter = 1;
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if ($this->_limittofile && $this->_limittofile != $file) continue;
|
||||
foreach ($files as $file) {
|
||||
if ($this->_limittofile && $this->_limittofile != $file) {
|
||||
continue;
|
||||
}
|
||||
$counter++;
|
||||
$fileContent = null;
|
||||
$refPath = $this->_langDir.$this->_refLang.self::DIR_SEPARATOR.$file;
|
||||
@ -88,54 +89,66 @@ class autoTranslator
|
||||
|
||||
// Define target dirs
|
||||
$targetlangs=array($this->_destlang);
|
||||
if ($this->_destlang == 'all')
|
||||
{
|
||||
if ($this->_destlang == 'all') {
|
||||
$targetlangs=array();
|
||||
|
||||
// If we must process all languages
|
||||
$arraytmp=dol_dir_list($this->_langDir, 'directories', 0);
|
||||
foreach ($arraytmp as $dirtmp)
|
||||
{
|
||||
if ($dirtmp['name'] === $this->_refLang) continue; // We discard source language
|
||||
foreach ($arraytmp as $dirtmp) {
|
||||
if ($dirtmp['name'] === $this->_refLang) {
|
||||
continue; // We discard source language
|
||||
}
|
||||
$tmppart=explode('_', $dirtmp['name']);
|
||||
if (preg_match('/^en/i', $dirtmp['name'])) continue; // We discard en_* languages
|
||||
if (preg_match('/^fr/i', $dirtmp['name'])) continue; // We discard fr_* languages
|
||||
if (preg_match('/^es/i', $dirtmp['name'])) continue; // We discard es_* languages
|
||||
if (preg_match('/ca_ES/i', $dirtmp['name'])) continue; // We discard es_CA language
|
||||
if (preg_match('/pt_BR/i', $dirtmp['name'])) continue; // We discard pt_BR language
|
||||
if (preg_match('/nl_BE/i', $dirtmp['name'])) continue; // We discard nl_BE language
|
||||
if (preg_match('/^\./i', $dirtmp['name'])) continue; // We discard files .*
|
||||
if (preg_match('/^CVS/i', $dirtmp['name'])) continue; // We discard CVS
|
||||
if (preg_match('/^en/i', $dirtmp['name'])) {
|
||||
continue; // We discard en_* languages
|
||||
}
|
||||
if (preg_match('/^fr/i', $dirtmp['name'])) {
|
||||
continue; // We discard fr_* languages
|
||||
}
|
||||
if (preg_match('/^es/i', $dirtmp['name'])) {
|
||||
continue; // We discard es_* languages
|
||||
}
|
||||
if (preg_match('/ca_ES/i', $dirtmp['name'])) {
|
||||
continue; // We discard es_CA language
|
||||
}
|
||||
if (preg_match('/pt_BR/i', $dirtmp['name'])) {
|
||||
continue; // We discard pt_BR language
|
||||
}
|
||||
if (preg_match('/nl_BE/i', $dirtmp['name'])) {
|
||||
continue; // We discard nl_BE language
|
||||
}
|
||||
if (preg_match('/^\./i', $dirtmp['name'])) {
|
||||
continue; // We discard files .*
|
||||
}
|
||||
if (preg_match('/^CVS/i', $dirtmp['name'])) {
|
||||
continue; // We discard CVS
|
||||
}
|
||||
$targetlangs[]=$dirtmp['name'];
|
||||
}
|
||||
//var_dump($targetlangs);
|
||||
}
|
||||
|
||||
// Process translation of source file for each target languages
|
||||
foreach ($targetlangs as $my_destlang)
|
||||
{
|
||||
foreach ($targetlangs as $my_destlang) {
|
||||
$this->_translatedFiles = array();
|
||||
|
||||
$destPath = $this->_langDir.$my_destlang.self::DIR_SEPARATOR.$file;
|
||||
// Check destination file presence
|
||||
if (! file_exists($destPath))
|
||||
{
|
||||
if (! file_exists($destPath)) {
|
||||
// No file present, we generate file
|
||||
echo "File not found: " . $destPath . ". We generate it.<br>\n";
|
||||
$this->createTranslationFile($destPath, $my_destlang);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo "Updating file: " . $destPath . "<br>\n";
|
||||
}
|
||||
|
||||
// Translate lines
|
||||
$fileContentDest = file($destPath, FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$newlines=0;
|
||||
foreach ($fileContent as $line){
|
||||
foreach ($fileContent as $line) {
|
||||
$key = $this->getLineKey($line);
|
||||
$value = $this->getLineValue($line);
|
||||
if ($key && $value)
|
||||
{
|
||||
if ($key && $value) {
|
||||
$newlines+=$this->translateFileLine($fileContentDest, $file, $key, $value, $my_destlang);
|
||||
}
|
||||
}
|
||||
@ -159,8 +172,7 @@ class autoTranslator
|
||||
{
|
||||
$this->_time_end = date('Y-m-d H:i:s');
|
||||
|
||||
if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0)
|
||||
{
|
||||
if (isset($this->_translatedFiles[$file]) && count($this->_translatedFiles[$file])>0) {
|
||||
$fp = fopen($destPath, 'a');
|
||||
fwrite($fp, "\n");
|
||||
fwrite($fp, "\n");
|
||||
@ -213,27 +225,31 @@ class autoTranslator
|
||||
$destValue = $this->getLineValue($line);
|
||||
// If translated return
|
||||
//print "destKey=".$destKey."\n";
|
||||
if ( trim($destKey) == trim($key) )
|
||||
{ // Found already existing translation (key already exits in dest file)
|
||||
if (trim($destKey) == trim($key)) { // Found already existing translation (key already exits in dest file)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($key == 'CHARSET') {
|
||||
$val=$this->_outputpagecode;
|
||||
} elseif (preg_match('/^Format/', $key)) {
|
||||
$val=$value;
|
||||
} elseif ($value=='-') {
|
||||
$val=$value;
|
||||
} else {
|
||||
$val=$this->_outputpagecode;
|
||||
} elseif (preg_match('/^Format/', $key)) {
|
||||
$val=$value;
|
||||
} elseif ($value=='-') {
|
||||
$val=$value;
|
||||
} else {
|
||||
// If not translated then translate
|
||||
if ($this->_outputpagecode == 'UTF-8') $val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
|
||||
else $val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
|
||||
if ($this->_outputpagecode == 'UTF-8') {
|
||||
$val=$this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2));
|
||||
} else {
|
||||
$val=utf8_decode($this->translateTexts(array($value), substr($this->_refLang, 0, 2), substr($my_destlang, 0, 2)));
|
||||
}
|
||||
}
|
||||
|
||||
$val=trim($val);
|
||||
|
||||
if (empty($val)) return 0;
|
||||
if (empty($val)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->_translatedFiles[$file][] = $key . '=' . $val ;
|
||||
return 1;
|
||||
@ -293,9 +309,13 @@ class autoTranslator
|
||||
{
|
||||
// We want to be sure that src_lang and dest_lang are using 2 chars only
|
||||
$tmp=explode('_', $src_lang);
|
||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) $src_lang=$tmp[0];
|
||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) {
|
||||
$src_lang=$tmp[0];
|
||||
}
|
||||
$tmp=explode('_', $dest_lang);
|
||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) $dest_lang=$tmp[0];
|
||||
if (! empty($tmp[1]) && $tmp[0] == $tmp[1]) {
|
||||
$dest_lang=$tmp[0];
|
||||
}
|
||||
|
||||
//setting language pair
|
||||
$lang_pair = $src_lang.'|'.$dest_lang;
|
||||
@ -306,17 +326,16 @@ class autoTranslator
|
||||
// Define GET URL v1
|
||||
//$url = "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=".urlencode($src_text_to_translate)."&langpair=".urlencode($lang_pair);
|
||||
// Example: http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=Setup%20area&langpair=en_US|fr_FR
|
||||
// Define GET URL v2
|
||||
// Define GET URL v2
|
||||
$url = "https://www.googleapis.com/language/translate/v2?key=".$this->_apikey."&q=".urlencode($src_text_to_translate)."&source=".urlencode($src_lang)."&target=".urlencode($dest_lang);
|
||||
// Example: https://www.googleapis.com/language/translate/v2?key=_apikey&q=Setup%20area&source=en_US&target=fr_FR
|
||||
|
||||
// Send request
|
||||
//print "Url to translate: ".$url."\n";
|
||||
|
||||
if (! function_exists("curl_init"))
|
||||
{
|
||||
print "Error, your PHP does not support curl functions.\n";
|
||||
die();
|
||||
if (! function_exists("curl_init")) {
|
||||
print "Error, your PHP does not support curl functions.\n";
|
||||
die();
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
@ -331,9 +350,8 @@ class autoTranslator
|
||||
$json = json_decode($body, true);
|
||||
|
||||
if ((! empty($json['responseStatus']) && $json['responseStatus'] != 200)
|
||||
|| count($json['data']['translations']) == 0)
|
||||
{
|
||||
print "Error: ".$json['responseStatus']." ".$url."\n";
|
||||
|| count($json['data']['translations']) == 0) {
|
||||
print "Error: ".$json['responseStatus']." ".$url."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -345,5 +363,5 @@ class autoTranslator
|
||||
//print "OK ".join('',$src_texts).' => '.$rep."\n";
|
||||
|
||||
return $rep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,8 +32,8 @@ $path=dirname(__FILE__).'/';
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Include Dolibarr environment
|
||||
@ -56,10 +56,10 @@ $dir=DOL_DOCUMENT_ROOT."/langs";
|
||||
|
||||
// Check parameters
|
||||
if (! isset($argv[3])) {
|
||||
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
|
||||
print "Example: ".$script_file." en_US pt_PT 123456\n";
|
||||
print "Rem: lang_code to use can be found on https://translate.google.com\n";
|
||||
exit;
|
||||
print "Usage: ".$script_file." lang_code_src lang_code_dest|all APIKEY [langfile.lang]\n";
|
||||
print "Example: ".$script_file." en_US pt_PT 123456\n";
|
||||
print "Rem: lang_code to use can be found on https://translate.google.com\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Show parameters
|
||||
@ -67,21 +67,17 @@ print 'Argument 1='.$argv[1]."\n";
|
||||
print 'Argument 2='.$argv[2]."\n";
|
||||
print 'Argument 3='.$argv[3]."\n";
|
||||
$file='';
|
||||
if (isset($argv[4]))
|
||||
{
|
||||
if (isset($argv[4])) {
|
||||
$file=$argv[4];
|
||||
print 'Argument 4='.$argv[4]."\n";
|
||||
}
|
||||
print 'Files will be generated/updated in directory '.$dir."\n";
|
||||
|
||||
if ($argv[2] != 'all')
|
||||
{
|
||||
if (! is_dir($dir.'/'.$argv[2]))
|
||||
{
|
||||
if ($argv[2] != 'all') {
|
||||
if (! is_dir($dir.'/'.$argv[2])) {
|
||||
print 'Create directory '.$dir.'/'.$argv[2]."\n";
|
||||
$result=mkdir($dir.'/'.$argv[2]);
|
||||
if (! $result)
|
||||
{
|
||||
if (! $result) {
|
||||
$db->close();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -25,18 +25,16 @@ $path=dirname(__FILE__).'/';
|
||||
$web=0;
|
||||
|
||||
// Test if batch mode
|
||||
if (substr($sapi_type, 0, 3) == 'cgi')
|
||||
{
|
||||
$web=1;
|
||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||
$web=1;
|
||||
}
|
||||
|
||||
|
||||
if ($web)
|
||||
{
|
||||
echo "<html>";
|
||||
echo "<head>";
|
||||
if ($web) {
|
||||
echo "<html>";
|
||||
echo "<head>";
|
||||
|
||||
echo "<STYLE type=\"text/css\">
|
||||
echo "<STYLE type=\"text/css\">
|
||||
|
||||
table {
|
||||
background: #f5f5f5;
|
||||
@ -83,13 +81,17 @@ if ($web)
|
||||
|
||||
</STYLE>";
|
||||
|
||||
echo "<body>";
|
||||
echo "<body>";
|
||||
}
|
||||
|
||||
echo "If you call this with argument \"unused=true\" it searches for the translation strings that exist in en_US but are never used.\n";
|
||||
if ($web) print "<br>";
|
||||
if ($web) {
|
||||
print "<br>";
|
||||
}
|
||||
echo "IMPORTANT: that can take quite a lot of time (up to 10 minutes), you need to tune the max_execution_time on your php.ini accordingly.\n";
|
||||
if ($web) print "<br>";
|
||||
if ($web) {
|
||||
print "<br>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -105,8 +107,7 @@ $workdir = $htdocs."langs/en_US/";
|
||||
|
||||
|
||||
$files = scandir($workdir);
|
||||
if (empty($files))
|
||||
{
|
||||
if (empty($files)) {
|
||||
echo "Can't scan workdir = ".$workdir;
|
||||
exit;
|
||||
}
|
||||
@ -115,18 +116,17 @@ $dups=array();
|
||||
$exludefiles = array('.','..','README');
|
||||
$files = array_diff($files, $exludefiles);
|
||||
// To force a file: $files=array('myfile.lang');
|
||||
if (isset($argv[2]))
|
||||
{
|
||||
$files = array($argv[2]);
|
||||
if (isset($argv[2])) {
|
||||
$files = array($argv[2]);
|
||||
}
|
||||
$langstrings_3d = array();
|
||||
$langstrings_full = array();
|
||||
foreach ($files AS $file) {
|
||||
foreach ($files as $file) {
|
||||
$path_file = pathinfo($file);
|
||||
// we're only interested in .lang files
|
||||
if ($path_file['extension']=='lang') {
|
||||
$content = file($workdir.$file);
|
||||
foreach ($content AS $line => $row) {
|
||||
foreach ($content as $line => $row) {
|
||||
// don't want comment lines
|
||||
if (substr($row, 0, 1) !== '#') {
|
||||
// don't want lines without the separator (why should those even be here, anyway...)
|
||||
@ -142,29 +142,29 @@ foreach ($files AS $file) {
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($langstrings_3d AS $filename => $file)
|
||||
{
|
||||
foreach ($file AS $linenum => $value)
|
||||
{
|
||||
foreach ($langstrings_3d as $filename => $file) {
|
||||
foreach ($file as $linenum => $value) {
|
||||
$keys = array_keys($langstrings_full, $value);
|
||||
if (count($keys)>1)
|
||||
{
|
||||
foreach ($keys AS $key) {
|
||||
if (count($keys)>1) {
|
||||
foreach ($keys as $key) {
|
||||
$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($web) print "<h2>";
|
||||
if ($web) {
|
||||
print "<h2>";
|
||||
}
|
||||
print "Duplicate strings in lang files in $workdir - ".count($dups)." found\n";
|
||||
if ($web) print "</h2>";
|
||||
if ($web) {
|
||||
print "</h2>";
|
||||
}
|
||||
|
||||
if ($web)
|
||||
{
|
||||
echo '<table border_bottom="1">'."\n";
|
||||
echo "<thead><tr><th align=\"center\">#</th><th>String</th><th>File and lines</th></thead>\n";
|
||||
echo "<tbody>\n";
|
||||
if ($web) {
|
||||
echo '<table border_bottom="1">'."\n";
|
||||
echo "<thead><tr><th align=\"center\">#</th><th>String</th><th>File and lines</th></thead>\n";
|
||||
echo "<tbody>\n";
|
||||
}
|
||||
|
||||
$sduplicateinsamefile='';
|
||||
@ -173,216 +173,419 @@ $sininstallandadmin='';
|
||||
$sother='';
|
||||
|
||||
$count = 0;
|
||||
foreach ($dups as $string => $pages)
|
||||
{
|
||||
foreach ($dups as $string => $pages) {
|
||||
$count++;
|
||||
$s='';
|
||||
|
||||
// Keyword $string
|
||||
if ($web) $s.="<tr>";
|
||||
if ($web) $s.="<td align=\"center\">";
|
||||
if ($web) $s.=$count;
|
||||
if ($web) $s.="</td>";
|
||||
if ($web) $s.="<td>";
|
||||
if ($web) {
|
||||
$s.="<tr>";
|
||||
}
|
||||
if ($web) {
|
||||
$s.="<td align=\"center\">";
|
||||
}
|
||||
if ($web) {
|
||||
$s.=$count;
|
||||
}
|
||||
if ($web) {
|
||||
$s.="</td>";
|
||||
}
|
||||
if ($web) {
|
||||
$s.="<td>";
|
||||
}
|
||||
$s.=$string;
|
||||
if ($web) $s.="</td>";
|
||||
if ($web) $s.="<td>";
|
||||
if (! $web) $s.= ' : ';
|
||||
if ($web) {
|
||||
$s.="</td>";
|
||||
}
|
||||
if ($web) {
|
||||
$s.="<td>";
|
||||
}
|
||||
if (! $web) {
|
||||
$s.= ' : ';
|
||||
}
|
||||
|
||||
// Loop on each files keyword was found
|
||||
$duplicateinsamefile=0;
|
||||
$duplicateinsamefile=0;
|
||||
$inmain=0;
|
||||
$inadmin=0;
|
||||
foreach ($pages AS $file => $lines)
|
||||
{
|
||||
if ($file == 'main.lang') { $inmain=1; $inadmin=0; }
|
||||
if ($file == 'admin.lang' && ! $inmain) { $inadmin=1; }
|
||||
$inadmin=0;
|
||||
foreach ($pages as $file => $lines) {
|
||||
if ($file == 'main.lang') {
|
||||
$inmain=1; $inadmin=0;
|
||||
}
|
||||
if ($file == 'admin.lang' && ! $inmain) {
|
||||
$inadmin=1;
|
||||
}
|
||||
|
||||
$s.=$file." ";
|
||||
$s.=$file." ";
|
||||
|
||||
// Loop on each line keword was found into file.
|
||||
$listoffilesforthisentry=array();
|
||||
foreach ($lines as $line => $translatedvalue)
|
||||
{
|
||||
if (! empty($listoffilesforthisentry[$file])) $duplicateinsamefile=1;
|
||||
$listoffilesforthisentry[$file]=1;
|
||||
// Loop on each line keword was found into file.
|
||||
$listoffilesforthisentry=array();
|
||||
foreach ($lines as $line => $translatedvalue) {
|
||||
if (! empty($listoffilesforthisentry[$file])) {
|
||||
$duplicateinsamefile=1;
|
||||
}
|
||||
$listoffilesforthisentry[$file]=1;
|
||||
|
||||
$s.= "(".$line." - ".htmlentities($translatedvalue).") ";
|
||||
}
|
||||
if ($web) $s.="<br>";
|
||||
if ($web) {
|
||||
$s.="<br>";
|
||||
}
|
||||
}
|
||||
if ($web) {
|
||||
$s.="</td></tr>";
|
||||
}
|
||||
if ($web) $s.="</td></tr>";
|
||||
$s.="\n";
|
||||
|
||||
if ($duplicateinsamefile) $sduplicateinsamefile .= $s;
|
||||
elseif ($inmain) $sinmainandother .= $s;
|
||||
elseif ($inadmin) $sininstallandadmin .= $s;
|
||||
else $sother .= $s;
|
||||
if ($duplicateinsamefile) {
|
||||
$sduplicateinsamefile .= $s;
|
||||
} elseif ($inmain) {
|
||||
$sinmainandother .= $s;
|
||||
} elseif ($inadmin) {
|
||||
$sininstallandadmin .= $s;
|
||||
} else {
|
||||
$sother .= $s;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $web) print "\n***** Entries duplicated in same file\n";
|
||||
if (! $web) {
|
||||
print "\n***** Entries duplicated in same file\n";
|
||||
}
|
||||
print $sduplicateinsamefile;
|
||||
if (! $web && empty($sduplicateinsamefile)) print "None\n";
|
||||
if (! $web) print "\n";
|
||||
if (! $web && empty($sduplicateinsamefile)) {
|
||||
print "None\n";
|
||||
}
|
||||
if (! $web) {
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if (! $web) print "***** Entries in main and another (keep only entry in main)\n";
|
||||
if (! $web) {
|
||||
print "***** Entries in main and another (keep only entry in main)\n";
|
||||
}
|
||||
print $sinmainandother;
|
||||
if (! $web && empty($sinmainandother)) print "None\n";
|
||||
if (! $web) print "\n";
|
||||
if (! $web && empty($sinmainandother)) {
|
||||
print "None\n";
|
||||
}
|
||||
if (! $web) {
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if (! $web) print "***** Entries in admin and another\n";
|
||||
if (! $web) {
|
||||
print "***** Entries in admin and another\n";
|
||||
}
|
||||
print $sininstallandadmin;
|
||||
if (! $web && empty($sininstallandadmin)) print "None\n";
|
||||
if (! $web) print "\n";
|
||||
if (! $web && empty($sininstallandadmin)) {
|
||||
print "None\n";
|
||||
}
|
||||
if (! $web) {
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if (! $web) print "***** Other\n";
|
||||
if (! $web) {
|
||||
print "***** Other\n";
|
||||
}
|
||||
print $sother;
|
||||
if (! $web && empty($sother)) print "None\n";
|
||||
if (! $web) print "\n";
|
||||
if (! $web && empty($sother)) {
|
||||
print "None\n";
|
||||
}
|
||||
if (! $web) {
|
||||
print "\n";
|
||||
}
|
||||
|
||||
if ($web)
|
||||
{
|
||||
echo "</tbody>\n";
|
||||
echo "</table>\n";
|
||||
if ($web) {
|
||||
echo "</tbody>\n";
|
||||
echo "</table>\n";
|
||||
}
|
||||
|
||||
|
||||
// STEP 2 - Search key not used
|
||||
|
||||
if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true'))
|
||||
{
|
||||
print "***** Strings in en_US that are never used:\n";
|
||||
if ((! empty($_REQUEST['unused']) && $_REQUEST['unused'] == 'true') || (isset($argv[1]) && $argv[1]=='unused=true')) {
|
||||
print "***** Strings in en_US that are never used:\n";
|
||||
|
||||
$unused=array();
|
||||
foreach ($langstrings_dist AS $value => $line)
|
||||
{
|
||||
$qualifiedforclean=1;
|
||||
// Check if we must keep this key to be into file for removal
|
||||
if (preg_match('/^Module\d+/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Permission\d+/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^PermissionAdvanced\d+/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ProfId\d+/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Delays_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^BarcodeDesc/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Extrafield/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^LocalTax/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Country/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Civility/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Currency/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^DemandReasonTypeSRC/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^PaperFormat/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^AmountLT/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^TotalLT/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Month/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^MonthShort/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Day\d/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Short/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ExportDataset_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ImportDataset_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ActionAC_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^TypeLocaltax/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^StatusProspect/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^PL_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^TE_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^JuridicalStatus/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^CalcMode/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^newLT/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^LT[0-9]/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^TypeContact_contrat_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ErrorPriceExpression/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^Language_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^DescADHERENT_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^SubmitTranslation/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ModuleCompanyCode/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/InDolibarr$/', $value)) $qualifiedforclean=0;
|
||||
// admin.lang
|
||||
if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) $qualifiedforclean=0;
|
||||
// boxes.lang
|
||||
if (preg_match('/^BoxTitleLast/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^BoxTitleLatest/', $value)) $qualifiedforclean=0;
|
||||
// install.lang
|
||||
if (preg_match('/^KeepDefaultValues/', $value)) $qualifiedforclean=0;
|
||||
$unused=array();
|
||||
foreach ($langstrings_dist as $value => $line) {
|
||||
$qualifiedforclean=1;
|
||||
// Check if we must keep this key to be into file for removal
|
||||
if (preg_match('/^Module\d+/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Permission\d+/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^PermissionAdvanced\d+/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ProfId\d+/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Delays_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^BarcodeDesc/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Extrafield/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^LocalTax/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Country/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Civility/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Currency/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^DemandReasonTypeSRC/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^PaperFormat/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Duration/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^AmountLT/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^TotalLT/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Month/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^MonthShort/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Day\d/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Short/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ExportDataset_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ImportDataset_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ActionAC_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^TypeLocaltax/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^StatusProspect/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^PL_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^TE_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^JuridicalStatus/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^CalcMode/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^newLT/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^LT[0-9]/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^TypeContact_contrat_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ErrorPriceExpression/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^Language_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^DescADHERENT_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^SubmitTranslation/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^ModuleCompanyCode/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/InDolibarr$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// admin.lang
|
||||
if (preg_match('/^DAV_ALLOW_PUBLIC_DIR/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^DAV_ALLOW_ECM_DIR/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// boxes.lang
|
||||
if (preg_match('/^BoxTitleLast/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^BoxTitleLatest/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// install.lang
|
||||
if (preg_match('/^KeepDefaultValues/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// mail.lang
|
||||
if (preg_match('/MailingModuleDesc/i', $value)) $qualifiedforclean=0;
|
||||
// main.lang
|
||||
if (preg_match('/^Duration/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^FormatDate/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^DateFormat/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^.b$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^.*Bytes$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/MailingModuleDesc/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// main.lang
|
||||
if (preg_match('/^Duration/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^FormatDate/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^DateFormat/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^.b$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^.*Bytes$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^NoteSomeFeaturesAreDisabled/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^(DoTest|Under|Limits|Cards|CurrentValue|DateLimit|DateAndHour|NbOfLines|NbOfObjects|NbOfReferes|TotalTTCShort|VATs)/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// modulebuilder
|
||||
if (preg_match('/^ModuleBuilderDesc/', $value)) $qualifiedforclean=0;
|
||||
// orders
|
||||
if (preg_match('/^OrderSource/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^TypeContact_/', $value)) $qualifiedforclean=0;
|
||||
// other.lang
|
||||
if (preg_match('/^Notify_/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^PredefinedMail/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^DemoCompany/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^WeightUnit/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^LengthUnit/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^SurfaceUnit/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^VolumeUnit/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^SizeUnit/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^EMailText/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/ById$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/ByLogin$/', $value)) $qualifiedforclean=0;
|
||||
// printing
|
||||
if (preg_match('/PrintingDriverDesc$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/PrintTestDesc$/', $value)) $qualifiedforclean=0;
|
||||
// products
|
||||
if (preg_match('/GlobalVariableUpdaterType$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/OppStatus/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/AvailabilityType/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/CardProduct/', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/^ModuleBuilderDesc/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// orders
|
||||
if (preg_match('/^OrderSource/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^TypeContact_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// other.lang
|
||||
if (preg_match('/^Notify_/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^PredefinedMail/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^DemoCompany/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^WeightUnit/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^LengthUnit/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^SurfaceUnit/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^VolumeUnit/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^SizeUnit/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/^EMailText/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/ById$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/ByLogin$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// printing
|
||||
if (preg_match('/PrintingDriverDesc$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/PrintTestDesc$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
// products
|
||||
if (preg_match('/GlobalVariableUpdaterType$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/GlobalVariableUpdaterHelp$/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/OppStatus/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/AvailabilityType/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/CardProduct/', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
|
||||
if (preg_match('/sms/i', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/TF_/i', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/WithBankUsing/i', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/descWORKFLOW_/i', $value)) $qualifiedforclean=0;
|
||||
if (preg_match('/sms/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/TF_/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/WithBankUsing/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
if (preg_match('/descWORKFLOW_/i', $value)) {
|
||||
$qualifiedforclean=0;
|
||||
}
|
||||
|
||||
if (! $qualifiedforclean)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (! $qualifiedforclean) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//$search = '\'trans("'.$value.'")\'';
|
||||
$search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
|
||||
//$search = '\'trans("'.$value.'")\'';
|
||||
$search = '-e "\''.$value.'\'" -e \'"'.$value.'"\' -e "('.$value.')" -e "('.$value.',"';
|
||||
$string = 'grep -R -m 1 -F --exclude=includes/* --include=*.php '.$search.' '.$htdocs.'* '.$scripts.'*';
|
||||
//print $string."<br>\n";
|
||||
exec($string, $output);
|
||||
if (empty($output)) {
|
||||
$unused[$value] = $line;
|
||||
echo $line; // $trad contains the \n
|
||||
}
|
||||
else {
|
||||
unset($output);
|
||||
//print 'X'.$output.'Y';
|
||||
$unused[$value] = $line;
|
||||
echo $line; // $trad contains the \n
|
||||
} else {
|
||||
unset($output);
|
||||
//print 'X'.$output.'Y';
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($unused)) print "No string not used found.\n";
|
||||
else {
|
||||
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
|
||||
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
|
||||
file_put_contents($filetosave, implode("", $unused));
|
||||
print "To remove from original file, run command :\n";
|
||||
if (($argv[2]?$argv[2]:"")) print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
|
||||
print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:"");
|
||||
if (($argv[2]?$argv[2]:"")) print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
|
||||
if (empty($unused)) {
|
||||
print "No string not used found.\n";
|
||||
} else {
|
||||
$filetosave='/tmp/'.($argv[2]?$argv[2]:"").'notused.lang';
|
||||
print "Strings in en_US that are never used are saved into file ".$filetosave.":\n";
|
||||
file_put_contents($filetosave, implode("", $unused));
|
||||
print "To remove from original file, run command :\n";
|
||||
if (($argv[2]?$argv[2]:"")) {
|
||||
print 'cd htdocs/langs/en_US; mv '.($argv[2]?$argv[2]:"")." ".($argv[2]?$argv[2]:"").".tmp; ";
|
||||
}
|
||||
print "diff ".($argv[2]?$argv[2]:"").".tmp ".$filetosave." | grep \< | cut -b 3- > ".($argv[2]?$argv[2]:"");
|
||||
if (($argv[2]?$argv[2]:"")) {
|
||||
print "; rm ".($argv[2]?$argv[2]:"").".tmp;\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
if ($web)
|
||||
{
|
||||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
if ($web) {
|
||||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
}
|
||||
|
||||
exit;
|
||||
|
||||
@ -63,8 +63,7 @@ $lSecondary = isset($argv[2])?$argv[2]:'';
|
||||
$lEnglish = 'en_US';
|
||||
$filesToProcess = isset($argv[3])?$argv[3]:'';
|
||||
|
||||
if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess))
|
||||
{
|
||||
if (empty($lPrimary) || empty($lSecondary) || empty($filesToProcess)) {
|
||||
$rc = 1;
|
||||
$msg = '***** Script to clean language files *****'."\n";
|
||||
$msg.= 'Usage: ./dev/translation/strip_language_file.php xx_XX xx_YY [file.lang|all]'."\n";
|
||||
@ -77,8 +76,7 @@ $aSecondary = array();
|
||||
$aEnglish = array();
|
||||
|
||||
// Define array $filesToProcess
|
||||
if ($filesToProcess == 'all')
|
||||
{
|
||||
if ($filesToProcess == 'all') {
|
||||
$dir = new DirectoryIterator('htdocs/langs/'.$lPrimary);
|
||||
while ($dir->valid()) {
|
||||
if (!$dir->isDot() && $dir->isFile() && ! preg_match('/^\./', $dir->getFilename())) {
|
||||
@ -87,15 +85,15 @@ if ($filesToProcess == 'all')
|
||||
$dir->next();
|
||||
}
|
||||
$filesToProcess=$files;
|
||||
} else {
|
||||
$filesToProcess=explode(',', $filesToProcess);
|
||||
}
|
||||
else $filesToProcess=explode(',', $filesToProcess);
|
||||
|
||||
// Arguments should be OK here.
|
||||
|
||||
|
||||
// Loop on each file
|
||||
foreach ($filesToProcess as $fileToProcess)
|
||||
{
|
||||
foreach ($filesToProcess as $fileToProcess) {
|
||||
$lPrimaryFile = 'htdocs/langs/'.$lPrimary.'/'.$fileToProcess;
|
||||
$lSecondaryFile = 'htdocs/langs/'.$lSecondary.'/'.$fileToProcess;
|
||||
$lEnglishFile = 'htdocs/langs/'.$lEnglish.'/'.$fileToProcess;
|
||||
@ -103,21 +101,21 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
|
||||
print "---- Process language file ".$lSecondaryFile."\n";
|
||||
|
||||
if ( ! is_readable($lPrimaryFile) ) {
|
||||
if (! is_readable($lPrimaryFile)) {
|
||||
$rc = 2;
|
||||
$msg = "Cannot read primary language file $lPrimaryFile.";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
exit($rc);
|
||||
}
|
||||
|
||||
if ( ! is_readable($lSecondaryFile) ) {
|
||||
if (! is_readable($lSecondaryFile)) {
|
||||
$rc = 3;
|
||||
$msg = "Cannot read secondary language file $lSecondaryFile. We discard this file.";
|
||||
print $msg . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! is_readable($lEnglishFile) ) {
|
||||
if (! is_readable($lEnglishFile)) {
|
||||
$rc = 3;
|
||||
$msg = "Cannot read english language file $lEnglishFile. We discard this file.";
|
||||
print $msg . "\n";
|
||||
@ -126,25 +124,23 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
|
||||
// Start reading and parsing Secondary
|
||||
|
||||
if ( $handle = fopen($lSecondaryFile, 'r') )
|
||||
{
|
||||
if ($handle = fopen($lSecondaryFile, 'r')) {
|
||||
print "Read Secondary File $lSecondaryFile:\n";
|
||||
$cnt = 0;
|
||||
while (($line = fgets($handle)) !== false)
|
||||
{
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$cnt++;
|
||||
|
||||
// strip comments
|
||||
if ( preg_match("/^\w*#/", $line) ) {
|
||||
if (preg_match("/^\w*#/", $line)) {
|
||||
continue;
|
||||
}
|
||||
// strip empty lines
|
||||
if ( preg_match("/^\w*$/", $line) ) {
|
||||
if (preg_match("/^\w*$/", $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$a = mb_split('=', trim($line), 2);
|
||||
if ( count($a) != 2 ) {
|
||||
if (count($a) != 2) {
|
||||
print "ERROR in file $lSecondaryFile, line $cnt: " . trim($line) . "\n";
|
||||
continue;
|
||||
}
|
||||
@ -152,29 +148,27 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
list($key, $value) = $a;
|
||||
|
||||
// key is redundant
|
||||
if ( array_key_exists($key, $aSecondary) ) {
|
||||
if (array_key_exists($key, $aSecondary)) {
|
||||
print "Key $key is redundant in file $lSecondaryFile (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// String has no value
|
||||
if ( $value == '' ) {
|
||||
if ($value == '') {
|
||||
print "Key $key has no value in file $lSecondaryFile (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$aSecondary[$key] = trim($value);
|
||||
}
|
||||
if ( ! feof($handle) )
|
||||
{
|
||||
if (! feof($handle)) {
|
||||
$rc = 5;
|
||||
$msg = "Unexpected fgets() fail";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
exit($rc);
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rc = 6;
|
||||
$msg = "Cannot open file $lSecondaryFile";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
@ -184,25 +178,23 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
|
||||
// Start reading and parsing English
|
||||
|
||||
if ( $handle = fopen($lEnglishFile, 'r') )
|
||||
{
|
||||
if ($handle = fopen($lEnglishFile, 'r')) {
|
||||
print "Read English File $lEnglishFile:\n";
|
||||
$cnt = 0;
|
||||
while (($line = fgets($handle)) !== false)
|
||||
{
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$cnt++;
|
||||
|
||||
// strip comments
|
||||
if ( preg_match("/^\w*#/", $line) ) {
|
||||
if (preg_match("/^\w*#/", $line)) {
|
||||
continue;
|
||||
}
|
||||
// strip empty lines
|
||||
if ( preg_match("/^\w*$/", $line) ) {
|
||||
if (preg_match("/^\w*$/", $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$a = mb_split('=', trim($line), 2);
|
||||
if ( count($a) != 2 ) {
|
||||
if (count($a) != 2) {
|
||||
print "ERROR in file $lEnglishFile, line $cnt: " . trim($line) . "\n";
|
||||
continue;
|
||||
}
|
||||
@ -210,29 +202,27 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
list($key, $value) = $a;
|
||||
|
||||
// key is redundant
|
||||
if ( array_key_exists($key, $aEnglish) ) {
|
||||
if (array_key_exists($key, $aEnglish)) {
|
||||
print "Key $key is redundant in file $lEnglishFile (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// String has no value
|
||||
if ( $value == '' ) {
|
||||
if ($value == '') {
|
||||
print "Key $key has no value in file $lEnglishFile (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
$aEnglish[$key] = trim($value);
|
||||
}
|
||||
if ( ! feof($handle) )
|
||||
{
|
||||
if (! feof($handle)) {
|
||||
$rc = 5;
|
||||
$msg = "Unexpected fgets() fail";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
exit($rc);
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rc = 6;
|
||||
$msg = "Cannot open file $lEnglishFile";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
@ -246,10 +236,8 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
$arrayofkeytoalwayskeep=array('DIRECTION','FONTFORPDF','FONTSIZEFORPDF','SeparatorDecimal','SeparatorThousand');
|
||||
|
||||
|
||||
if ( $handle = fopen($lPrimaryFile, 'r') )
|
||||
{
|
||||
if ( ! $oh = fopen($output, 'w') )
|
||||
{
|
||||
if ($handle = fopen($lPrimaryFile, 'r')) {
|
||||
if (! $oh = fopen($output, 'w')) {
|
||||
print "ERROR in writing to file ".$output."\n";
|
||||
exit;
|
||||
}
|
||||
@ -259,21 +247,20 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
fwrite($oh, "# Dolibarr language file - Source file is en_US - ".(preg_replace('/\.lang$/', '', $fileToProcess))."\n");
|
||||
|
||||
$cnt = 0;
|
||||
while (($line = fgets($handle)) !== false)
|
||||
{
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
$cnt++;
|
||||
|
||||
// strip comments
|
||||
if ( preg_match("/^\w*#/", $line) ) {
|
||||
if (preg_match("/^\w*#/", $line)) {
|
||||
continue;
|
||||
}
|
||||
// strip empty lines
|
||||
if ( preg_match("/^\w*$/", $line) ) {
|
||||
if (preg_match("/^\w*$/", $line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$a = mb_split('=', trim($line), 2);
|
||||
if ( count($a) != 2 ) {
|
||||
if (count($a) != 2) {
|
||||
print "ERROR in file $lPrimaryFile, line $cnt: " . trim($line) . "\n";
|
||||
continue;
|
||||
}
|
||||
@ -281,17 +268,16 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
list($key, $value) = $a;
|
||||
|
||||
// key is redundant
|
||||
if ( array_key_exists($key, $aPrimary) ) {
|
||||
if (array_key_exists($key, $aPrimary)) {
|
||||
print "Key $key is redundant in file $lPrimaryFile (line: $cnt) - Already found into ".$fileFirstFound[$key]." (line: ".$lineFirstFound[$key].").\n";
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$fileFirstFound[$key] = $fileToProcess;
|
||||
$lineFirstFound[$key] = $cnt;
|
||||
}
|
||||
|
||||
// String has no value
|
||||
if ( $value == '' ) {
|
||||
if ($value == '') {
|
||||
print "Key $key has no value in file $lPrimaryFile (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
@ -305,28 +291,23 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
//print "Found primary key = ".$key."\n";
|
||||
|
||||
// Key not in other file
|
||||
if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key))
|
||||
{
|
||||
if (in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)) {
|
||||
//print "Key $key is a key we always want to see into secondary file (line: $cnt).\n";
|
||||
}
|
||||
elseif ( ! array_key_exists($key, $aSecondary))
|
||||
{
|
||||
} elseif (! array_key_exists($key, $aSecondary)) {
|
||||
//print "Key $key does NOT exist in secondary language (line: $cnt).\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
// String exists in both files and value into alternative language differs from main language but also from english files
|
||||
if (
|
||||
(! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
|
||||
&& ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
|
||||
if ((! empty($aSecondary[$key]) && $aSecondary[$key] != $aPrimary[$key]
|
||||
&& ! empty($aEnglish[$key]) && $aSecondary[$key] != $aEnglish[$key])
|
||||
|| in_array($key, $arrayofkeytoalwayskeep) || preg_match('/^FormatDate/', $key) || preg_match('/^FormatHour/', $key)
|
||||
)
|
||||
{
|
||||
) {
|
||||
//print "Key $key differs (aSecondary=".$aSecondary[$key].", aPrimary=".$aPrimary[$key].", aEnglish=".$aEnglish[$key].") so we add it into new secondary language (line: $cnt).\n";
|
||||
fwrite($oh, $key."=".(empty($aSecondary[$key])?$aPrimary[$key]:$aSecondary[$key])."\n");
|
||||
}
|
||||
}
|
||||
if ( ! feof($handle) ) {
|
||||
if (! feof($handle)) {
|
||||
$rc = 7;
|
||||
$msg = "Unexpected fgets() fail";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
@ -334,8 +315,7 @@ foreach ($filesToProcess as $fileToProcess)
|
||||
}
|
||||
fclose($oh);
|
||||
fclose($handle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$rc = 8;
|
||||
$msg = "Cannot open file $lPrimaryFile";
|
||||
print $msg . " (rc=$rc).\n";
|
||||
|
||||
BIN
doc/images/dolibarr_screenshot12_1920x1080.jpg
Normal file
BIN
doc/images/dolibarr_screenshot12_1920x1080.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 219 KiB |
@ -6,18 +6,15 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
This directory contains several subdirectories with entries for
|
||||
informations on Dolibarr.<br>
|
||||
But if you are looking for other resources (downloads, documentation, addons, ...), you can find this
|
||||
on Internet on web following sites:<br>
|
||||
<br>
|
||||
* <a href="https://wiki.dolibarr.org">Dolibarr wiki (documentation)</a><br>
|
||||
This directory contains several subdirectories with entries for informations on Dolibarr.<br>
|
||||
But if you are looking for other resources (downloads, documentation, addons, ...), you can find this on Internet on web following sites:<br>
|
||||
|
||||
<br>
|
||||
* <a href="https://www.dolibarr.org">Dolibarr portal (official website)</a><br>
|
||||
<br>
|
||||
* <a href="https://demo.dolibarr.org">Dolibarr demo (online)</a><br>
|
||||
* <a href="https://wiki.dolibarr.org">Dolibarr wiki (documentation)</a><br>
|
||||
<br>
|
||||
* <a href="https://www.nltechno.com/pages/dolibarrwinbin.php">DoliWamp, the Dolibarr for Windows</a><br>
|
||||
* <a href="https://demo.dolibarr.org">Dolibarr demo (online)</a><br>
|
||||
<br>
|
||||
* <a href="https://www.dolistore.com">DoliStore (official addons/plugins market place)</a><br>
|
||||
|
||||
|
||||
@ -6,7 +6,10 @@ Benutzeranleitung
|
||||
--------------------------------
|
||||
|
||||
Alle Dolibarr-Informationen sind online verfuegbar ueber die Webseiten:
|
||||
https://www.dolibarr.de
|
||||
oder
|
||||
https://www.dolibarr.org
|
||||
https://wiki.dolibarr.org
|
||||
|
||||
|
||||
https://www.dolibarr.de (de) oder https://www.dolibarr.org (intl)
|
||||
|
||||
|
||||
https://wiki.dolibarr.org/index.php/Hauptseite (de)
|
||||
|
||||
|
||||
@ -45,24 +45,40 @@ $search_label = GETPOST('search_label', 'alpha');
|
||||
$search_labelshort = GETPOST('search_labelshort', 'alpha');
|
||||
$search_accountparent = GETPOST('search_accountparent', 'alpha');
|
||||
$search_pcgtype = GETPOST('search_pcgtype', 'alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
$chartofaccounts = GETPOST('chartofaccounts', 'int');
|
||||
|
||||
$permissiontoadd = $user->rights->accounting->chartofaccount;
|
||||
$permissiontodelete = $user->rights->accounting->chartofaccount;
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if (!$user->rights->accounting->chartofaccount) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->chartofaccount) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "aa.account_number";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "aa.account_number";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
$arrayfields = array(
|
||||
'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
|
||||
@ -74,31 +90,45 @@ $arrayfields = array(
|
||||
'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
|
||||
);
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
unset($arrayfields['aa.reconcilable']);
|
||||
}
|
||||
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha')) {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been monowraponalldified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (!empty($cancel)) $action = '';
|
||||
if (empty($reshook)) {
|
||||
if (!empty($cancel)) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
$objectclass = 'AccountingAccount';
|
||||
$uploaddir = $conf->accounting->multidir_output[$conf->entity];
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
if ($action == "delete") {
|
||||
$action = "";
|
||||
}
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
|
||||
$search_account = "";
|
||||
$search_label = "";
|
||||
$search_labelshort = "";
|
||||
@ -107,23 +137,21 @@ if (empty($reshook))
|
||||
$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)
|
||||
{
|
||||
|| (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 && $permissiontoadd) {
|
||||
// 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;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
$country_code = $obj->code;
|
||||
} else dol_print_error($db);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// Try to load sql file
|
||||
if ($country_code)
|
||||
{
|
||||
if ($country_code) {
|
||||
$sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
|
||||
|
||||
$offsetforchartofaccount = 0;
|
||||
@ -131,16 +159,15 @@ if (empty($reshook))
|
||||
// and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value.
|
||||
// This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used.
|
||||
$tmp = file_get_contents($sqlfile);
|
||||
if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg))
|
||||
{
|
||||
$reg = array();
|
||||
if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) {
|
||||
$offsetforchartofaccount += $reg[1];
|
||||
}
|
||||
$offsetforchartofaccount += ($conf->entity * 100000000);
|
||||
|
||||
$result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
if ($result > 0) {
|
||||
setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
|
||||
@ -155,7 +182,7 @@ if (empty($reshook))
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'disable') {
|
||||
if ($action == 'disable' && $permissiontoadd) {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->accountDeactivate($id, $mode);
|
||||
@ -165,7 +192,7 @@ if (empty($reshook))
|
||||
if ($result < 0) {
|
||||
setEventMessages($accounting->error, $accounting->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'enable') {
|
||||
} elseif ($action == 'enable' && $permissiontoadd) {
|
||||
if ($accounting->fetch($id)) {
|
||||
$mode = GETPOST('mode', 'int');
|
||||
$result = $accounting->account_activate($id, $mode);
|
||||
@ -198,9 +225,12 @@ $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.a
|
||||
$sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
|
||||
if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
|
||||
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
|
||||
$sql .= " WHERE asy.rowid = ".$pcgver;
|
||||
if ($db->type == 'pgsql') {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
|
||||
} else {
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
|
||||
}
|
||||
$sql .= " WHERE asy.rowid = ".((int) $pcgver);
|
||||
//print $sql;
|
||||
if (strlen(trim($search_account))) {
|
||||
$lengthpaddingaccount = 0;
|
||||
@ -224,57 +254,89 @@ if (strlen(trim($search_account))) {
|
||||
$search_account_tmp_clean = $search_account_tmp;
|
||||
$search_account_clean = $search_account;
|
||||
$startchar = '%';
|
||||
if (strpos($search_account_tmp, '^') === 0)
|
||||
{
|
||||
if (strpos($search_account_tmp, '^') === 0) {
|
||||
$startchar = '';
|
||||
$search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp);
|
||||
$search_account_clean = preg_replace('/^\^/', '', $search_account);
|
||||
}
|
||||
$sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'";
|
||||
$sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')";
|
||||
} else $sql .= natural_search("aa.account_number", $search_account_tmp);
|
||||
} else {
|
||||
$sql .= natural_search("aa.account_number", $search_account_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
|
||||
if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort);
|
||||
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2);
|
||||
if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype);
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("aa.label", $search_label);
|
||||
}
|
||||
if (strlen(trim($search_labelshort))) {
|
||||
$sql .= natural_search("aa.labelshort", $search_labelshort);
|
||||
}
|
||||
if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') {
|
||||
$sql .= natural_search("aa.account_parent", $search_accountparent, 2);
|
||||
}
|
||||
if (strlen(trim($search_pcgtype))) {
|
||||
$sql .= natural_search("aa.pcg_type", $search_pcgtype);
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
//print $sql;
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// List of mass actions available
|
||||
if ($user->rights->accounting->chartofaccount) {
|
||||
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
}
|
||||
if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
|
||||
$arrayofmassactions = array();
|
||||
}
|
||||
|
||||
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
|
||||
$arrayofselected = is_array($toselect) ? $toselect : array();
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($search_account) $param .= '&search_account='.urlencode($search_account);
|
||||
if ($search_label) $param .= '&search_label='.urlencode($search_label);
|
||||
if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort);
|
||||
if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent);
|
||||
if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($search_account) {
|
||||
$param .= '&search_account='.urlencode($search_account);
|
||||
}
|
||||
if ($search_label) {
|
||||
$param .= '&search_label='.urlencode($search_label);
|
||||
}
|
||||
if ($search_labelshort) {
|
||||
$param .= '&search_labelshort='.urlencode($search_labelshort);
|
||||
}
|
||||
if ($search_accountparent > 0 || $search_accountparent == '0') {
|
||||
$param .= '&search_accountparent='.urlencode($search_accountparent);
|
||||
}
|
||||
if ($search_pcgtype) {
|
||||
$param .= '&search_pcgtype='.urlencode($search_pcgtype);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
||||
if (!empty($conf->use_javascript_ajax))
|
||||
{
|
||||
if (!empty($conf->use_javascript_ajax)) {
|
||||
print '<!-- Add javascript to reload page when we click "Change plan" -->
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
@ -288,7 +350,9 @@ if ($resql)
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
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="list">';
|
||||
@ -297,22 +361,23 @@ if ($resql)
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
$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);
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $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">';
|
||||
print '<select class="flat minwidth200" 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;
|
||||
print '<option value="-1"> </option>';
|
||||
while ($i < $numbis) {
|
||||
$obj = $db->fetch_object($resqlchart);
|
||||
|
||||
@ -322,7 +387,9 @@ if ($resql)
|
||||
|
||||
$i++;
|
||||
}
|
||||
} else dol_print_error($db);
|
||||
} 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")).'">';
|
||||
@ -332,50 +399,85 @@ if ($resql)
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
|
||||
|
||||
$moreforfilter = '';
|
||||
$massactionbutton = '';
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
||||
|
||||
// Line for search fields
|
||||
print '<tr class="liste_titre_filter">';
|
||||
if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
|
||||
if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
|
||||
if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
|
||||
if (!empty($arrayfields['aa.account_number']['checked'])) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['aa.label']['checked'])) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['aa.labelshort']['checked'])) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
|
||||
}
|
||||
if (!empty($arrayfields['aa.account_parent']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
|
||||
print '</td>';
|
||||
}
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre"> </td>'; }
|
||||
if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre"> </td>';
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
|
||||
}
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($arrayfields['aa.reconcilable']['checked'])) {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['aa.active']['checked'])) {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
}
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
$searchpicto = $form->showFilterButtons();
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$totalarray = array();
|
||||
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);
|
||||
if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
|
||||
if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
|
||||
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);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['aa.label']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['aa.labelshort']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['aa.account_parent']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($arrayfields['aa.reconcilable']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
if (!empty($arrayfields['aa.active']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
$accountstatic = new AccountingAccount($db);
|
||||
$accountparent = new AccountingAccount($db);
|
||||
|
||||
$totalarray = array();
|
||||
$i = 0;
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$accountstatic->id = $obj->rowid;
|
||||
@ -385,39 +487,40 @@ if ($resql)
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Account number
|
||||
if (!empty($arrayfields['aa.account_number']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.account_number']['checked'])) {
|
||||
print "<td>";
|
||||
print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Account label
|
||||
if (!empty($arrayfields['aa.label']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.label']['checked'])) {
|
||||
print "<td>";
|
||||
print $obj->label;
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Account label to show (label short)
|
||||
if (!empty($arrayfields['aa.labelshort']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.labelshort']['checked'])) {
|
||||
print "<td>";
|
||||
print $obj->labelshort;
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Account parent
|
||||
if (!empty($arrayfields['aa.account_parent']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.account_parent']['checked'])) {
|
||||
// Note: obj->account_parent is a foreign key to a rowid. It is field in child table and obj->rowid2 is same, but in parent table.
|
||||
// So for orphans, obj->account_parent is set but not obj->rowid2
|
||||
if (!empty($obj->account_parent) && !empty($obj->rowid2))
|
||||
{
|
||||
if (!empty($obj->account_parent) && !empty($obj->rowid2)) {
|
||||
print "<td>";
|
||||
print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
|
||||
$accountparent->id = $obj->rowid2;
|
||||
@ -425,24 +528,29 @@ if ($resql)
|
||||
$accountparent->account_number = $obj->account_number2; // Sotre an account number for output
|
||||
print $accountparent->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
} else {
|
||||
print '<td>';
|
||||
if (!empty($obj->account_parent)) {
|
||||
print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Chart of accounts type
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.pcg_type']['checked'])) {
|
||||
print "<td>";
|
||||
print $obj->pcg_type;
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
@ -450,11 +558,11 @@ if ($resql)
|
||||
if (!empty($arrayfields['aa.reconcilable']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (empty($obj->reconcilable)) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
@ -466,24 +574,25 @@ if ($resql)
|
||||
}
|
||||
|
||||
// Activated or not
|
||||
if (!empty($arrayfields['aa.active']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['aa.active']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (empty($obj->active)) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=0">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=0&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Action
|
||||
print '<td class="center">';
|
||||
print '<td class="center nowraponall">';
|
||||
if ($user->rights->accounting->chartofaccount) {
|
||||
print '<a class="editfielda" href="./card.php?action=update&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
|
||||
print img_edit();
|
||||
@ -492,14 +601,29 @@ if ($resql)
|
||||
print '<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
|
||||
print img_delete();
|
||||
print '</a>';
|
||||
print ' ';
|
||||
if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
|
||||
$selected = 0;
|
||||
if (in_array($obj->rowid, $arrayofselected)) {
|
||||
$selected = 1;
|
||||
}
|
||||
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
|
||||
}
|
||||
}
|
||||
print '</td>'."\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($num == 0) {
|
||||
$totalarray['nbfield']++;
|
||||
print '<tr><td colspan="'.$totalarray['nbfield'].'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print "</div>";
|
||||
print '</form>';
|
||||
|
||||
@ -39,7 +39,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
if (!empty($conf->accounting->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("errors", "admin", "companies", "resource", "holiday", "compta", "accountancy", "hrm"));
|
||||
@ -62,7 +64,9 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield", 'aZ09comma');
|
||||
$sortorder = GETPOST("sortorder", 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $listlimit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -71,8 +75,12 @@ $search_country_id = GETPOST('search_country_id', 'int');
|
||||
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if (!$user->rights->accounting->chartofaccount) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->chartofaccount) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
@ -139,14 +147,12 @@ $sourceList = array();
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha'))
|
||||
{
|
||||
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
|
||||
$search_country_id = '';
|
||||
}
|
||||
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
@ -154,56 +160,50 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
|
||||
// Check that all fields are filled
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) continue; // For some pages, country is not mandatory
|
||||
if ((!GETPOSTISSET($value)) || GETPOST($value) == '')
|
||||
{
|
||||
foreach ($listfield as $f => $value) {
|
||||
if ($value == 'country_id' && in_array($tablib[$id], array('Pcg_version'))) {
|
||||
continue; // For some pages, country is not mandatory
|
||||
}
|
||||
if ((!GETPOSTISSET($value)) || GETPOST($value) == '') {
|
||||
$ok = 0;
|
||||
$fieldnamekey = $listfield[$f];
|
||||
// We take translate key of field
|
||||
|
||||
if ($fieldnamekey == 'pcg_version') $fieldnamekey = 'Pcg_version';
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
|
||||
if ($fieldnamekey == 'pcg_version') {
|
||||
$fieldnamekey = 'Pcg_version';
|
||||
}
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
|
||||
$fieldnamekey = 'Label';
|
||||
}
|
||||
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors');
|
||||
}
|
||||
}
|
||||
// Other checks
|
||||
if ($tabname[$id] == MAIN_DB_PREFIX."c_actioncomm" && GETPOSTISSET("type") && in_array($_POST["type"], array('system', 'systemauto'))) {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorReservedTypeSystemSystemAuto'), null, 'errors');
|
||||
}
|
||||
if (GETPOSTISSET("pcg_version"))
|
||||
{
|
||||
if (GETPOST("pcg_version") == '0')
|
||||
{
|
||||
if (GETPOSTISSET("pcg_version")) {
|
||||
if (GETPOST("pcg_version") == '0') {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
|
||||
{
|
||||
$ok = 0;
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
{
|
||||
$ok = 0;
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
}
|
||||
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2))
|
||||
{
|
||||
if (GETPOSTISSET("country") && (GETPOST("country") == '0') && ($id != 2)) {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities("Country")), null, 'errors');
|
||||
}
|
||||
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
if ($ok && GETPOST('actionadd', 'alpha')) {
|
||||
if ($tabrowid[$id]) {
|
||||
// Recupere id libre pour insertion
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
@ -214,34 +214,39 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Add new entry
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$sql .= $tabrowid[$id].",";
|
||||
}
|
||||
$sql .= $tabfieldinsert[$id];
|
||||
$sql .= ",active)";
|
||||
$sql .= " VALUES(";
|
||||
|
||||
// List of values
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$sql .= $newid.",";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldinsert as $f => $value)
|
||||
{
|
||||
foreach ($listfieldinsert as $f => $value) {
|
||||
if ($value == 'price' || preg_match('/^amount/i', $value) || $value == 'taux') {
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
|
||||
} elseif ($value == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql .= ",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
}
|
||||
if ($_POST[$listfieldvalue[$i]] == '') {
|
||||
$sql .= "null";
|
||||
} else {
|
||||
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ",1)";
|
||||
|
||||
dol_syslog("actionadd", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) // Add is ok
|
||||
{
|
||||
if ($result) { // Add is ok
|
||||
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
|
||||
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
|
||||
} else {
|
||||
@ -254,30 +259,36 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
}
|
||||
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($ok && GETPOST('actionmodify', 'alpha')) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
|
||||
{
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
|
||||
$sql .= $tabrowid[$id]."=";
|
||||
$sql .= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
{
|
||||
foreach ($listfieldmodify as $field) {
|
||||
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
|
||||
} elseif ($field == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql .= ",";
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
}
|
||||
$sql .= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null";
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') {
|
||||
$sql .= "null";
|
||||
} else {
|
||||
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -285,31 +296,30 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
}
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
|
||||
if (GETPOST('actioncancel', 'alpha'))
|
||||
{
|
||||
if (GETPOST('actioncancel', 'alpha')) {
|
||||
//$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
if (!$result) {
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -318,9 +328,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
}
|
||||
|
||||
// activate
|
||||
if ($action == $acts[0])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == $acts[0]) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -329,16 +342,18 @@ if ($action == $acts[0])
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// disable
|
||||
if ($action == $acts[1])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == $acts[1]) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -347,16 +362,18 @@ if ($action == $acts[1])
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// favorite
|
||||
if ($action == 'activate_favorite')
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == 'activate_favorite') {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 1 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -365,16 +382,18 @@ if ($action == 'activate_favorite')
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// disable favorite
|
||||
if ($action == 'disable_favorite')
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == 'disable_favorite') {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET favorite = 0 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -383,8 +402,7 @@ if ($action == 'disable_favorite')
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
@ -406,8 +424,7 @@ print load_fiche_titre($titre, $linkback, 'title_accountancy');
|
||||
|
||||
|
||||
// Confirmation de la suppression de la ligne
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.urlencode($page).'&' : '').'sortfield='.urlencode($sortfield).'&sortorder='.urlencode($sortorder).'&rowid='.urlencode($rowid).'&code='.urlencode($code).'&id='.urlencode($id), $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
//var_dump($elementList);
|
||||
@ -415,20 +432,23 @@ if ($action == 'delete')
|
||||
/*
|
||||
* Show a dictionary
|
||||
*/
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql = $tabsql[$id];
|
||||
|
||||
if ($search_country_id > 0)
|
||||
{
|
||||
if (preg_match('/ WHERE /', $sql)) $sql .= " AND ";
|
||||
else $sql .= " WHERE ";
|
||||
if ($search_country_id > 0) {
|
||||
if (preg_match('/ WHERE /', $sql)) {
|
||||
$sql .= " AND ";
|
||||
} else {
|
||||
$sql .= " WHERE ";
|
||||
}
|
||||
$sql .= " c.rowid = ".$search_country_id;
|
||||
}
|
||||
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield = 'country_code';
|
||||
if ($sortfield == 'country') {
|
||||
$sortfield = 'country_code';
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($listlimit + 1, $offset);
|
||||
//print $sql;
|
||||
@ -442,33 +462,35 @@ if ($id)
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused = 0;
|
||||
$var = false;
|
||||
|
||||
if ($tabname[$id]) {
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$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] == 'libelle' || $fieldlist[$field] == 'label')
|
||||
{
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$valuetoshow = $langs->trans("Code");
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') {
|
||||
$valuetoshow = $langs->trans("Label");
|
||||
}
|
||||
if ($fieldlist[$field] == 'country') {
|
||||
if (in_array('region_id', $fieldlist)) { print '<td> </td>'; continue; } // For region page, we do not show the country input
|
||||
if (in_array('region_id', $fieldlist)) {
|
||||
print '<td> </td>'; continue;
|
||||
} // For region page, we do not show the country input
|
||||
$valuetoshow = $langs->trans("Country");
|
||||
}
|
||||
if ($fieldlist[$field] == 'country_id') { $valuetoshow = ''; }
|
||||
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') { $valuetoshow = $langs->trans("Pcg_version"); }
|
||||
if ($fieldlist[$field] == 'country_id') {
|
||||
$valuetoshow = '';
|
||||
}
|
||||
if ($fieldlist[$field] == 'pcg_version' || $fieldlist[$field] == 'fk_pcg_version') {
|
||||
$valuetoshow = $langs->trans("Pcg_version");
|
||||
}
|
||||
|
||||
if ($valuetoshow != '') {
|
||||
print '<td class="'.$class.'">';
|
||||
@ -481,7 +503,6 @@ if ($id)
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle' || $fieldlist[$field] == 'label') $alabelisused = 1;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
@ -496,12 +517,11 @@ if ($id)
|
||||
|
||||
$obj = new stdClass();
|
||||
// If data was already input, we define them in obj to populate input fields.
|
||||
if (GETPOST('actionadd', 'alpha'))
|
||||
{
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val))
|
||||
if (GETPOST('actionadd', 'alpha')) {
|
||||
foreach ($fieldlist as $key => $val) {
|
||||
if (GETPOST($val)) {
|
||||
$obj->$val = GETPOST($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -510,8 +530,7 @@ if ($id)
|
||||
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'add');
|
||||
}
|
||||
|
||||
@ -530,20 +549,24 @@ if ($id)
|
||||
// List of available values in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
|
||||
if ($search_country_id > 0) {
|
||||
$param .= '&search_country_id='.$search_country_id;
|
||||
}
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
|
||||
if ($sortorder) {
|
||||
$paramwithsearch .= '&sortorder='.$sortorder;
|
||||
}
|
||||
if ($sortfield) {
|
||||
$paramwithsearch .= '&sortfield='.$sortfield;
|
||||
}
|
||||
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
if ($num > $listlimit) {
|
||||
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
|
||||
print '</td></tr>';
|
||||
@ -551,16 +574,15 @@ if ($id)
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
$showfield = 1; // By defaut
|
||||
|
||||
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') { $showfield = 0; }
|
||||
if ($fieldlist[$field] == 'region_id' || $fieldlist[$field] == 'country_id') {
|
||||
$showfield = 0;
|
||||
}
|
||||
|
||||
if ($showfield)
|
||||
{
|
||||
if ($value == 'country')
|
||||
{
|
||||
if ($showfield) {
|
||||
if ($value == 'country') {
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
print '</td>';
|
||||
@ -586,16 +608,13 @@ if ($id)
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
// Lines with values
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
//print_r($obj);
|
||||
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
|
||||
{
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
|
||||
print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
@ -606,39 +625,35 @@ if ($id)
|
||||
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook)) fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
if (empty($reshook)) {
|
||||
fieldListAccountModel($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
}
|
||||
|
||||
print '<td colspan="3" class="right"><a name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"> </a><input type="submit" class="button" name="actionmodify" value="'.$langs->trans("Modify").'">';
|
||||
print ' <input type="submit" class="button button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||
} else {
|
||||
$tmpaction = 'view';
|
||||
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$tmpaction = 'view';
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
$showfield = 1;
|
||||
$class = "left";
|
||||
$valuetoshow = $obj->{$fieldlist[$field]};
|
||||
if ($value == 'type_template')
|
||||
{
|
||||
if ($value == 'type_template') {
|
||||
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
|
||||
}
|
||||
if ($value == 'element')
|
||||
{
|
||||
if ($value == 'element') {
|
||||
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
|
||||
} elseif ($value == 'source')
|
||||
{
|
||||
} elseif ($value == 'source') {
|
||||
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
|
||||
} elseif ($valuetoshow == 'all') {
|
||||
$valuetoshow = $langs->trans('All');
|
||||
} elseif ($fieldlist[$field] == 'country') {
|
||||
if (empty($obj->country_code))
|
||||
{
|
||||
if (empty($obj->country_code)) {
|
||||
$valuetoshow = '-';
|
||||
} else {
|
||||
$key = $langs->trans("Country".strtoupper($obj->country_code));
|
||||
@ -649,9 +664,13 @@ if ($id)
|
||||
}
|
||||
|
||||
$class = 'tddict';
|
||||
if ($fieldlist[$field] == 'tracking') $class .= ' tdoverflowauto';
|
||||
if ($fieldlist[$field] == 'tracking') {
|
||||
$class .= ' tdoverflowauto';
|
||||
}
|
||||
// Show value for field
|
||||
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
if ($showfield) {
|
||||
print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,22 +678,33 @@ if ($id)
|
||||
$iserasable = 1; $canbedisabled = 1; $canbemodified = 1; // true by default
|
||||
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
|
||||
if ($param) $url .= '&'.$param;
|
||||
if ($param) {
|
||||
$url .= '&'.$param;
|
||||
}
|
||||
$url .= '&';
|
||||
|
||||
// Active
|
||||
print '<td class="center nowrap">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
else print $langs->trans("AlwaysActive");
|
||||
if ($canbedisabled) {
|
||||
print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
} else {
|
||||
print $langs->trans("AlwaysActive");
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
// Modify link
|
||||
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
|
||||
else print '<td> </td>';
|
||||
if ($canbemodified) {
|
||||
print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
// Delete link
|
||||
if ($iserasable) print '<td class="center"><a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
|
||||
else print '<td> </td>';
|
||||
if ($iserasable) {
|
||||
print '<td class="center"><a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a></td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
}
|
||||
@ -718,12 +748,9 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
|
||||
$formcompany = new FormCompany($db);
|
||||
$formaccounting = new FormAccounting($db);
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'country')
|
||||
{
|
||||
if (in_array('region_id', $fieldlist))
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
if ($fieldlist[$field] == 'country') {
|
||||
if (in_array('region_id', $fieldlist)) {
|
||||
print '<td>';
|
||||
//print join(',',$fieldlist);
|
||||
print '</td>';
|
||||
@ -733,18 +760,19 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
|
||||
$fieldname = 'country';
|
||||
print $form->select_country((!empty($obj->country_code) ? $obj->country_code : (!empty($obj->country) ? $obj->country : '')), $fieldname, '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
print '</td>';
|
||||
} elseif ($fieldlist[$field] == 'country_id')
|
||||
{
|
||||
if (!in_array('country', $fieldlist)) // If there is already a field country, we don't show country_id (avoid duplicate)
|
||||
{
|
||||
} elseif ($fieldlist[$field] == 'country_id') {
|
||||
if (!in_array('country', $fieldlist)) { // If there is already a field country, we don't show country_id (avoid duplicate)
|
||||
$country_id = (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]} : 0);
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="'.$fieldlist[$field].'" value="'.$country_id.'">';
|
||||
print '</td>';
|
||||
}
|
||||
} elseif ($fieldlist[$field] == 'type_cdr') {
|
||||
if ($fieldlist[$field] == 'type_cdr') print '<td class="center">';
|
||||
else print '<td>';
|
||||
if ($fieldlist[$field] == 'type_cdr') {
|
||||
print '<td class="center">';
|
||||
} else {
|
||||
print '<td>';
|
||||
}
|
||||
if ($fieldlist[$field] == 'type_cdr') {
|
||||
print $form->selectarray($fieldlist[$field], array(0=>$langs->trans('None'), 1=>$langs->trans('AtEndOfMonth'), 2=>$langs->trans('CurrentNext')), (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
|
||||
} else {
|
||||
@ -756,10 +784,18 @@ function fieldListAccountModel($fieldlist, $obj = '', $tabname = '', $context =
|
||||
} else {
|
||||
print '<td>';
|
||||
$size = ''; $class = '';
|
||||
if ($fieldlist[$field] == 'code') $size = 'size="8" ';
|
||||
if ($fieldlist[$field] == 'position') $size = 'size="4" ';
|
||||
if ($fieldlist[$field] == 'libelle') $size = 'centpercent';
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$size = 'size="8" ';
|
||||
}
|
||||
if ($fieldlist[$field] == 'position') {
|
||||
$size = 'size="4" ';
|
||||
}
|
||||
if ($fieldlist[$field] == 'libelle') {
|
||||
$size = 'centpercent';
|
||||
}
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
|
||||
$size = 'size="2" ';
|
||||
}
|
||||
print '<input type="text" '.$size.' class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -32,20 +32,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
$error = 0;
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("bills", "accountancy"));
|
||||
$langs->loadLangs(array("bills", "accountancy", "compta"));
|
||||
|
||||
$mesg = '';
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$backtopage = GETPOST('backtopage', 'alpha');
|
||||
$id = GETPOST('id', 'int');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$accountingaccount = GETPOST('accountingaccount', 'alpha');
|
||||
|
||||
$account_number = GETPOST('account_number', 'string');
|
||||
$label = GETPOST('label', 'alpha');
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if (!$user->rights->accounting->chartofaccount) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->chartofaccount) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
$object = new AccountingAccount($db);
|
||||
@ -55,114 +60,121 @@ $object = new AccountingAccount($db);
|
||||
* Action
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha'))
|
||||
{
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$urltogo = $backtopage ? $backtopage : dol_buildpath('/accountancy/admin/account.php', 1);
|
||||
header("Location: ".$urltogo);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($action == 'add' && $user->rights->accounting->chartofaccount)
|
||||
{
|
||||
if ($action == 'add' && $user->rights->accounting->chartofaccount) {
|
||||
if (!$cancel) {
|
||||
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
|
||||
$result = $db->query($sql);
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
// Clean code
|
||||
|
||||
// To manage zero or not at the end of the accounting account
|
||||
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
|
||||
{
|
||||
$account_number = GETPOST('account_number', 'string');
|
||||
if (!$account_number) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
|
||||
$action = 'create';
|
||||
} elseif (!$label) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
||||
$action = 'create';
|
||||
} else {
|
||||
$account_number = clean_account(GETPOST('account_number', 'string'));
|
||||
}
|
||||
$sql = 'SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS);
|
||||
|
||||
if (GETPOST('account_parent', 'int') <= 0)
|
||||
{
|
||||
$account_parent = 0;
|
||||
} else {
|
||||
$account_parent = GETPOST('account_parent', 'int');
|
||||
}
|
||||
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
|
||||
$result = $db->query($sql);
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
$object->fk_pcg_version = $obj->pcg_version;
|
||||
$object->pcg_type = GETPOST('pcg_type', 'alpha');
|
||||
$object->account_number = $account_number;
|
||||
$object->account_parent = $account_parent;
|
||||
$object->account_category = GETPOST('account_category', 'alpha');
|
||||
$object->label = GETPOST('label', 'alpha');
|
||||
$object->labelshort = GETPOST('labelshort', 'alpha');
|
||||
$object->active = 1;
|
||||
// Clean code
|
||||
|
||||
$res = $object->create($user);
|
||||
if ($res == - 3) {
|
||||
$error = 1;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} elseif ($res == - 4) {
|
||||
$error = 2;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} elseif ($res < 0)
|
||||
{
|
||||
$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;
|
||||
// To manage zero or not at the end of the accounting account
|
||||
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1) {
|
||||
$account_number = $account_number;
|
||||
} else {
|
||||
$account_number = clean_account($account_number);
|
||||
}
|
||||
|
||||
if (GETPOST('account_parent', 'int') <= 0) {
|
||||
$account_parent = 0;
|
||||
} else {
|
||||
$account_parent = GETPOST('account_parent', 'int');
|
||||
}
|
||||
|
||||
$object->fk_pcg_version = $obj->pcg_version;
|
||||
$object->pcg_type = GETPOST('pcg_type', 'alpha');
|
||||
$object->account_number = $account_number;
|
||||
$object->account_parent = $account_parent;
|
||||
$object->account_category = GETPOST('account_category', 'alpha');
|
||||
$object->label = $label;
|
||||
$object->labelshort = GETPOST('labelshort', 'alpha');
|
||||
$object->active = 1;
|
||||
|
||||
$res = $object->create($user);
|
||||
if ($res == -3) {
|
||||
$error = 1;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} elseif ($res == -4) {
|
||||
$error = 2;
|
||||
$action = "create";
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} elseif ($res < 0) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'edit' && $user->rights->accounting->chartofaccount) {
|
||||
if (!$cancel) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.$conf->global->CHARTOFACCOUNTS;
|
||||
|
||||
dol_syslog('accountancy/admin/card.php:: $sql='.$sql);
|
||||
$result2 = $db->query($sql);
|
||||
$obj = $db->fetch_object($result2);
|
||||
|
||||
// Clean code
|
||||
|
||||
// To manage zero or not at the end of the accounting account
|
||||
if ($conf->global->ACCOUNTING_MANAGE_ZERO == 1)
|
||||
{
|
||||
$account_number = GETPOST('account_number', 'string');
|
||||
if (!$account_number) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountNumber")), null, 'errors');
|
||||
$action = 'update';
|
||||
} elseif (!$label) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
|
||||
$action = 'update';
|
||||
} else {
|
||||
$account_number = clean_account(GETPOST('account_number', 'string'));
|
||||
}
|
||||
$result = $object->fetch($id);
|
||||
|
||||
if (GETPOST('account_parent', 'int') <= 0)
|
||||
{
|
||||
$account_parent = 0;
|
||||
} else {
|
||||
$account_parent = GETPOST('account_parent', 'int');
|
||||
}
|
||||
$sql = 'SELECT pcg_version FROM '.MAIN_DB_PREFIX.'accounting_system WHERE rowid='.((int) $conf->global->CHARTOFACCOUNTS);
|
||||
|
||||
$object->fk_pcg_version = $obj->pcg_version;
|
||||
$object->pcg_type = GETPOST('pcg_type', 'alpha');
|
||||
$object->account_number = $account_number;
|
||||
$object->account_parent = $account_parent;
|
||||
$object->account_category = GETPOST('account_category', 'alpha');
|
||||
$object->label = GETPOST('label', 'alpha');
|
||||
$object->labelshort = GETPOST('labelshort', 'alpha');
|
||||
dol_syslog('accountancy/admin/card.php:: $sql=' . $sql);
|
||||
$result2 = $db->query($sql);
|
||||
$obj = $db->fetch_object($result2);
|
||||
|
||||
$result = $object->update($user);
|
||||
// Clean code
|
||||
|
||||
if ($result > 0) {
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
header("Location: ".$urltogo);
|
||||
exit();
|
||||
} else {
|
||||
$mesg = $object->error;
|
||||
// To manage zero or not at the end of the accounting account
|
||||
if (isset($conf->global->ACCOUNTING_MANAGE_ZERO) && $conf->global->ACCOUNTING_MANAGE_ZERO == 1) {
|
||||
$account_number = $account_number;
|
||||
} else {
|
||||
$account_number = clean_account($account_number);
|
||||
}
|
||||
|
||||
if (GETPOST('account_parent', 'int') <= 0) {
|
||||
$account_parent = 0;
|
||||
} else {
|
||||
$account_parent = GETPOST('account_parent', 'int');
|
||||
}
|
||||
|
||||
$object->fk_pcg_version = $obj->pcg_version;
|
||||
$object->pcg_type = GETPOST('pcg_type', 'alpha');
|
||||
$object->account_number = $account_number;
|
||||
$object->account_parent = $account_parent;
|
||||
$object->account_category = GETPOST('account_category', 'alpha');
|
||||
$object->label = $label;
|
||||
$object->labelshort = GETPOST('labelshort', 'alpha');
|
||||
|
||||
$result = $object->update($user);
|
||||
if ($result > 0) {
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"] . "?id=" . $id);
|
||||
header("Location: " . $urltogo);
|
||||
exit();
|
||||
} else {
|
||||
setEventMessages($object->error, null, 'errors');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$urltogo = $backtopage ? $backtopage : ($_SERVER["PHP_SELF"]."?id=".$id);
|
||||
@ -198,8 +210,10 @@ $accountsystem = new AccountancySystem($db);
|
||||
$accountsystem->fetch($conf->global->CHARTOFACCOUNTS);
|
||||
|
||||
$title = $langs->trans('AccountAccounting')." - ".$langs->trans('Card');
|
||||
$helpurl = '';
|
||||
llxheader('', $title, $helpurl);
|
||||
|
||||
$help_url = 'EN:Category:Accounting';
|
||||
|
||||
llxheader('', $title, $help_url);
|
||||
|
||||
|
||||
// Create mode
|
||||
@ -222,7 +236,7 @@ if ($action == 'create') {
|
||||
|
||||
// Account number
|
||||
print '<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans("AccountNumber").'</span></td>';
|
||||
print '<td><input name="account_number" size="30" value="'.$accountingaccount.'"></td></tr>';
|
||||
print '<td><input name="account_number" size="30" value="'.$account_number.'"></td></tr>';
|
||||
|
||||
// Label
|
||||
print '<tr><td><span class="fieldrequired">'.$langs->trans("Label").'</span></td>';
|
||||
@ -238,18 +252,22 @@ if ($action == 'create') {
|
||||
print $formaccounting->select_account($object->account_parent, 'account_parent', 1, null, 0, 0, 'minwidth200');
|
||||
print '</td></tr>';
|
||||
|
||||
// Category
|
||||
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
|
||||
print '<td>';
|
||||
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Chart of accounts type
|
||||
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc"));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Category
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc"));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1, 0, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
@ -265,13 +283,10 @@ if ($action == 'create') {
|
||||
$result = $object->fetch($id, $ref, 1);
|
||||
|
||||
if ($result > 0) {
|
||||
dol_htmloutput_mesg($mesg);
|
||||
|
||||
$head = accounting_prepare_head($object);
|
||||
|
||||
// Edit mode
|
||||
if ($action == 'update')
|
||||
{
|
||||
if ($action == 'update') {
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans('AccountAccounting'), 0, 'billr');
|
||||
|
||||
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
@ -300,18 +315,22 @@ if ($action == 'create') {
|
||||
print $formaccounting->select_account($object->account_parent, 'account_parent', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Category
|
||||
print '<tr><td>'.$langs->trans("AccountingCategory").'</td>';
|
||||
print '<td>';
|
||||
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Chart of accounts type
|
||||
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc"));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
print '<input type="text" name="pcg_type" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Category
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc"));
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formaccounting->select_accounting_category($object->account_category, 'account_category', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
@ -353,13 +372,17 @@ if ($action == 'create') {
|
||||
print '<tr><td>'.$langs->trans("Accountparent").'</td>';
|
||||
print '<td colspan="2">'.$accp->account_number.' - '.$accp->label.'</td></tr>';
|
||||
|
||||
// Category
|
||||
print "<tr><td>".$langs->trans("AccountingCategory")."</td><td colspan='2'>".$object->account_category_label."</td>";
|
||||
|
||||
// Chart of accounts type
|
||||
print '<tr><td>'.$langs->trans("Pcgtype").'</td>';
|
||||
// Group of accounting account
|
||||
print '<tr><td>';
|
||||
print $form->textwithpicto($langs->trans("Pcgtype"), $langs->transnoentitiesnoconv("PcgtypeDesc"));
|
||||
print '</td>';
|
||||
print '<td colspan="2">'.$object->pcg_type.'</td></tr>';
|
||||
|
||||
// Custom group of accounting account
|
||||
print "<tr><td>";
|
||||
print $form->textwithpicto($langs->trans("AccountingCategory"), $langs->transnoentitiesnoconv("AccountingAccountGroupsDesc"));
|
||||
print "</td><td colspan='2'>".$object->account_category_label."</td>";
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
@ -32,9 +32,7 @@ $error = 0;
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("bills", "accountancy"));
|
||||
|
||||
$mesg = '';
|
||||
$id = GETPOST('id', 'int');
|
||||
$rowid = GETPOST('rowid', 'int');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$cat_id = GETPOST('account_category', 'int');
|
||||
@ -46,8 +44,7 @@ if ($cat_id == 0) {
|
||||
}
|
||||
|
||||
// Security check
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
{
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
@ -58,12 +55,13 @@ $accountingcategory = new AccountancyCategory($db);
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// si ajout de comptes
|
||||
// If we add account
|
||||
if (!empty($selectcpt)) {
|
||||
$cpts = array();
|
||||
foreach ($selectcpt as $selectedoption) {
|
||||
if (!array_key_exists($selectedoption, $cpts))
|
||||
if (!array_key_exists($selectedoption, $cpts)) {
|
||||
$cpts[$selectedoption] = "'".$selectedoption."'";
|
||||
}
|
||||
}
|
||||
|
||||
$return = $accountingcategory->updateAccAcc($cat_id, $cpts);
|
||||
@ -74,6 +72,7 @@ if (!empty($selectcpt)) {
|
||||
setEventMessages($langs->trans('RecordModifiedSuccessfully'), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'delete') {
|
||||
if ($cpt_id) {
|
||||
if ($accountingcategory->deleteCptCat($cpt_id)) {
|
||||
@ -95,8 +94,9 @@ $formaccounting = new FormAccounting($db);
|
||||
llxheader('', $langs->trans('AccountingCategory'));
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/categories_list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
$titlepicto = 'setup';
|
||||
|
||||
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback);
|
||||
print load_fiche_titre($langs->trans('AccountingCategory'), $linkback, $titlepicto);
|
||||
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -114,8 +114,7 @@ print '<input class="button" type="submit" value="'.$langs->trans("Select").'">'
|
||||
print '</td></tr>';
|
||||
|
||||
// Select the accounts
|
||||
if (!empty($cat_id))
|
||||
{
|
||||
if (!empty($cat_id)) {
|
||||
$return = $accountingcategory->getAccountsWithNoCategory($cat_id);
|
||||
if ($return < 0) {
|
||||
setEventMessages(null, $accountingcategory->errors, 'errors');
|
||||
@ -124,8 +123,7 @@ if (!empty($cat_id))
|
||||
print '<td>';
|
||||
|
||||
$arraykeyvalue = array();
|
||||
foreach ($accountingcategory->lines_cptbk as $key => $val)
|
||||
{
|
||||
foreach ($accountingcategory->lines_cptbk as $key => $val) {
|
||||
$arraykeyvalue[length_accountg($val->numero_compte)] = length_accountg($val->numero_compte).' ('.$val->label_compte.($val->doc_ref ? ' '.$val->doc_ref : '').')';
|
||||
}
|
||||
|
||||
@ -152,8 +150,8 @@ print '</form>';
|
||||
|
||||
|
||||
if ($action == 'display' || $action == 'delete') {
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print "<table class='noborder' width='100%'>\n";
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">'.$langs->trans("AccountAccounting")."</td>";
|
||||
print '<td class="liste_titre" colspan="2">'.$langs->trans("Label")."</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,6 @@ if ($action == 'update') {
|
||||
|
||||
foreach ($list_account_main as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -38,8 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries", "loan"));
|
||||
|
||||
// Security check
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
{
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
@ -36,8 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
|
||||
$langs->loadLangs(array("compta", "bills", "admin", "accountancy"));
|
||||
|
||||
// Security access
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
{
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
@ -32,21 +32,29 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "f.rowid"; // Set here default search field
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "f.rowid"; // Set here default search field
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("admin", "compta"));
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
if (!$user->rights->accounting->fiscalyear->write) // If we can read accounting records, we should be able to see fiscal year.
|
||||
}
|
||||
if (!$user->rights->accounting->fiscalyear->write) { // If we can read accounting records, we should be able to see fiscal year.
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -58,8 +66,9 @@ static $tmpstatut2label = array(
|
||||
$statut2label = array(
|
||||
''
|
||||
);
|
||||
foreach ($tmpstatut2label as $key => $val)
|
||||
foreach ($tmpstatut2label as $key => $val) {
|
||||
$statut2label[$key] = $langs->trans($val);
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
|
||||
@ -82,8 +91,10 @@ $form = new Form($db);
|
||||
$fiscalyearstatic = new Fiscalyear($db);
|
||||
|
||||
$title = $langs->trans('AccountingPeriods');
|
||||
$helpurl = "";
|
||||
llxHeader('', $title, $helpurl);
|
||||
|
||||
$help_url = "EN:Module_Double_Entry_Accounting";
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$sql = "SELECT f.rowid, f.label, f.date_start, f.date_end, f.statut, f.entity";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear as f";
|
||||
@ -92,12 +103,10 @@ $sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
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
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -106,8 +115,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
||||
@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
|
||||
$langs->loadLangs(array("admin", "compta"));
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
if (empty($user->rights->accounting->fiscalyear->write))
|
||||
}
|
||||
if (empty($user->rights->accounting->fiscalyear->write)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -50,8 +52,9 @@ static $tmpstatut2label = array(
|
||||
$statut2label = array(
|
||||
''
|
||||
);
|
||||
foreach ($tmpstatut2label as $key => $val)
|
||||
foreach ($tmpstatut2label as $key => $val) {
|
||||
$statut2label[$key] = $langs->trans($val);
|
||||
}
|
||||
|
||||
$object = new Fiscalyear($db);
|
||||
|
||||
@ -113,15 +116,13 @@ if ($action == 'confirm_delete' && $confirm == "yes") {
|
||||
header("Location: ./fiscalyear.php");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Update record
|
||||
elseif ($action == 'update') {
|
||||
} elseif ($action == 'update') {
|
||||
// Update record
|
||||
if (!GETPOST('cancel', 'alpha')) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$object->date_start = empty($_POST["fiscalyear"]) ? '' : $date_start;
|
||||
$object->date_end = empty($_POST["fiscalyearend"]) ? '' : $date_end;
|
||||
$object->date_start = GETPOST("fiscalyear") ? $date_start : '';
|
||||
$object->date_end = GETPOST("fiscalyearend") ? $date_end : '';
|
||||
$object->label = GETPOST('label', 'alpha');
|
||||
$object->statut = GETPOST('statut', 'int');
|
||||
|
||||
@ -148,11 +149,12 @@ elseif ($action == 'update') {
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Card");
|
||||
$helpurl = "";
|
||||
llxHeader("", $title, $helpurl);
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
$help_url = "EN:Module_Double_Entry_Accounting";
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("NewFiscalYear"));
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
@ -298,11 +300,10 @@ if ($action == 'create')
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
if (!empty($user->rights->accounting->fiscalyear->write))
|
||||
{
|
||||
/*
|
||||
* Barre d'actions
|
||||
*/
|
||||
/*
|
||||
* Action bar
|
||||
*/
|
||||
if (!empty($user->rights->accounting->fiscalyear->write)) {
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
||||
|
||||
@ -30,17 +30,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/fiscalyear.class.php';
|
||||
$langs->loadLangs(array("admin", "compta"));
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0)
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
if (!$user->rights->accounting->fiscalyear->write)
|
||||
}
|
||||
if (!$user->rights->accounting->fiscalyear->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$id = GETPOST('id', 'int');
|
||||
|
||||
|
||||
// View
|
||||
|
||||
$title = $langs->trans("Fiscalyear")." - ".$langs->trans("Info");
|
||||
$helpurl = "";
|
||||
llxHeader("", $title, $helpurl);
|
||||
|
||||
$help_url = "EN:Module_Double_Entry_Accounting";
|
||||
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
if ($id) {
|
||||
$object = new Fiscalyear($db);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
* Copyright (C) 2017 Laurent Destailleur <eldy@destailleur.fr>
|
||||
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -37,8 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
$langs->loadLangs(array("compta", "bills", "admin", "accountancy", "other"));
|
||||
|
||||
// Security access
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
{
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
@ -48,8 +48,9 @@ $action = GETPOST('action', 'aZ09');
|
||||
$list = array(
|
||||
'ACCOUNTING_LENGTH_GACCOUNT',
|
||||
'ACCOUNTING_LENGTH_AACCOUNT',
|
||||
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
|
||||
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
|
||||
// 'ACCOUNTING_LIMIT_LIST_VENTILATION' // there is already a global parameter to define the nb of records in lists, we must use it in priority. Having one parameter for nb of record for each page is deprecated.
|
||||
// 'ACCOUNTING_LENGTH_DESCRIPTION', // adjust size displayed for lines description for dol_trunc
|
||||
// 'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
|
||||
);
|
||||
|
||||
$list_binding = array(
|
||||
@ -57,19 +58,40 @@ $list_binding = array(
|
||||
'ACCOUNTING_DEFAULT_PERIOD_ON_TRANSFER'
|
||||
);
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (in_array($action, array(
|
||||
'setBANK_DISABLE_DIRECT_INPUT',
|
||||
'setACCOUNTANCY_COMBO_FOR_AUX',
|
||||
'setACCOUNTING_MANAGE_ZERO',
|
||||
'setACCOUNTING_LIST_SORT_VENTILATION_TODO',
|
||||
'setACCOUNTING_LIST_SORT_VENTILATION_DONE'))) {
|
||||
$constname = preg_replace('/^set/', '', $action);
|
||||
$constvalue = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, $constname, $constvalue, 'yesno', 0, '', $conf->entity);
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
setEventMessages($langs->trans("Error"), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'update') {
|
||||
$error = 0;
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
foreach ($list as $constname)
|
||||
{
|
||||
if (!$error) {
|
||||
foreach ($list as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
var_dump($constname);
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
@ -78,12 +100,11 @@ if ($action == 'update') {
|
||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||
}
|
||||
|
||||
foreach ($list_binding as $constname)
|
||||
{
|
||||
foreach ($list_binding as $constname) {
|
||||
$constvalue = GETPOST($constname, 'alpha');
|
||||
|
||||
if ($constname == 'ACCOUNTING_DATE_START_BINDING') {
|
||||
$constvalue = dol_mktime(12, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int'));
|
||||
$constvalue = dol_mktime(0, 0, 0, GETPOST($constname.'month', 'int'), GETPOST($constname.'day', 'int'), GETPOST($constname.'year', 'int'));
|
||||
}
|
||||
|
||||
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
|
||||
@ -103,8 +124,9 @@ if ($action == 'update') {
|
||||
if ($action == 'setlistsorttodo') {
|
||||
$setlistsorttodo = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
@ -116,8 +138,10 @@ if ($action == 'setlistsorttodo') {
|
||||
if ($action == 'setlistsortdone') {
|
||||
$setlistsortdone = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -128,8 +152,10 @@ if ($action == 'setlistsortdone') {
|
||||
if ($action == 'setmanagezero') {
|
||||
$setmanagezero = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -140,8 +166,10 @@ if ($action == 'setmanagezero') {
|
||||
if ($action == 'setdisabledirectinput') {
|
||||
$setdisabledirectinput = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "BANK_DISABLE_DIRECT_INPUT", $setdisabledirectinput, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -152,8 +180,10 @@ if ($action == 'setdisabledirectinput') {
|
||||
if ($action == 'setenabledraftexport') {
|
||||
$setenabledraftexport = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL", $setenabledraftexport, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -164,8 +194,10 @@ if ($action == 'setenabledraftexport') {
|
||||
if ($action == 'setenablesubsidiarylist') {
|
||||
$setenablesubsidiarylist = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -176,8 +208,10 @@ if ($action == 'setenablesubsidiarylist') {
|
||||
if ($action == 'setdisablebindingonsales') {
|
||||
$setdisablebindingonsales = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -188,8 +222,10 @@ if ($action == 'setdisablebindingonsales') {
|
||||
if ($action == 'setdisablebindingonpurchases') {
|
||||
$setdisablebindingonpurchases = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -200,8 +236,10 @@ if ($action == 'setdisablebindingonpurchases') {
|
||||
if ($action == 'setdisablebindingonexpensereports') {
|
||||
$setdisablebindingonexpensereports = GETPOST('value', 'int');
|
||||
$res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity);
|
||||
if (!$res > 0)
|
||||
if (!($res > 0)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||
} else {
|
||||
@ -209,9 +247,11 @@ if ($action == 'setdisablebindingonexpensereports') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$title = $langs->trans('ConfigAccountingExpert');
|
||||
@ -251,11 +291,11 @@ print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("BANK_DISABLE_DIRECT_INPUT").'</td>';
|
||||
if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=0">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setBANK_DISABLE_DIRECT_INPUT&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disabledirectinput&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setBANK_DISABLE_DIRECT_INPUT&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -263,12 +303,13 @@ print '</tr>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").'</td>';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=0">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&enablesubsidiarylist&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTANCY_COMBO_FOR_AUX&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -277,22 +318,23 @@ print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_MANAGE_ZERO").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=0">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_MANAGE_ZERO&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&managezero&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_MANAGE_ZERO&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
// Param a user $user->rights->accounting->chartofaccount can access
|
||||
foreach ($list as $key)
|
||||
{
|
||||
foreach ($list as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue;
|
||||
if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Param
|
||||
$label = $langs->trans($key);
|
||||
@ -317,11 +359,11 @@ print "</tr>\n";
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=0">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_LIST_SORT_VENTILATION_TODO&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsorttodo&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_LIST_SORT_VENTILATION_TODO&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -330,19 +372,18 @@ print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=0">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_LIST_SORT_VENTILATION_DONE&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&listsortdone&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setACCOUNTING_LIST_SORT_VENTILATION_DONE&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
// Param a user $user->rights->accounting->chartofaccount can access
|
||||
foreach ($list_binding as $key)
|
||||
{
|
||||
foreach ($list_binding as $key) {
|
||||
print '<tr class="oddeven value">';
|
||||
|
||||
// Param
|
||||
@ -366,11 +407,11 @@ foreach ($list_binding as $key)
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonsales&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonsales&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonsales&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -379,11 +420,11 @@ print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonpurchases&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonpurchases&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonpurchases&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -392,11 +433,11 @@ print '</tr>';
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").'</td>';
|
||||
if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonexpensereports&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=0">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', 'warning');
|
||||
print '</a></td>';
|
||||
} else {
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&disablebindingonexpensereports&value=1">';
|
||||
print '<td class="right"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?token='.newToken().'&action=setdisablebindingonexpensereports&value=1">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a></td>';
|
||||
}
|
||||
|
||||
@ -22,7 +22,9 @@
|
||||
* \brief Setup page to configure journals
|
||||
*/
|
||||
|
||||
if (!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
|
||||
if (!defined('CSRFCHECK_WITH_TOKEN')) {
|
||||
define('CSRFCHECK_WITH_TOKEN', '1'); // Force use of CSRF protection with tokens even for GET
|
||||
}
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
@ -43,8 +45,7 @@ $rowid = GETPOST('rowid', 'alpha');
|
||||
$code = GETPOST('code', 'alpha');
|
||||
|
||||
// Security access
|
||||
if (empty($user->rights->accounting->chartofaccount))
|
||||
{
|
||||
if (empty($user->rights->accounting->chartofaccount)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
@ -60,12 +61,18 @@ $active = 1;
|
||||
$sortfield = GETPOST("sortfield", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $listlimit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (empty($sortfield)) $sortfield = 'code';
|
||||
if (empty($sortorder)) $sortorder = 'ASC';
|
||||
if (empty($sortfield)) {
|
||||
$sortfield = 'code';
|
||||
}
|
||||
if (empty($sortorder)) {
|
||||
$sortorder = 'ASC';
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
@ -145,14 +152,12 @@ $sourceList = array(
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha'))
|
||||
{
|
||||
if (GETPOST('button_removefilter', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter_x', 'alpha')) {
|
||||
$search_country_id = '';
|
||||
}
|
||||
|
||||
// Actions add or modify an entry into a dictionary
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) {
|
||||
$listfield = explode(',', str_replace(' ', '', $tabfield[$id]));
|
||||
$listfieldinsert = explode(',', $tabfieldinsert[$id]);
|
||||
$listfieldmodify = explode(',', $tabfieldinsert[$id]);
|
||||
@ -160,48 +165,53 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
|
||||
// Check that all fields are filled
|
||||
$ok = 1;
|
||||
foreach ($listfield as $f => $value)
|
||||
{
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) $fieldnamekey = 'Label';
|
||||
if ($fieldnamekey == 'code') $fieldnamekey = 'Code';
|
||||
if ($fieldnamekey == 'nature') $fieldnamekey = 'NatureOfJournal';
|
||||
foreach ($listfield as $f => $value) {
|
||||
if ($fieldnamekey == 'libelle' || ($fieldnamekey == 'label')) {
|
||||
$fieldnamekey = 'Label';
|
||||
}
|
||||
if ($fieldnamekey == 'code') {
|
||||
$fieldnamekey = 'Code';
|
||||
}
|
||||
if ($fieldnamekey == 'nature') {
|
||||
$fieldnamekey = 'NatureOfJournal';
|
||||
}
|
||||
}
|
||||
// Other checks
|
||||
if (GETPOSTISSET("code"))
|
||||
{
|
||||
if (GETPOST("code") == '0')
|
||||
{
|
||||
if (GETPOSTISSET("code")) {
|
||||
if (GETPOST("code") == '0') {
|
||||
$ok = 0;
|
||||
setEventMessages($langs->transnoentities('ErrorCodeCantContainZero'), null, 'errors');
|
||||
}
|
||||
/*if (!is_numeric($_POST['code'])) // disabled, code may not be in numeric base
|
||||
{
|
||||
$ok = 0;
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
{
|
||||
$ok = 0;
|
||||
$msg .= $langs->transnoentities('ErrorFieldFormat', $langs->transnoentities('Code')).'<br>';
|
||||
}*/
|
||||
}
|
||||
if (!GETPOST('label', 'alpha'))
|
||||
{
|
||||
if (!GETPOST('label', 'alpha')) {
|
||||
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label")), null, 'errors');
|
||||
$ok = 0;
|
||||
}
|
||||
|
||||
// Clean some parameters
|
||||
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
||||
if ($_POST["accountancy_code"] <= 0) {
|
||||
$_POST["accountancy_code"] = ''; // If empty, we force to null
|
||||
}
|
||||
if ($_POST["accountancy_code_sell"] <= 0) {
|
||||
$_POST["accountancy_code_sell"] = ''; // If empty, we force to null
|
||||
}
|
||||
if ($_POST["accountancy_code_buy"] <= 0) {
|
||||
$_POST["accountancy_code_buy"] = ''; // If empty, we force to null
|
||||
}
|
||||
|
||||
// Si verif ok et action add, on ajoute la ligne
|
||||
if ($ok && GETPOST('actionadd', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id])
|
||||
{
|
||||
if ($ok && GETPOST('actionadd', 'alpha')) {
|
||||
if ($tabrowid[$id]) {
|
||||
// Recupere id libre pour insertion
|
||||
$newid = 0;
|
||||
$sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id];
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
if ($result) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$newid = ($obj->newid + 1);
|
||||
} else {
|
||||
@ -212,32 +222,37 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// Add new entry
|
||||
$sql = "INSERT INTO ".$tabname[$id]." (";
|
||||
// List of fields
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$sql .= $tabrowid[$id].",";
|
||||
}
|
||||
$sql .= $tabfieldinsert[$id];
|
||||
$sql .= ",active,entity)";
|
||||
$sql .= " VALUES(";
|
||||
|
||||
// List of values
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert))
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) {
|
||||
$sql .= $newid.",";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldinsert as $f => $value)
|
||||
{
|
||||
foreach ($listfieldinsert as $f => $value) {
|
||||
if ($value == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql .= ",";
|
||||
if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; // For vat, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
}
|
||||
if ($_POST[$listfieldvalue[$i]] == '') {
|
||||
$sql .= "null"; // For vat, we want/accept code = ''
|
||||
} else {
|
||||
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= ",1,".$conf->entity.")";
|
||||
|
||||
dol_syslog("actionadd", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result) // Add is ok
|
||||
{
|
||||
if ($result) { // Add is ok
|
||||
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
|
||||
$_POST = array('id'=>$id); // Clean $_POST array, we keep only
|
||||
} else {
|
||||
@ -250,30 +265,36 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
}
|
||||
|
||||
// Si verif ok et action modify, on modifie la ligne
|
||||
if ($ok && GETPOST('actionmodify', 'alpha'))
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($ok && GETPOST('actionmodify', 'alpha')) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
// Modify entry
|
||||
$sql = "UPDATE ".$tabname[$id]." SET ";
|
||||
// Modifie valeur des champs
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify))
|
||||
{
|
||||
if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) {
|
||||
$sql .= $tabrowid[$id]."=";
|
||||
$sql .= "'".$db->escape($rowid)."', ";
|
||||
}
|
||||
$i = 0;
|
||||
foreach ($listfieldmodify as $field)
|
||||
{
|
||||
foreach ($listfieldmodify as $field) {
|
||||
if ($field == 'price' || preg_match('/^amount/i', $field) || $field == 'taux') {
|
||||
$_POST[$listfieldvalue[$i]] = price2num($_POST[$listfieldvalue[$i]], 'MU');
|
||||
} elseif ($field == 'entity') {
|
||||
$_POST[$listfieldvalue[$i]] = $conf->entity;
|
||||
}
|
||||
if ($i) $sql .= ",";
|
||||
if ($i) {
|
||||
$sql .= ",";
|
||||
}
|
||||
$sql .= $field."=";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) $sql .= "null"; // For vat, we want/accept code = ''
|
||||
else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
if ($_POST[$listfieldvalue[$i]] == '' && !($listfieldvalue[$i] == 'code' && $id == 10)) {
|
||||
$sql .= "null"; // For vat, we want/accept code = ''
|
||||
} else {
|
||||
$sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -282,8 +303,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
dol_syslog("actionmodify", LOG_DEBUG);
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
setEventMessages($db->error(), null, 'errors');
|
||||
}
|
||||
}
|
||||
@ -295,19 +315,20 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha'))
|
||||
// $_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition
|
||||
//}
|
||||
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes') { // delete
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
$sql = "DELETE from ".$tabname[$id]." WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
dol_syslog("delete", LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS')
|
||||
{
|
||||
if (!$result) {
|
||||
if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') {
|
||||
setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors');
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
@ -316,9 +337,12 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete
|
||||
}
|
||||
|
||||
// activate
|
||||
if ($action == $acts[0])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == $acts[0]) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -328,16 +352,18 @@ if ($action == $acts[0])
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// disable
|
||||
if ($action == $acts[1])
|
||||
{
|
||||
if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; }
|
||||
if ($action == $acts[1]) {
|
||||
if ($tabrowid[$id]) {
|
||||
$rowidcol = $tabrowid[$id];
|
||||
} else {
|
||||
$rowidcol = "rowid";
|
||||
}
|
||||
|
||||
if ($rowid) {
|
||||
$sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol." = ".((int) $rowid);
|
||||
@ -347,8 +373,7 @@ if ($action == $acts[1])
|
||||
$sql .= " AND entity = ".$conf->entity;
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (!$result)
|
||||
{
|
||||
if (!$result) {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
@ -365,8 +390,7 @@ llxHeader();
|
||||
|
||||
$titre = $langs->trans("DictionarySetup");
|
||||
$linkback = '';
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
$titre .= ' - '.$langs->trans($tablib[$id]);
|
||||
$titlepicto = 'title_accountancy';
|
||||
}
|
||||
@ -375,8 +399,7 @@ print load_fiche_titre($titre, $linkback, $titlepicto);
|
||||
|
||||
|
||||
// Confirmation de la suppression de la ligne
|
||||
if ($action == 'delete')
|
||||
{
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid.'&code='.$code.'&id='.$id, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_delete', '', 0, 1);
|
||||
}
|
||||
//var_dump($elementList);
|
||||
@ -384,14 +407,15 @@ if ($action == 'delete')
|
||||
/*
|
||||
* Show a dictionary
|
||||
*/
|
||||
if ($id)
|
||||
{
|
||||
if ($id) {
|
||||
// Complete requete recherche valeurs avec critere de tri
|
||||
$sql = $tabsql[$id];
|
||||
$sql .= " WHERE a.entity = ".$conf->entity;
|
||||
|
||||
// If sort order is "country", we use country_code instead
|
||||
if ($sortfield == 'country') $sortfield = 'country_code';
|
||||
if ($sortfield == 'country') {
|
||||
$sortfield = 'country_code';
|
||||
}
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($listlimit + 1, $offset);
|
||||
|
||||
@ -405,16 +429,12 @@ if ($id)
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
// Form to add a new line
|
||||
if ($tabname[$id])
|
||||
{
|
||||
$alabelisused = 0;
|
||||
|
||||
if ($tabname[$id]) {
|
||||
$fieldlist = explode(',', $tabfield[$id]);
|
||||
|
||||
// Line for title
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // Par defaut
|
||||
@ -432,12 +452,15 @@ 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;
|
||||
}
|
||||
|
||||
print '<td>';
|
||||
@ -453,12 +476,11 @@ if ($id)
|
||||
|
||||
$obj = new stdClass();
|
||||
// If data was already input, we define them in obj to populate input fields.
|
||||
if (GETPOST('actionadd', 'alpha'))
|
||||
{
|
||||
foreach ($fieldlist as $key=>$val)
|
||||
{
|
||||
if (GETPOST($val) != '')
|
||||
if (GETPOST('actionadd', 'alpha')) {
|
||||
foreach ($fieldlist as $key => $val) {
|
||||
if (GETPOST($val) != '') {
|
||||
$obj->$val = GETPOST($val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -467,13 +489,12 @@ if ($id)
|
||||
$reshook = $hookmanager->executeHooks('createDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
|
||||
if (empty($reshook)) {
|
||||
fieldListJournal($fieldlist, $obj, $tabname[$id], 'add');
|
||||
}
|
||||
|
||||
print '<td colspan="4" class="right">';
|
||||
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
|
||||
print '<input type="submit" class="button" name="actionadd" value="'.$langs->trans("Add").'">';
|
||||
print '</td>';
|
||||
print "</tr>";
|
||||
|
||||
@ -485,21 +506,27 @@ if ($id)
|
||||
// List of available record in database
|
||||
dol_syslog("htdocs/admin/dict", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
|
||||
$param = '&id='.$id;
|
||||
if ($search_country_id > 0) $param .= '&search_country_id='.$search_country_id;
|
||||
if ($search_country_id > 0) {
|
||||
$param .= '&search_country_id='.$search_country_id;
|
||||
}
|
||||
$paramwithsearch = $param;
|
||||
if ($sortorder) $paramwithsearch .= '&sortorder='.$sortorder;
|
||||
if ($sortfield) $paramwithsearch .= '&sortfield='.$sortfield;
|
||||
if (GETPOST('from', 'alpha')) $paramwithsearch .= '&from='.GETPOST('from', 'alpha');
|
||||
if ($sortorder) {
|
||||
$paramwithsearch .= '&sortorder='.$sortorder;
|
||||
}
|
||||
if ($sortfield) {
|
||||
$paramwithsearch .= '&sortfield='.$sortfield;
|
||||
}
|
||||
if (GETPOST('from', 'alpha')) {
|
||||
$paramwithsearch .= '&from='.GETPOST('from', 'alpha');
|
||||
}
|
||||
|
||||
// There is several pages
|
||||
if ($num > $listlimit)
|
||||
{
|
||||
if ($num > $listlimit) {
|
||||
print '<tr class="none"><td class="right" colspan="'.(3 + count($fieldlist)).'">';
|
||||
print_fleche_navigation($page, $_SERVER["PHP_SELF"], $paramwithsearch, ($num > $listlimit), '<li class="pagination"><span>'.$langs->trans("Page").' '.($page + 1).'</span></li>');
|
||||
print '</td></tr>';
|
||||
@ -522,8 +549,7 @@ if ($id)
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
$showfield = 1; // By defaut
|
||||
@ -531,11 +557,11 @@ if ($id)
|
||||
$sortable = 1;
|
||||
$valuetoshow = '';
|
||||
/*
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
$valuetoshow=$tmp['valuetoshow'];
|
||||
$align=$tmp['align'];
|
||||
$sortable=$tmp['sortable'];
|
||||
$tmparray=getLabelOfField($fieldlist[$field]);
|
||||
$showfield=$tmp['showfield'];
|
||||
$valuetoshow=$tmp['valuetoshow'];
|
||||
$align=$tmp['align'];
|
||||
$sortable=$tmp['sortable'];
|
||||
*/
|
||||
$valuetoshow = ucfirst($fieldlist[$field]); // By defaut
|
||||
$valuetoshow = $langs->trans($valuetoshow); // try to translate
|
||||
@ -560,23 +586,22 @@ if ($id)
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
if ($num) {
|
||||
// Lines with values
|
||||
while ($i < $num)
|
||||
{
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
//print_r($obj);
|
||||
print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">';
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code)))
|
||||
{
|
||||
if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) {
|
||||
$tmpaction = 'edit';
|
||||
$parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('editDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
// Show fields
|
||||
if (empty($reshook)) fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
if (empty($reshook)) {
|
||||
fieldListJournal($fieldlist, $obj, $tabname[$id], 'edit');
|
||||
}
|
||||
|
||||
print '<td class="center" colspan="4">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
@ -586,17 +611,15 @@ if ($id)
|
||||
print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>';
|
||||
print '</td>';
|
||||
} else {
|
||||
$tmpaction = 'view';
|
||||
$tmpaction = 'view';
|
||||
$parameters = array('var'=>$var, 'fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]);
|
||||
$reshook = $hookmanager->executeHooks('viewDictionaryFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks
|
||||
|
||||
$error = $hookmanager->error; $errors = $hookmanager->errors;
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (empty($reshook)) {
|
||||
$langs->load("accountancy");
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
$showfield = 1;
|
||||
$class = "left";
|
||||
$valuetoshow = $obj->{$fieldlist[$field]};
|
||||
@ -611,7 +634,9 @@ if ($id)
|
||||
|
||||
$class = 'tddict';
|
||||
// Show value for field
|
||||
if ($showfield) print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
if ($showfield) {
|
||||
print '<!-- '.$fieldlist[$field].' --><td class="'.$class.'">'.$valuetoshow.'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,27 +658,38 @@ if ($id)
|
||||
$canbemodified = $iserasable;
|
||||
|
||||
$url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '');
|
||||
if ($param) $url .= '&'.$param;
|
||||
if ($param) {
|
||||
$url .= '&'.$param;
|
||||
}
|
||||
$url .= '&';
|
||||
|
||||
// Active
|
||||
print '<td class="nowrap center">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
|
||||
else print $langs->trans("AlwaysActive");
|
||||
if ($canbedisabled) {
|
||||
print '<a href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
|
||||
} else {
|
||||
print $langs->trans("AlwaysActive");
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
// Modify link
|
||||
if ($canbemodified) print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
|
||||
else print '<td> </td>';
|
||||
if ($canbemodified) {
|
||||
print '<td class="center"><a class="reposition editfielda" href="'.$url.'action=edit&token='.newToken().'">'.img_edit().'</a></td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
// Delete link
|
||||
if ($iserasable)
|
||||
{
|
||||
if ($iserasable) {
|
||||
print '<td class="center">';
|
||||
if ($user->admin) print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
|
||||
if ($user->admin) {
|
||||
print '<a href="'.$url.'action=delete&token='.newToken().'">'.img_delete().'</a>';
|
||||
}
|
||||
//else print '<a href="#">'.img_delete().'</a>'; // Some dictionary can be edited by other profile than admin
|
||||
print '</td>';
|
||||
} else print '<td> </td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print '<td></td>';
|
||||
|
||||
@ -701,10 +737,8 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
$formadmin = new FormAdmin($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
if ($fieldlist[$field] == 'nature')
|
||||
{
|
||||
foreach ($fieldlist as $field => $value) {
|
||||
if ($fieldlist[$field] == 'nature') {
|
||||
print '<td>';
|
||||
print $form->selectarray('nature', $sourceList, (!empty($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:''));
|
||||
print '</td>';
|
||||
@ -713,9 +747,15 @@ function fieldListJournal($fieldlist, $obj = '', $tabname = '', $context = '')
|
||||
} else {
|
||||
print '<td>';
|
||||
$size = ''; $class = '';
|
||||
if ($fieldlist[$field] == 'code') $class = 'maxwidth100';
|
||||
if ($fieldlist[$field] == 'label') $class = 'quatrevingtpercent';
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') $size = 'size="2" ';
|
||||
if ($fieldlist[$field] == 'code') {
|
||||
$class = 'maxwidth100';
|
||||
}
|
||||
if ($fieldlist[$field] == 'label') {
|
||||
$class = 'quatrevingtpercent';
|
||||
}
|
||||
if ($fieldlist[$field] == 'sortorder' || $fieldlist[$field] == 'sens' || $fieldlist[$field] == 'category_type') {
|
||||
$size = 'size="2" ';
|
||||
}
|
||||
print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->{$fieldlist[$field]}) ? $obj->{$fieldlist[$field]}:'').'" name="'.$fieldlist[$field].'">';
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2013-2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com>
|
||||
@ -41,8 +41,9 @@ $langs->loadLangs(array("companies", "compta", "accountancy", "products"));
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->bind->write)
|
||||
if (!$user->rights->accounting->bind->write) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// search & action GETPOST
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
@ -60,7 +61,9 @@ $search_desc = GETPOST('search_desc', 'alpha');
|
||||
$search_vat = GETPOST('search_vat', 'alpha');
|
||||
$search_current_account = GETPOST('search_current_account', 'alpha');
|
||||
$search_current_account_valid = GETPOST('search_current_account_valid', 'alpha');
|
||||
if ($search_current_account_valid == '') $search_current_account_valid = 'withoutvalidaccount';
|
||||
if ($search_current_account_valid == '') {
|
||||
$search_current_account_valid = 'withoutvalidaccount';
|
||||
}
|
||||
$search_onsell = GETPOST('search_onsell', 'alpha');
|
||||
$search_onpurchase = GETPOST('search_onpurchase', 'alpha');
|
||||
|
||||
@ -68,38 +71,75 @@ $accounting_product_mode = GETPOST('accounting_product_mode', 'alpha');
|
||||
$btn_changeaccount = GETPOST('changeaccount', 'alpha');
|
||||
$btn_changetype = GETPOST('changetype', 'alpha');
|
||||
|
||||
if (empty($accounting_product_mode)) $accounting_product_mode = 'ACCOUNTANCY_SELL';
|
||||
if (empty($accounting_product_mode)) {
|
||||
$accounting_product_mode = 'ACCOUNTANCY_SELL';
|
||||
}
|
||||
|
||||
$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", 'alpha');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "p.ref";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "p.ref";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
if (empty($action)) $action = 'list';
|
||||
if (empty($action)) {
|
||||
$action = 'list';
|
||||
}
|
||||
|
||||
$arrayfields = array();
|
||||
|
||||
$accounting_product_modes = array(
|
||||
'ACCOUNTANCY_SELL',
|
||||
'ACCOUNTANCY_SELL_INTRA',
|
||||
'ACCOUNTANCY_SELL_EXPORT',
|
||||
'ACCOUNTANCY_BUY',
|
||||
'ACCOUNTANCY_BUY_INTRA',
|
||||
'ACCOUNTANCY_BUY_EXPORT'
|
||||
);
|
||||
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
$accountancy_field_name = "accountancy_code_buy";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
$accountancy_field_name = "accountancy_code_buy_intra";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
$accountancy_field_name = "accountancy_code_buy_export";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
$accountancy_field_name = "accountancy_code_sell";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
$accountancy_field_name = "accountancy_code_sell_intra";
|
||||
} else { // $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT'
|
||||
$accountancy_field_name = "accountancy_code_sell_export";
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
|
||||
$search_ref = '';
|
||||
$search_label = '';
|
||||
$search_desc = '';
|
||||
@ -115,15 +155,6 @@ if ($action == 'update') {
|
||||
if (!empty($btn_changetype)) {
|
||||
$error = 0;
|
||||
|
||||
$accounting_product_modes = array(
|
||||
'ACCOUNTANCY_SELL',
|
||||
'ACCOUNTANCY_SELL_INTRA',
|
||||
'ACCOUNTANCY_SELL_EXPORT',
|
||||
'ACCOUNTANCY_BUY',
|
||||
'ACCOUNTANCY_BUY_INTRA',
|
||||
'ACCOUNTANCY_BUY_EXPORT'
|
||||
);
|
||||
|
||||
if (in_array($accounting_product_mode, $accounting_product_modes)) {
|
||||
if (!dolibarr_set_const($db, 'ACCOUNTING_PRODUCT_MODE', $accounting_product_mode, 'chaine', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
@ -135,20 +166,18 @@ if ($action == 'update') {
|
||||
|
||||
if (!empty($btn_changeaccount)) {
|
||||
//$msg = '<div><span class="accountingprocessing">' . $langs->trans("Processing") . '...</span></div>';
|
||||
if (!empty($chk_prod)) {
|
||||
if (!empty($chk_prod) && in_array($accounting_product_mode, $accounting_product_modes)) {
|
||||
$accounting = new AccountingAccount($db);
|
||||
|
||||
//$msg .= '<div><span class="accountingprocessing">' . count($chk_prod) . ' ' . $langs->trans("SelectedLines") . '</span></div>';
|
||||
$arrayofdifferentselectedvalues = array();
|
||||
|
||||
$cpt = 0; $ok = 0; $ko = 0;
|
||||
foreach ($chk_prod as $productid)
|
||||
{
|
||||
foreach ($chk_prod as $productid) {
|
||||
$accounting_account_id = GETPOST('codeventil_'.$productid);
|
||||
|
||||
$result = 0;
|
||||
if ($accounting_account_id > 0)
|
||||
{
|
||||
if ($accounting_account_id > 0) {
|
||||
$arrayofdifferentselectedvalues[$accounting_account_id] = $accounting_account_id;
|
||||
$result = $accounting->fetch($accounting_account_id, null, 1);
|
||||
}
|
||||
@ -159,30 +188,18 @@ if ($action == 'update') {
|
||||
} else {
|
||||
$db->begin();
|
||||
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."product";
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY') {
|
||||
$sql .= " SET accountancy_code_buy = ".$accounting->account_number;
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_perentity (fk_product, entity, '".$db->escape($accountancy_field_name)."')";
|
||||
$sql .= " VALUES (".((int) $productid).", ".((int) $conf->entity).", '".$db->escape($accounting->account_number)."')";
|
||||
$sql .= " ON DUPLICATE KEY UPDATE ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'";
|
||||
} else {
|
||||
$sql = " UPDATE ".MAIN_DB_PREFIX."product";
|
||||
$sql .= " SET ".$accountancy_field_name." = '".$db->escape($accounting->account_number)."'";
|
||||
$sql .= " WHERE rowid = ".((int) $productid);
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
$sql .= " SET accountancy_code_buy_intra = ".$accounting->account_number;
|
||||
}
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
$sql .= " SET accountancy_code_buy_export = ".$accounting->account_number;
|
||||
}
|
||||
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;
|
||||
}
|
||||
$sql .= " WHERE rowid = ".((int) $productid);
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php sql=".$sql, LOG_DEBUG);
|
||||
if ($db->query($sql))
|
||||
{
|
||||
if ($db->query($sql)) {
|
||||
$ok++;
|
||||
$db->commit();
|
||||
} else {
|
||||
@ -195,8 +212,12 @@ if ($action == 'update') {
|
||||
}
|
||||
}
|
||||
|
||||
if ($ko) setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
|
||||
if ($ok) setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
|
||||
if ($ko) {
|
||||
setEventMessages($langs->trans("XLineFailedToBeBinded", $ko), null, 'errors');
|
||||
}
|
||||
if ($ok) {
|
||||
setEventMessages($langs->trans("XLineSuccessfullyBinded", $ok), null, 'mesgs');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,64 +264,35 @@ llxHeader('', $langs->trans("ProductsBinding"));
|
||||
|
||||
$pcgverid = $conf->global->CHARTOFACCOUNTS;
|
||||
$pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'pcg_version');
|
||||
if (empty($pcgvercode)) $pcgvercode = $pcgverid;
|
||||
if (empty($pcgvercode)) {
|
||||
$pcgvercode = $pcgverid;
|
||||
}
|
||||
|
||||
$sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy, p.tva_tx,";
|
||||
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
|
||||
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " pa.accountancy_code_sell, pa.accountancy_code_sell_intra, pa.accountancy_code_sell_export,";
|
||||
$sql .= " pa.accountancy_code_buy, pa.accountancy_code_buy_intra, pa.accountancy_code_buy_export,";
|
||||
} else {
|
||||
$sql .= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
|
||||
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,";
|
||||
}
|
||||
$sql .= " p.tms, p.fk_product_type as product_type,";
|
||||
$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)."'";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA')
|
||||
{
|
||||
$sql .= " p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
|
||||
{
|
||||
$sql .= " p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL')
|
||||
{
|
||||
$sql .= " p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA')
|
||||
{
|
||||
$sql .= " p.accountancy_code_sell_intra = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
|
||||
if (!empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_perentity as pa ON pa.fk_product = p.rowid AND pa.entity = " . ((int) $conf->entity);
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = pa." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
|
||||
} else {
|
||||
$sql .= " p.accountancy_code_sell_export = aa.account_number AND aa.fk_pcg_version = '".$db->escape($pcgvercode)."'";
|
||||
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.account_number = p." . $accountancy_field_name . " AND aa.fk_pcg_version = '" . $db->escape($pcgvercode) . "'";
|
||||
}
|
||||
$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);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
if (strlen(trim($search_current_account))) {
|
||||
$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);
|
||||
}
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA') {
|
||||
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((empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, $search_current_account);
|
||||
}
|
||||
if ($search_current_account_valid == 'withoutvalidaccount')
|
||||
{
|
||||
if ($search_current_account_valid == 'withoutvalidaccount') {
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
}
|
||||
if ($search_current_account_valid == 'withvalidaccount')
|
||||
{
|
||||
if ($search_current_account_valid == 'withvalidaccount') {
|
||||
$sql .= " AND aa.account_number IS NOT NULL";
|
||||
}
|
||||
// Add search filter like
|
||||
@ -316,18 +308,20 @@ if (strlen(trim($search_desc))) {
|
||||
if (strlen(trim($search_vat))) {
|
||||
$sql .= natural_search("p.tva_tx", price2num($search_vat), 1);
|
||||
}
|
||||
if ($search_onsell != '' && $search_onsell != '-1') $sql .= natural_search('p.tosell', $search_onsell, 1);
|
||||
if ($search_onpurchase != '' && $search_onpurchase != '-1') $sql .= natural_search('p.tobuy', $search_onpurchase, 1);
|
||||
if ($search_onsell != '' && $search_onsell != '-1') {
|
||||
$sql .= natural_search('p.tosell', $search_onsell, 1);
|
||||
}
|
||||
if ($search_onpurchase != '' && $search_onpurchase != '-1') {
|
||||
$sql .= natural_search('p.tobuy', $search_onpurchase, 1);
|
||||
}
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
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
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -337,24 +331,43 @@ $sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
dol_syslog("/accountancy/admin/productaccount.php:: sql=".$sql, LOG_DEBUG);
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
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);
|
||||
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 (!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);
|
||||
}
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
@ -372,26 +385,24 @@ if ($result)
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Options').'</td><td>'.$langs->trans('Description').'</td>';
|
||||
print "</tr>\n";
|
||||
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"'.($accounting_product_mode == 'ACCOUNTANCY_SELL' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSell').'</td>';
|
||||
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_SELL"'.($accounting_product_mode == 'ACCOUNTANCY_SELL' ? ' checked' : '').'> '.$langs->trans('OptionModeProductSell').'</td>';
|
||||
print '<td>'.$langs->trans('OptionModeProductSellDesc');
|
||||
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>';
|
||||
if ($mysoc->isInEEC()) {
|
||||
print '<tr class="oddeven"><td><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 '<tr class="oddeven"><td><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 '<tr class="oddeven"><td><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())
|
||||
{
|
||||
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyIntra').'</td>';
|
||||
if ($mysoc->isInEEC()) {
|
||||
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_INTRA"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyIntra').'</td>';
|
||||
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
|
||||
}
|
||||
print '<tr class="oddeven"><td class="titlefield"><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyExport').'</td>';
|
||||
print '<tr class="oddeven"><td><input type="radio" name="accounting_product_mode" value="ACCOUNTANCY_BUY_EXPORT"'.($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT' ? ' checked' : '').'> '.$langs->trans('OptionModeProductBuyExport').'</td>';
|
||||
print '<td>'.$langs->trans('OptionModeProductBuyDesc')."</td></tr>\n";
|
||||
print "</table>\n";
|
||||
|
||||
@ -419,13 +430,14 @@ if ($result)
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
|
||||
print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" size="5" name="search_vat" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) {
|
||||
print '<td class="liste_titre"><input type="text" class="flat" size="20" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
|
||||
}
|
||||
// On sell
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
print '<td class="liste_titre center">'.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).'</td>';
|
||||
}
|
||||
// On buy
|
||||
elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
} else {
|
||||
// On buy
|
||||
print '<td class="liste_titre center">'.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).'</td>';
|
||||
}
|
||||
// Current account
|
||||
@ -444,29 +456,17 @@ 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') {
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $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";
|
||||
} 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') {
|
||||
} else {
|
||||
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') {
|
||||
print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
$fieldtosortaccount = "p.accountancy_code_buy_export";
|
||||
}
|
||||
print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED) ? "p." : "pa.") . $accountancy_field_name, "", $param, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("AssignDedicatedAccountingAccount");
|
||||
$clickpitco = $form->showCheckAddButtons('checkforselect', 1);
|
||||
print_liste_field_titre($clickpitco, '', '', '', '', '', '', '', 'center ');
|
||||
@ -475,8 +475,7 @@ 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
|
||||
@ -558,8 +557,7 @@ if ($result)
|
||||
|
||||
print '<td class="left">'.$obj->label.'</td>';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC))
|
||||
{
|
||||
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
|
||||
@ -572,32 +570,45 @@ if ($result)
|
||||
print vatrate($obj->tva_tx);
|
||||
print '</td>';
|
||||
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT')
|
||||
// On sell / On purchase
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') {
|
||||
print '<td class="center">'.$product_static->getLibStatut(3, 0).'</td>';
|
||||
|
||||
if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT')
|
||||
} else {
|
||||
print '<td class="center">'.$product_static->getLibStatut(3, 1).'</td>';
|
||||
}
|
||||
|
||||
// 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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
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"));
|
||||
if ($obj->accountancy_code_sell_export && empty($obj->aaid)) {
|
||||
print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount"));
|
||||
}
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
@ -607,58 +618,82 @@ if ($result)
|
||||
// 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;
|
||||
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
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') {
|
||||
// Accounting account buy 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_prodbuy;
|
||||
if (empty($defaultvalue)) {
|
||||
$defaultvalue = $compta_prodbuy;
|
||||
}
|
||||
$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
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') {
|
||||
// Accounting account buy 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_prodbuy;
|
||||
if (empty($defaultvalue)) {
|
||||
$defaultvalue = $compta_prodbuy;
|
||||
}
|
||||
$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
|
||||
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>';
|
||||
} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') {
|
||||
// Accounting account sell
|
||||
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;
|
||||
if (empty($defaultvalue)) {
|
||||
$defaultvalue = $compta_prodsell;
|
||||
}
|
||||
$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
|
||||
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>';
|
||||
} 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;
|
||||
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
|
||||
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;
|
||||
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
|
||||
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>';
|
||||
}
|
||||
|
||||
@ -43,20 +43,30 @@ $search_label = GETPOST('search_label', 'alpha');
|
||||
$search_type = GETPOST('search_type', 'int');
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) accessforbidden();
|
||||
if (!$user->rights->accounting->chartofaccount) accessforbidden();
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (!$user->rights->accounting->chartofaccount) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) $sortfield = "label";
|
||||
if (!$sortorder) $sortorder = "ASC";
|
||||
if (!$sortfield) {
|
||||
$sortfield = "label";
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
|
||||
$arrayfields = array(
|
||||
'subaccount'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
|
||||
@ -65,27 +75,35 @@ $arrayfields = array(
|
||||
'reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1)
|
||||
);
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['reconcilable']);
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||
unset($arrayfields['reconcilable']);
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
|
||||
if (GETPOST('cancel', 'alpha')) {
|
||||
$action = 'list'; $massaction = '';
|
||||
}
|
||||
if (!GETPOST('confirmmassaction', 'alpha')) {
|
||||
$massaction = '';
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (!empty($cancel)) $action = '';
|
||||
if (empty($reshook)) {
|
||||
if (!empty($cancel)) {
|
||||
$action = '';
|
||||
}
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
|
||||
$search_subaccount = "";
|
||||
$search_label = "";
|
||||
$search_type = "";
|
||||
@ -100,9 +118,10 @@ if (empty($reshook))
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$help_url = '';
|
||||
$title = $langs->trans('ChartOfIndividualAccountsOfSubsidiaryLedger');
|
||||
|
||||
llxHeader('', $title);
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
// Customer
|
||||
$sql = "SELECT sa.rowid, sa.nom as label, sa.code_compta as subaccount, '1' as type, sa.entity";
|
||||
@ -132,19 +151,24 @@ if (strlen(trim($search_subaccount))) {
|
||||
$search_subaccount_tmp_clean = $search_subaccount_tmp;
|
||||
$search_subaccount_clean = $search_subaccount;
|
||||
$startchar = '%';
|
||||
if (strpos($search_subaccount_tmp, '^') === 0)
|
||||
{
|
||||
if (strpos($search_subaccount_tmp, '^') === 0) {
|
||||
$startchar = '';
|
||||
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
|
||||
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
|
||||
}
|
||||
$sql .= " AND (sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
|
||||
$sql .= " OR sa.code_compta LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
|
||||
} else $sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
|
||||
} else {
|
||||
$sql .= natural_search("sa.code_compta", $search_subaccount_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label);
|
||||
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("sa.nom", $search_label);
|
||||
}
|
||||
if (!empty($search_type) && $search_type >= 0) {
|
||||
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
}
|
||||
|
||||
// Supplier
|
||||
$sql .= " UNION ";
|
||||
@ -174,19 +198,24 @@ if (strlen(trim($search_subaccount))) {
|
||||
$search_subaccount_tmp_clean = $search_subaccount_tmp;
|
||||
$search_subaccount_clean = $search_subaccount;
|
||||
$startchar = '%';
|
||||
if (strpos($search_subaccount_tmp, '^') === 0)
|
||||
{
|
||||
if (strpos($search_subaccount_tmp, '^') === 0) {
|
||||
$startchar = '';
|
||||
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
|
||||
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
|
||||
}
|
||||
$sql .= " AND (sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
|
||||
$sql .= " OR sa.code_compta_fournisseur LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
|
||||
} else $sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
|
||||
} else {
|
||||
$sql .= natural_search("sa.code_compta_fournisseur", $search_subaccount_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(trim($search_label))) $sql .= natural_search("sa.nom", $search_label);
|
||||
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("sa.nom", $search_label);
|
||||
}
|
||||
if (!empty($search_type) && $search_type >= 0) {
|
||||
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
}
|
||||
|
||||
// User
|
||||
$sql .= " UNION ";
|
||||
@ -216,30 +245,33 @@ if (strlen(trim($search_subaccount))) {
|
||||
$search_subaccount_tmp_clean = $search_subaccount_tmp;
|
||||
$search_subaccount_clean = $search_subaccount;
|
||||
$startchar = '%';
|
||||
if (strpos($search_subaccount_tmp, '^') === 0)
|
||||
{
|
||||
if (strpos($search_subaccount_tmp, '^') === 0) {
|
||||
$startchar = '';
|
||||
$search_subaccount_tmp_clean = preg_replace('/^\^/', '', $search_subaccount_tmp);
|
||||
$search_subaccount_clean = preg_replace('/^\^/', '', $search_subaccount);
|
||||
}
|
||||
$sql .= " AND (u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_tmp_clean)."'";
|
||||
$sql .= " OR u.accountancy_code LIKE '".$db->escape($startchar.$search_subaccount_clean)."%')";
|
||||
} else $sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
|
||||
} else {
|
||||
$sql .= natural_search("u.accountancy_code", $search_subaccount_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen(trim($search_label))) $sql .= natural_search("u.lastname", $search_label);
|
||||
if (!empty($search_type) && $search_type >= 0) $sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
if (strlen(trim($search_label))) {
|
||||
$sql .= natural_search("u.lastname", $search_label);
|
||||
}
|
||||
if (!empty($search_type) && $search_type >= 0) {
|
||||
$sql .= " HAVING type LIKE '".$db->escape($search_type)."'";
|
||||
}
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
@ -250,19 +282,30 @@ $sql .= $db->plimit($limit + 1, $offset);
|
||||
dol_syslog('accountancy/admin/subaccount.php:: $sql='.$sql);
|
||||
$resql = $db->query($sql);
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if ($search_subaccount) $param .= '&search_subaccount='.urlencode($search_subaccount);
|
||||
if ($search_label) $param .= '&search_label='.urlencode($search_label);
|
||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
if ($search_subaccount) {
|
||||
$param .= '&search_subaccount='.urlencode($search_subaccount);
|
||||
}
|
||||
if ($search_label) {
|
||||
$param .= '&search_label='.urlencode($search_label);
|
||||
}
|
||||
if ($optioncss != '') {
|
||||
$param .= '&optioncss='.urlencode($optioncss);
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
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="list">';
|
||||
@ -272,7 +315,7 @@ if ($resql)
|
||||
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit, 0, 0, 1);
|
||||
|
||||
print '<div class="warning">'.$langs->trans("WarningCreateSubAccounts").'</div>';
|
||||
print '<div class="info">'.$langs->trans("WarningCreateSubAccounts").'</div>';
|
||||
|
||||
$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
|
||||
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||
@ -285,10 +328,20 @@ if ($resql)
|
||||
|
||||
// Line for search fields
|
||||
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('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print '<td class="liste_titre"> </td>'; }
|
||||
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('1'=>$langs->trans('Customer'), '2'=>$langs->trans('Supplier'), '3'=>$langs->trans('Employee')), $search_type, 1).'</td>';
|
||||
}
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($arrayfields['reconcilable']['checked'])) {
|
||||
print '<td class="liste_titre"> </td>';
|
||||
}
|
||||
}
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
print $searchpicto;
|
||||
@ -296,62 +349,69 @@ if ($resql)
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
if (!empty($arrayfields['subaccount']['checked'])) print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['label']['checked'])) print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['type']['checked'])) print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['reconcilable']['checked'])) print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center '); }
|
||||
if (!empty($arrayfields['subaccount']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['subaccount']['label'], $_SERVER["PHP_SELF"], "subaccount", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['label']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['label']['label'], $_SERVER["PHP_SELF"], "label", "", $param, '', $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['type']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
if (!empty($arrayfields['reconcilable']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['reconcilable']['label'], $_SERVER["PHP_SELF"], 'reconcilable', '', $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
$totalarray = array();
|
||||
$i = 0;
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Account number
|
||||
if (!empty($arrayfields['subaccount']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['subaccount']['checked'])) {
|
||||
print "<td>";
|
||||
print length_accounta($obj->subaccount);
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Subaccount label
|
||||
if (!empty($arrayfields['label']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['label']['checked'])) {
|
||||
print "<td>";
|
||||
print $obj->label;
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Type
|
||||
if (!empty($arrayfields['type']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['type']['checked'])) {
|
||||
print '<td class="center">';
|
||||
$s = '';
|
||||
// Customer
|
||||
if ($obj->type == 1)
|
||||
{
|
||||
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 == 2)
|
||||
{
|
||||
} elseif ($obj->type == 2) {
|
||||
// Supplier
|
||||
$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 == 3)
|
||||
{
|
||||
} elseif ($obj->type == 3) {
|
||||
// User
|
||||
$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>';
|
||||
}
|
||||
print $s;
|
||||
print '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
|
||||
@ -359,11 +419,11 @@ if ($resql)
|
||||
if (!empty($arrayfields['reconcilable']['checked'])) {
|
||||
print '<td class="center">';
|
||||
if (empty($obj->reconcilable)) {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
|
||||
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
@ -376,25 +436,22 @@ if ($resql)
|
||||
|
||||
// Action
|
||||
print '<td class="center">';
|
||||
$e = '';
|
||||
// Customer
|
||||
if ($obj->type == 1)
|
||||
{
|
||||
$e = '';
|
||||
// Customer
|
||||
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>';
|
||||
}
|
||||
} elseif ($obj->type == 2) {
|
||||
// Supplier
|
||||
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>';
|
||||
}
|
||||
} elseif ($obj->type == 3) {
|
||||
// User
|
||||
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>';
|
||||
}
|
||||
print $e;
|
||||
print $e;
|
||||
print '</td>'."\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print '</tr>'."\n";
|
||||
$i++;
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -37,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("accountancy"));
|
||||
$langs->loadLangs(array("accountancy", "compta"));
|
||||
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
$sortorder = GETPOST("sortorder", 'alpha');
|
||||
@ -49,7 +48,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
@ -75,10 +76,9 @@ $formaccounting = new FormAccounting($db);
|
||||
$formother = new FormOther($db);
|
||||
$form = new Form($db);
|
||||
|
||||
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
|
||||
{
|
||||
if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) {
|
||||
$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 .= " 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) {
|
||||
@ -88,10 +88,12 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
|
||||
} 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)
|
||||
{
|
||||
if ($month_end < 1) {
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
@ -99,13 +101,21 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
|
||||
$search_date_end = dol_get_last_day($year_end, $month_end);
|
||||
}
|
||||
}
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "t.numero_compte";
|
||||
if ($sortorder == "") {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if ($sortfield == "") {
|
||||
$sortfield = "t.numero_compte";
|
||||
}
|
||||
|
||||
|
||||
$param = '';
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
|
||||
$filter = array();
|
||||
if (!empty($search_date_start)) {
|
||||
@ -125,12 +135,23 @@ if (!empty($search_accountancy_code_end)) {
|
||||
$param .= '&search_accountancy_code_end='.$search_accountancy_code_end;
|
||||
}
|
||||
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Action
|
||||
*/
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
|
||||
{
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$show_subgroup = '';
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
@ -144,8 +165,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
||||
* View
|
||||
*/
|
||||
|
||||
if ($action == 'export_csv')
|
||||
{
|
||||
if ($action == 'export_csv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
|
||||
$filename = 'balance';
|
||||
@ -157,8 +177,7 @@ if ($action == 'export_csv')
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
foreach ($object->lines as $line) {
|
||||
print length_accountg($line->numero_compte).$sep;
|
||||
print $object->get_compte_desc($line->numero_compte).$sep;
|
||||
print price($line->debit).$sep;
|
||||
@ -176,12 +195,10 @@ $title_page = $langs->trans("AccountBalance");
|
||||
llxHeader('', $title_page);
|
||||
|
||||
|
||||
if ($action != 'export_csv')
|
||||
{
|
||||
if ($action != 'export_csv') {
|
||||
// List
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
|
||||
if ($nbtotalofrecords < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
@ -194,7 +211,9 @@ if ($action != 'export_csv')
|
||||
}
|
||||
|
||||
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" id="action" value="list">';
|
||||
@ -242,10 +261,12 @@ if ($action != 'export_csv')
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4);
|
||||
|
||||
print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
|
||||
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<td class="liste_titre" colspan="5">';
|
||||
print '<td class="liste_titre" colspan="'.$colspan.'">';
|
||||
print $langs->trans('From');
|
||||
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, '');
|
||||
print ' ';
|
||||
@ -261,7 +282,9 @@ if ($action != 'export_csv')
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
|
||||
}
|
||||
print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
|
||||
@ -278,25 +301,32 @@ if ($action != 'export_csv')
|
||||
|
||||
$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 .= " AND t.doc_date < '".$db->idate($search_date_start)."'";
|
||||
$sql .= " GROUP BY t.numero_compte";
|
||||
// TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts
|
||||
// without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal.
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
$sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
|
||||
$sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
|
||||
$sql .= " 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";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
$nrows = $resql->num_rows;
|
||||
$opening_balances = array();
|
||||
for ($i = 0; $i < $nrows; $i++) {
|
||||
$arr = $resql->fetch_array();
|
||||
$opening_balances["'".$arr['numero_compte']."'"] = $arr['opening_balance'];
|
||||
$resql = $db->query($sql);
|
||||
$nrows = $resql->num_rows;
|
||||
$opening_balances = array();
|
||||
for ($i = 0; $i < $nrows; $i++) {
|
||||
$arr = $resql->fetch_array();
|
||||
$opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($object->lines as $line)
|
||||
{
|
||||
foreach ($object->lines as $line) {
|
||||
// reset before the fetch (in case of the fetch fails)
|
||||
$accountingaccountstatic->id = 0;
|
||||
$accountingaccountstatic->account_number = '';
|
||||
|
||||
$accountingaccountstatic->fetch(null, $line->numero_compte, true);
|
||||
if (!empty($accountingaccountstatic->account_number)) {
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1);
|
||||
$accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard');
|
||||
} else {
|
||||
$accounting_account = length_accountg($line->numero_compte);
|
||||
}
|
||||
@ -311,29 +341,45 @@ if ($action != 'export_csv')
|
||||
$root_account_description = $tmparrayforrootaccount['label'];
|
||||
$root_account_number = $tmparrayforrootaccount['account_number'];
|
||||
|
||||
if (empty($accountingaccountstatic->account_number)) {
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/accountancy/admin/card.php?action=create&accountingaccount='.length_accountg($line->numero_compte).'">'.img_edit_add().'</a>';
|
||||
//var_dump($tmparrayforrootaccount);
|
||||
//var_dump($accounting_account);
|
||||
//var_dump($accountingaccountstatic);
|
||||
if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
|
||||
$link = '<a class="editfielda reposition" href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=update&token=' . newToken() . '&id=' . $accountingaccountstatic->id . '">' . img_edit() . '</a>';
|
||||
} elseif ($accounting_account == 'NotDefined') {
|
||||
$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
|
||||
} elseif (empty($tmparrayforrootaccount['label'])) {
|
||||
// $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent.
|
||||
// This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent.
|
||||
// BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so shoule not show a link to create another account.
|
||||
// BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin.
|
||||
//$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
|
||||
}
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
if (!empty($show_subgroup))
|
||||
{
|
||||
if (!empty($show_subgroup)) {
|
||||
// Show accounting account
|
||||
if (empty($displayed_account) || $root_account_number != $displayed_account) {
|
||||
// Show subtotal per accounting account
|
||||
if ($displayed_account != "") {
|
||||
print '<tr class="liste_total">';
|
||||
print '<td class="right" colspan="2">'.$langs->trans("SubTotal").':</td>';
|
||||
print '<td class="right">'.$langs->trans("SubTotal").':</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
|
||||
}
|
||||
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
|
||||
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
|
||||
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_credit - $sous_total_debit)).'</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).'</td>';
|
||||
} else {
|
||||
print '<td class="nowrap right">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
|
||||
}
|
||||
print "<td></td>\n";
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Show first line of a break
|
||||
print '<tr class="trforbreak">';
|
||||
print '<td colspan="6" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
|
||||
print '<td colspan="'.($colspan+1).'" style="font-weight:bold; border-bottom: 1pt solid black;">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$displayed_account = $root_account_number;
|
||||
@ -343,11 +389,32 @@ if ($action != 'export_csv')
|
||||
}
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$accounting_account.'</td>';
|
||||
print '<td class="nowraponall right">'.price($opening_balance).'</td>';
|
||||
print '<td class="nowraponall right">'.price($line->debit).'</td>';
|
||||
print '<td class="nowraponall right">'.price($line->credit).'</td>';
|
||||
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowraponall right">'.price($opening_balance).'</td>';
|
||||
}
|
||||
|
||||
$urlzoom = '';
|
||||
if ($line->numero_compte) {
|
||||
$urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte);
|
||||
if (GETPOSTISSET('date_startmonth')) {
|
||||
$urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int');
|
||||
}
|
||||
if (GETPOSTISSET('date_endmonth')) {
|
||||
$urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int');
|
||||
}
|
||||
}
|
||||
// Debit
|
||||
print '<td class="nowraponall right"><a href="'.$urlzoom.'">'.price($line->debit).'</a></td>';
|
||||
// Credit
|
||||
print '<td class="nowraponall right"><a href="'.$urlzoom.'">'.price($line->credit).'</a></td>';
|
||||
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowraponall right">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
|
||||
} else {
|
||||
print '<td class="nowraponall right">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
|
||||
}
|
||||
print '<td class="center">'.$link;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
@ -358,14 +425,33 @@ if ($action != 'export_csv')
|
||||
$sous_total_opening_balance += $opening_balance;
|
||||
}
|
||||
|
||||
if (!empty($show_subgroup))
|
||||
{
|
||||
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("SubTotal").':</td><td class="nowrap right">'.price($sous_total_debit).'</td><td class="nowrap right">'.price($sous_total_credit).'</td><td class="nowrap right">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')).'</td>';
|
||||
if (!empty($show_subgroup)) {
|
||||
print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">'.price($sous_total_opening_balance).'</td>';
|
||||
}
|
||||
print '<td class="nowrap right">'.price($sous_total_debit).'</td>';
|
||||
print '<td class="nowrap right">'.price($sous_total_credit).'</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
|
||||
} else {
|
||||
print '<td class="nowrap right">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
|
||||
}
|
||||
print "<td></td>\n";
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr class="liste_total"><td class="right" colspan="2">'.$langs->trans("AccountBalance").':</td><td class="nowrap right">'.price($total_debit).'</td><td class="nowrap right">'.price($total_credit).'</td><td class="nowrap right">'.price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')).'</td>';
|
||||
print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">'.price($total_opening_balance).'</td>';
|
||||
}
|
||||
print '<td class="nowrap right">'.price($total_debit).'</td>';
|
||||
print '<td class="nowrap right">'.price($total_credit).'</td>';
|
||||
if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
|
||||
print '<td class="nowrap right">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>';
|
||||
} else {
|
||||
print '<td class="nowrap right">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>';
|
||||
}
|
||||
print "<td></td>\n";
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -1,136 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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/balancebymonth.php
|
||||
* \ingroup Accountancy (Double entries)
|
||||
* \brief Balance by month
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("bills", "compta", "accountancy", "other"));
|
||||
|
||||
// Filter
|
||||
$year = GETPOST("year", 'int');
|
||||
if ($year == 0) {
|
||||
$year_current = strftime("%Y", time());
|
||||
$year_start = $year_current;
|
||||
} else {
|
||||
$year_current = $year;
|
||||
$year_start = $year;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('', $langs->trans("Bookkeeping"));
|
||||
|
||||
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
|
||||
$textnextyear = ' <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans("AccountBalanceByMonth").' '.$textprevyear.' '.$langs->trans("Year").' '.$year_start.' '.$textnextyear);
|
||||
|
||||
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " WHERE fd.fk_code_ventilation = 0";
|
||||
$sql .= " AND f.rowid = fd.fk_facture AND f.fk_statut = 1;";
|
||||
|
||||
dol_syslog('accountancy/bookkeeping/balancebymonth.php:: $sql='.$sql);
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$row = $db->fetch_row($result);
|
||||
$nbfac = $row[0];
|
||||
|
||||
$db->free($result);
|
||||
}
|
||||
|
||||
$y = $year_current;
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width=150>'.$langs->trans("Label").'</td>';
|
||||
for ($i = 1; $i <= 12; $i++)
|
||||
{
|
||||
print '<td class="right">'.$langs->trans("MonthShort".sprintf("%02s", $i)).'</td>';
|
||||
}
|
||||
print '<td class="center"><strong>'.$langs->trans("Total").'</strong></td>';
|
||||
print '</tr>';
|
||||
|
||||
$sql = "SELECT bk.numero_compte AS 'compte',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=1,bk.montant,0)),2) AS 'Janvier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=2,bk.montant,0)),2) AS 'Fevrier',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=3,bk.montant,0)),2) AS 'Mars',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=4,bk.montant,0)),2) AS 'Avril',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=5,bk.montant,0)),2) AS 'Mai',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=6,bk.montant,0)),2) AS 'Juin',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=7,bk.montant,0)),2) AS 'Juillet',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=8,bk.montant,0)),2) AS 'Aout',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=9,bk.montant,0)),2) AS 'Septembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=10,bk.montant,0)),2) AS 'Octobre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=11,bk.montant,0)),2) AS 'Novembre',";
|
||||
$sql .= " ROUND(SUM(IF(MONTH(bk.doc_date)=12,bk.montant,0)),2) AS 'Decembre',";
|
||||
$sql .= " ROUND(SUM(bk.montant),2) as 'Total'";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as bk";
|
||||
$sql .= " WHERE bk.doc_date >= '".$db->idate(dol_get_first_day($y, 1, false))."'";
|
||||
$sql .= " AND bk.doc_date <= '".$db->idate(dol_get_last_day($y, 12, false))."'";
|
||||
$sql .= " GROUP BY bk.numero_compte";
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($i < $num) {
|
||||
$row = $db->fetch_row($resql);
|
||||
|
||||
print '<tr class="oddeven"><td width="14%">'.length_accountg($row[0]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[1]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[2]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[3]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[4]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[5]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[6]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[7]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[8]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[9]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[10]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[11]).'</td>';
|
||||
print '<td class="right" width="6.5%">'.price($row[12]).'</td>';
|
||||
print '<td class="right" width="8%"><strong>'.price($row[13]).'</strong></td>';
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
} else {
|
||||
print $db->lasterror();
|
||||
}
|
||||
print "</table>\n";
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -44,13 +44,6 @@ $id = GETPOST('id', 'int'); // id of record
|
||||
$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp'
|
||||
$piece_num = GETPOST("piece_num", 'int'); // id of transaction (several lines share the same transaction id)
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
$mesg = '';
|
||||
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
$accountingjournal = new AccountingJournal($db);
|
||||
|
||||
@ -63,20 +56,37 @@ $accountingjournal->fetch(null, $journal_code);
|
||||
$journal_label = $accountingjournal->label;
|
||||
|
||||
$subledger_account = GETPOST('subledger_account', 'alphanohtml');
|
||||
if ($subledger_account == - 1) {
|
||||
if ($subledger_account == -1) {
|
||||
$subledger_account = null;
|
||||
}
|
||||
$subledger_label = GETPOST('subledger_label', 'alphanohtml');
|
||||
|
||||
$label_operation = GETPOST('label_operation', 'alphanohtml');
|
||||
$debit = price2num(GETPOST('debit', 'alpha'));
|
||||
$credit = price2num(GETPOST('credit', 'alpha'));
|
||||
|
||||
$save = GETPOST('save', 'alpha');
|
||||
if (!empty($save)) $action = 'add';
|
||||
if (!empty($save)) {
|
||||
$action = 'add';
|
||||
}
|
||||
$update = GETPOST('update', 'alpha');
|
||||
if (!empty($update)) $action = 'confirm_update';
|
||||
if (!empty($update)) {
|
||||
$action = 'confirm_update';
|
||||
}
|
||||
|
||||
$object = new BookKeeping($db);
|
||||
|
||||
// Security check
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -90,15 +100,13 @@ if ($action == "confirm_update") {
|
||||
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
|
||||
$action = 'update';
|
||||
}
|
||||
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
|
||||
{
|
||||
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
|
||||
$action = 'update';
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object = new BookKeeping($db);
|
||||
|
||||
$result = $object->fetch($id, null, $mode);
|
||||
@ -108,6 +116,7 @@ if ($action == "confirm_update") {
|
||||
} else {
|
||||
$object->numero_compte = $accountingaccount_number;
|
||||
$object->subledger_account = $subledger_account;
|
||||
$object->subledger_label = $subledger_label;
|
||||
$object->label_compte = $accountingaccount_label;
|
||||
$object->label_operation = $label_operation;
|
||||
$object->debit = $debit;
|
||||
@ -142,14 +151,12 @@ if ($action == "confirm_update") {
|
||||
} elseif ($action == "add") {
|
||||
$error = 0;
|
||||
|
||||
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0))
|
||||
{
|
||||
if ((floatval($debit) != 0.0) && (floatval($credit) != 0.0)) {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
|
||||
$action = '';
|
||||
}
|
||||
if (empty($accountingaccount_number) || $accountingaccount_number == '-1')
|
||||
{
|
||||
if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
|
||||
$error++;
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
|
||||
$action = '';
|
||||
@ -160,6 +167,7 @@ if ($action == "confirm_update") {
|
||||
|
||||
$object->numero_compte = $accountingaccount_number;
|
||||
$object->subledger_account = $subledger_account;
|
||||
$object->subledger_label = $subledger_label;
|
||||
$object->label_compte = $accountingaccount_label;
|
||||
$object->label_operation = $label_operation;
|
||||
$object->debit = $debit;
|
||||
@ -224,14 +232,13 @@ if ($action == "confirm_update") {
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
if (!GETPOST('next_num_mvt', 'alpha'))
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumPiece")), null, 'errors');
|
||||
if (!GETPOST('doc_ref', 'alpha')) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors');
|
||||
$action = 'create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$object->label_compte = '';
|
||||
$object->debit = 0;
|
||||
$object->credit = 0;
|
||||
@ -250,8 +257,7 @@ if ($action == "confirm_update") {
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
if ($mode != '_tmp')
|
||||
{
|
||||
if ($mode != '_tmp') {
|
||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||
}
|
||||
$action = 'update';
|
||||
@ -267,8 +273,7 @@ if ($action == 'setdate') {
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
if ($mode != '_tmp')
|
||||
{
|
||||
if ($mode != '_tmp') {
|
||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||
}
|
||||
$action = '';
|
||||
@ -281,8 +286,7 @@ if ($action == 'setjournal') {
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
if ($mode != '_tmp')
|
||||
{
|
||||
if ($mode != '_tmp') {
|
||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||
}
|
||||
$action = '';
|
||||
@ -295,8 +299,7 @@ if ($action == 'setdocref') {
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
if ($mode != '_tmp')
|
||||
{
|
||||
if ($mode != '_tmp') {
|
||||
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
|
||||
}
|
||||
$action = '';
|
||||
@ -330,20 +333,20 @@ if ($action == 'delete') {
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
if ($action == 'create') {
|
||||
print load_fiche_titre($langs->trans("CreateMvts"));
|
||||
|
||||
$object = new BookKeeping($db);
|
||||
$next_num_mvt = $object->getNextNumMvt('_tmp');
|
||||
|
||||
if (empty($next_num_mvt))
|
||||
{
|
||||
if (empty($next_num_mvt)) {
|
||||
dol_print_error('', 'Failed to get next piece number');
|
||||
}
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="confirm_create">'."\n";
|
||||
print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
|
||||
@ -371,7 +374,7 @@ if ($action == 'create')
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Piece").'</td>';
|
||||
print '<td class="fieldrequired">'.$langs->trans("Piece").'</td>';
|
||||
print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -400,8 +403,7 @@ if ($action == 'create')
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
|
||||
if (!empty($object->piece_num))
|
||||
{
|
||||
if (!empty($object->piece_num)) {
|
||||
$backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
|
||||
|
||||
print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
|
||||
@ -434,13 +436,16 @@ if ($action == 'create')
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Docdate');
|
||||
print '</td>';
|
||||
if ($action != 'editdate')
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
|
||||
if ($action != 'editdate') {
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'editdate') {
|
||||
print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="setdate">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
@ -458,13 +463,16 @@ if ($action == 'create')
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Codejournal');
|
||||
print '</td>';
|
||||
if ($action != 'editjournal')
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
|
||||
if ($action != 'editjournal') {
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editjournal') {
|
||||
print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="setjournal">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
@ -482,13 +490,16 @@ if ($action == 'create')
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Piece');
|
||||
print '</td>';
|
||||
if ($action != 'editdocref')
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
|
||||
if ($action != 'editdocref') {
|
||||
print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&piece_num='.$object->piece_num.'&mode='.$mode.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td>';
|
||||
if ($action == 'editdocref') {
|
||||
print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="setdocref">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
@ -511,8 +522,7 @@ if ($action == 'create')
|
||||
print '<table class="border tableforfield" width="100%">';
|
||||
|
||||
// Doc type
|
||||
if (!empty($object->doc_type))
|
||||
{
|
||||
if (!empty($object->doc_type)) {
|
||||
print '<tr>';
|
||||
print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
|
||||
print '<td>'.$object->doc_type.'</td>';
|
||||
@ -533,11 +543,11 @@ if ($action == 'create')
|
||||
print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
|
||||
print '<td>';
|
||||
if (empty($object->validated)) {
|
||||
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable">';
|
||||
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Disabled"), 'switch_off');
|
||||
print '</a>';
|
||||
} else {
|
||||
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable">';
|
||||
print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">';
|
||||
print img_picto($langs->trans("Activated"), 'switch_on');
|
||||
print '</a>';
|
||||
}
|
||||
@ -577,14 +587,16 @@ if ($action == 'create')
|
||||
|
||||
print '<br>';
|
||||
|
||||
$result = $object->fetchAllPerMvt($piece_num, $mode);
|
||||
$result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
print load_fiche_titre($langs->trans("ListeMvts"), '', '');
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'" method="post">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
}
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
|
||||
print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
|
||||
@ -594,7 +606,8 @@ if ($action == 'create')
|
||||
print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
|
||||
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
if (count($object->linesmvt) > 0) {
|
||||
$total_debit = 0;
|
||||
$total_credit = 0;
|
||||
@ -616,18 +629,22 @@ if ($action == 'create')
|
||||
$total_credit += $line->credit;
|
||||
|
||||
if ($action == 'update' && $line->id == $id) {
|
||||
print '<!-- td columns in edit mode -->';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, '');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
|
||||
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
|
||||
// Also, it is not possible to use a value that is not in the list.
|
||||
// Also, the label is not automatically filled when a value is selected.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1);
|
||||
} else {
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'">';
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
|
||||
}
|
||||
// Add also input for subledger label
|
||||
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
|
||||
print '</td>';
|
||||
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
|
||||
print '<td class="right"><input type="text" size="6" class="right" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
|
||||
@ -639,20 +656,26 @@ if ($action == 'create')
|
||||
} else {
|
||||
$accountingaccount->fetch(null, $line->numero_compte, true);
|
||||
print '<td>'.$accountingaccount->getNomUrl(0, 1, 1, '', 0).'</td>';
|
||||
print '<td>'.length_accounta($line->subledger_account).'</td>';
|
||||
print '<td>'.length_accounta($line->subledger_account);
|
||||
if ($line->subledger_label) {
|
||||
print ' - <span class="opacitymedium">'.$line->subledger_label.'</span>';
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>'.$line->label_operation.'</td>';
|
||||
print '<td class="nowrap right">'.price($line->debit).'</td>';
|
||||
print '<td class="nowrap right">'.price($line->credit).'</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
|
||||
print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=update&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
|
||||
print img_edit('', 0, 'class="marginrightonly"');
|
||||
print '</a> ';
|
||||
|
||||
$actiontodelete = 'delete';
|
||||
if ($mode == '_tmp' || $action != 'delmouv') $actiontodelete = 'confirm_delete';
|
||||
if ($mode == '_tmp' || $action != 'delmouv') {
|
||||
$actiontodelete = 'confirm_delete';
|
||||
}
|
||||
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.$line->piece_num.'&mode='.$mode.'">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action='.$actiontodelete.'&id='.$line->id.'&piece_num='.urlencode($line->piece_num).'&mode='.urlencode($mode).'&token='.urlencode(newToken()).'">';
|
||||
print img_delete();
|
||||
|
||||
print '</a>';
|
||||
@ -664,25 +687,27 @@ if ($action == 'create')
|
||||
$total_debit = price2num($total_debit, 'MT');
|
||||
$total_credit = price2num($total_credit, 'MT');
|
||||
|
||||
if ($total_debit != $total_credit)
|
||||
{
|
||||
if ($total_debit != $total_credit) {
|
||||
setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
|
||||
}
|
||||
|
||||
if ($action == "" || $action == 'add') {
|
||||
print '<tr class="oddeven">';
|
||||
print '<!-- td columns in add mode -->';
|
||||
print '<td>';
|
||||
print $formaccounting->select_account('', 'accountingaccount_number', 1, array(), 1, 1, '');
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
|
||||
// It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
|
||||
// Also, it is not possible to use a value that is not in the list.
|
||||
// Also, the label is not automatically filled when a value is selected.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $formaccounting->select_auxaccount('', 'subledger_account', 1);
|
||||
} else {
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="">';
|
||||
print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
|
||||
}
|
||||
print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
|
||||
print '</td>';
|
||||
print '<td><input type="text" class="minwidth200" name="label_operation" value="'.$label_operation.'"/></td>';
|
||||
print '<td class="right"><input type="text" size="6" class="right" name="debit" value=""/></td>';
|
||||
@ -693,12 +718,10 @@ if ($action == 'create')
|
||||
print '</table>';
|
||||
|
||||
|
||||
if ($mode == '_tmp' && $action == '')
|
||||
{
|
||||
if ($mode == '_tmp' && $action == '') {
|
||||
print '<br>';
|
||||
print '<div class="center">';
|
||||
if ($total_debit == $total_credit)
|
||||
{
|
||||
if ($total_debit == $total_credit) {
|
||||
print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.$object->piece_num.'&action=valid">'.$langs->trans("ValidTransaction").'</a>';
|
||||
} else {
|
||||
print '<input type="submit" class="button" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $debit, $credit)).'" value="'.dol_escape_htmltag($langs->trans("ValidTransaction")).'">';
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||
* Copyright (C) 2016-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
|
||||
* Copyright (C) 2018-2021 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
|
||||
@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("accountancy"));
|
||||
$langs->loadLangs(array("accountancy", "compta"));
|
||||
|
||||
$socid = GETPOST('socid', 'int');
|
||||
|
||||
@ -45,14 +45,14 @@ $search_mvt_num = GETPOST('search_mvt_num', 'int');
|
||||
$search_doc_type = GETPOST("search_doc_type", 'alpha');
|
||||
$search_doc_ref = GETPOST("search_doc_ref", 'alpha');
|
||||
$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_date_end = dol_mktime(23, 59, 59, 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_date_creation_start = dol_mktime(0, 0, 0, GETPOST('date_creation_startmonth', 'int'), GETPOST('date_creation_startday', 'int'), GETPOST('date_creation_startyear', 'int'));
|
||||
$search_date_creation_end = dol_mktime(0, 0, 0, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
|
||||
$search_date_creation_end = dol_mktime(23, 59, 59, GETPOST('date_creation_endmonth', 'int'), GETPOST('date_creation_endday', 'int'), GETPOST('date_creation_endyear', 'int'));
|
||||
$search_date_modification_start = dol_mktime(0, 0, 0, GETPOST('date_modification_startmonth', 'int'), GETPOST('date_modification_startday', 'int'), GETPOST('date_modification_startyear', 'int'));
|
||||
$search_date_modification_end = dol_mktime(0, 0, 0, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int'));
|
||||
$search_date_modification_end = dol_mktime(23, 59, 59, GETPOST('date_modification_endmonth', 'int'), GETPOST('date_modification_endday', 'int'), GETPOST('date_modification_endyear', 'int'));
|
||||
$search_date_export_start = dol_mktime(0, 0, 0, GETPOST('date_export_startmonth', 'int'), GETPOST('date_export_startday', 'int'), GETPOST('date_export_startyear', 'int'));
|
||||
$search_date_export_end = dol_mktime(0, 0, 0, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int'));
|
||||
$search_date_export_end = dol_mktime(23, 59, 59, GETPOST('date_export_endmonth', 'int'), GETPOST('date_export_endday', 'int'), GETPOST('date_export_endyear', 'int'));
|
||||
|
||||
//var_dump($search_date_start);exit;
|
||||
if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_delmvt")) {
|
||||
@ -85,21 +85,27 @@ $search_mvt_label = GETPOST('search_mvt_label', 'alpha');
|
||||
$search_direction = GETPOST('search_direction', 'alpha');
|
||||
$search_debit = GETPOST('search_debit', 'alpha');
|
||||
$search_credit = GETPOST('search_credit', 'alpha');
|
||||
$search_ledger_code = GETPOST('search_ledger_code', 'alpha');
|
||||
$search_ledger_code = GETPOST('search_ledger_code', 'array');
|
||||
$search_lettering_code = GETPOST('search_lettering_code', 'alpha');
|
||||
$search_not_reconciled = GETPOST('search_reconciled_option', 'alpha');
|
||||
$search_not_reconciled = GETPOST('search_not_reconciled', 'alpha');
|
||||
|
||||
// Load variable for pagination
|
||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page < 0) { $page = 0; }
|
||||
if (empty($page) || $page < 0) {
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if ($sortorder == "") $sortorder = "ASC";
|
||||
if ($sortfield == "") $sortfield = "t.piece_num,t.rowid";
|
||||
if ($sortorder == "") {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if ($sortfield == "") {
|
||||
$sortfield = "t.piece_num,t.rowid";
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$object = new BookKeeping($db);
|
||||
@ -108,10 +114,8 @@ $hookmanager->initHooks(array('bookkeepinglist'));
|
||||
$formaccounting = new FormAccounting($db);
|
||||
$form = new Form($db);
|
||||
|
||||
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export)
|
||||
{
|
||||
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values'))
|
||||
{
|
||||
if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GETPOSTISSET('begin') && !GETPOSTISSET('formfilteraction') && GETPOST('page', 'int') == '' && !GETPOST('noreset', 'int') && $user->rights->accounting->mouvements->export) {
|
||||
if (empty($search_date_start) && empty($search_date_end) && !GETPOSTISSET('restore_lastsearch_values') && !GETPOST('search_accountancy_code_start')) {
|
||||
$query = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
|
||||
$query .= " where date_start < '".$db->idate(dol_now())."' and date_end > '".$db->idate(dol_now())."' limit 1";
|
||||
$res = $db->query($query);
|
||||
@ -123,11 +127,12 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE
|
||||
} 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
|
||||
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)
|
||||
{
|
||||
if ($month_end < 1) {
|
||||
$month_end = 12;
|
||||
$year_end--;
|
||||
}
|
||||
@ -140,6 +145,7 @@ if (!in_array($action, array('export_file', 'delmouv', 'delmouvconfirm')) && !GE
|
||||
|
||||
$arrayfields = array(
|
||||
't.piece_num'=>array('label'=>$langs->trans("TransactionNumShort"), 'checked'=>1),
|
||||
't.code_journal'=>array('label'=>$langs->trans("Codejournal"), 'checked'=>1),
|
||||
't.doc_date'=>array('label'=>$langs->trans("Docdate"), 'checked'=>1),
|
||||
't.doc_ref'=>array('label'=>$langs->trans("Piece"), 'checked'=>1),
|
||||
't.numero_compte'=>array('label'=>$langs->trans("AccountAccountingShort"), 'checked'=>1),
|
||||
@ -148,38 +154,55 @@ $arrayfields = array(
|
||||
'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),
|
||||
'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),
|
||||
);
|
||||
|
||||
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) unset($arrayfields['t.lettering_code']);
|
||||
if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
|
||||
unset($arrayfields['t.lettering_code']);
|
||||
}
|
||||
|
||||
$listofformat = AccountancyExport::getType();
|
||||
$formatexportset = $conf->global->ACCOUNTING_EXPORT_MODELCSV;
|
||||
if (empty($listofformat[$formatexportset])) $formatexportset = 1;
|
||||
if (empty($listofformat[$formatexportset])) {
|
||||
$formatexportset = 1;
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
|
||||
if (empty($conf->accounting->enabled)) {
|
||||
accessforbidden();
|
||||
}
|
||||
if ($user->socid > 0) {
|
||||
accessforbidden();
|
||||
}
|
||||
if (empty($user->rights->accounting->mouvements->lire)) {
|
||||
accessforbidden();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
|
||||
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
|
||||
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 ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
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
|
||||
{
|
||||
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 = '';
|
||||
@ -192,7 +215,7 @@ if (empty($reshook))
|
||||
$search_accountancy_aux_code_end = '';
|
||||
$search_mvt_label = '';
|
||||
$search_direction = '';
|
||||
$search_ledger_code = '';
|
||||
$search_ledger_code = array();
|
||||
$search_date_start = '';
|
||||
$search_date_end = '';
|
||||
$search_date_creation_start = '';
|
||||
@ -267,7 +290,9 @@ if (empty($reshook))
|
||||
}
|
||||
if (!empty($search_ledger_code)) {
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code='.urlencode($search_ledger_code);
|
||||
foreach ($search_ledger_code as $code) {
|
||||
$param .= '&search_ledger_code[]='.urlencode($code);
|
||||
}
|
||||
}
|
||||
if (!empty($search_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
@ -346,8 +371,7 @@ if ($action == 'delbookkeepingyearconfirm' && $user->rights->accounting->mouveme
|
||||
$deljournal = 0;
|
||||
}
|
||||
|
||||
if (!empty($delmonth) || !empty($delyear) || !empty($deljournal))
|
||||
{
|
||||
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');
|
||||
@ -379,7 +403,9 @@ if ($action == 'delmouvconfirm' && $user->rights->accounting->mouvements->suppri
|
||||
}
|
||||
if ($action == 'setreexport') {
|
||||
$setreexport = GETPOST('value', 'int');
|
||||
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) $error++;
|
||||
if (!dolibarr_set_const($db, "ACCOUNTING_REEXPORT", $setreexport, 'yesno', 0, '', $conf->entity)) {
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
if ($conf->global->ACCOUNTING_REEXPORT == 1) {
|
||||
@ -447,13 +473,15 @@ if (count($filter) > 0) {
|
||||
$sqlwhere[] = natural_search($key, $value, 1, 1);
|
||||
} elseif ($key == 't.reconciled_option') {
|
||||
$sqlwhere[] = 't.lettering_code IS NULL';
|
||||
} elseif ($key == 't.code_journal' && !empty($value)) {
|
||||
$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
|
||||
} else {
|
||||
$sqlwhere[] = natural_search($key, $value, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql .= ' WHERE t.entity IN ('.getEntity('accountancy').')';
|
||||
if ($conf->global->ACCOUNTING_REEXPORT == 0) {
|
||||
if (empty($conf->global->ACCOUNTING_REEXPORT)) {
|
||||
$sql .= " AND t.date_export IS NULL";
|
||||
}
|
||||
if (count($sqlwhere) > 0) {
|
||||
@ -467,48 +495,43 @@ if (!empty($sortfield)) {
|
||||
|
||||
// Export into a file with format defined into setup (FEC, CSV, ...)
|
||||
// Must be after definition of $sql
|
||||
if ($action == 'export_file' && $user->rights->accounting->mouvements->export) {
|
||||
if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
|
||||
// TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them.
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', $conf->global->ACCOUNTING_REEXPORT);
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
} else {
|
||||
// Export files
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines, $formatexportset);
|
||||
|
||||
if (!empty($accountancyexport->errors))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 .= " , date_validated = '".$db->idate($now)."'";
|
||||
$sql .= " WHERE rowid = ".((int) $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)
|
||||
{
|
||||
if (!$result) {
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
// setEventMessages($langs->trans("AllExportedMovementsWereRecordedAsExported"), null, 'mesgs');
|
||||
} else {
|
||||
@ -533,26 +556,22 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("Journals");
|
||||
|
||||
// Count total nb of records
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
|
||||
{
|
||||
if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
|
||||
$page = 0;
|
||||
$offset = 0;
|
||||
}
|
||||
}
|
||||
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
|
||||
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||
{
|
||||
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
|
||||
$num = $nbtotalofrecords;
|
||||
} else {
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
if (!$resql) {
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
@ -566,7 +585,25 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
|
||||
|
||||
llxHeader('', $title_page);
|
||||
|
||||
if ($action == 'export_file') {
|
||||
$form_question = array();
|
||||
|
||||
$form_question['notifiedexportdate'] = array(
|
||||
'name' => 'notifiedexportdate',
|
||||
'type' => 'checkbox',
|
||||
'label' => $langs->trans('NotifiedExportDate'),
|
||||
'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_EXPORT_DATE) ? 'false' : 'true'),
|
||||
);
|
||||
$form_question['notifiedvalidationdate'] = array(
|
||||
'name' => 'notifiedvalidationdate',
|
||||
'type' => 'checkbox', // We don't use select here, the journal_array is already a select html component
|
||||
'label' => $langs->trans('NotifiedValidationDate'),
|
||||
'value' => (!empty($conf->global->ACCOUNTING_DEFAULT_NOT_NOTIFIED_VALIDATION_DATE) ? 'false' : 'true'),
|
||||
);
|
||||
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?'.$param, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', $langs->trans('ConfirmExportFile'), 'export_fileconfirm', $form_question, '', 1, 300);
|
||||
print $formconfirm;
|
||||
}
|
||||
if ($action == 'delmouv') {
|
||||
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?mvt_num='.GETPOST('mvt_num').$param, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvtPartial'), 'delmouvconfirm', '', 0, 1);
|
||||
print $formconfirm;
|
||||
@ -613,19 +650,28 @@ if ($action == 'delbookkeepingyear') {
|
||||
}
|
||||
|
||||
//$param=''; param started before
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.urlencode($limit);
|
||||
}
|
||||
|
||||
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="'.urlencode($optioncss).'">';
|
||||
if ($optioncss != '') {
|
||||
print '<input type="hidden" name="optioncss" value="'.urlencode($optioncss).'">';
|
||||
}
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="sortfield" value="'.urlencode($sortfield).'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.urlencode($sortorder).'">';
|
||||
|
||||
if (count($filter)) $buttonLabel = $langs->trans("ExportFilteredList");
|
||||
else $buttonLabel = $langs->trans("ExportList");
|
||||
if (count($filter)) {
|
||||
$buttonLabel = $langs->trans("ExportFilteredList");
|
||||
} else {
|
||||
$buttonLabel = $langs->trans("ExportList");
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
@ -638,14 +684,18 @@ if (empty($reshook)) {
|
||||
}
|
||||
$newcardbutton .= '<span class="valignmiddle marginrightonly">'.$langs->trans("IncludeDocsAlreadyExported").'</span>';
|
||||
|
||||
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
|
||||
if (!empty($user->rights->accounting->mouvements->export)) {
|
||||
$newcardbutton .= dolGetButtonTitle($buttonLabel, $langs->trans("ExportFilteredList").' ('.$listofformat[$formatexportset].')', 'fa fa-file-export paddingleft', $_SERVER["PHP_SELF"].'?action=export_file'.($param ? '&'.$param : ''), $user->rights->accounting->mouvements->export);
|
||||
}
|
||||
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewFlatList'), '', 'fa fa-list paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?'.$param, '', 1, array('morecss' => 'marginleftonly btnTitleSelected'));
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupByAccountAccounting'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php', '', 1, array('morecss' => 'marginleftonly'));
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('GroupBySubAccountAccounting'), '', 'fa fa-align-left vmirror paddingleft imgforviewmode', DOL_URL_ROOT.'/accountancy/bookkeeping/listbysubaccount.php?'.$param, '', 1, array('morecss' => 'marginleftonly'));
|
||||
|
||||
$url = './card.php?action=create';
|
||||
if (!empty($socid)) $url .= '&socid='.$socid;
|
||||
if (!empty($socid)) {
|
||||
$url .= '&socid='.$socid;
|
||||
}
|
||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewAccountingMvt'), '', 'fa fa-plus-circle paddingleft', $url, '', $user->rights->accounting->mouvements->creer);
|
||||
}
|
||||
|
||||
@ -653,26 +703,36 @@ print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield,
|
||||
|
||||
$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);
|
||||
if ($massactionbutton) {
|
||||
$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||
}
|
||||
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
|
||||
else $moreforfilter = $hookmanager->resPrint;
|
||||
if (empty($reshook)) {
|
||||
$moreforfilter .= $hookmanager->resPrint;
|
||||
} else {
|
||||
$moreforfilter = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<table class="tagtable liste centpercent">';
|
||||
|
||||
// Filters lines
|
||||
print '<tr class="liste_titre_filter">';
|
||||
|
||||
// Movement number
|
||||
if (!empty($arrayfields['t.piece_num']['checked']))
|
||||
{
|
||||
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>';
|
||||
}
|
||||
// Code journal
|
||||
if (!empty($arrayfields['t.code_journal']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
|
||||
print '</td>';
|
||||
}
|
||||
// Date document
|
||||
if (!empty($arrayfields['t.doc_date']['checked']))
|
||||
{
|
||||
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 : -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
|
||||
@ -683,33 +743,27 @@ if (!empty($arrayfields['t.doc_date']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Ref document
|
||||
if (!empty($arrayfields['t.doc_ref']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.doc_ref']['checked'])) {
|
||||
print '<td class="liste_titre"><input type="text" name="search_doc_ref" size="8" value="'.dol_escape_htmltag($search_doc_ref).'"></td>';
|
||||
}
|
||||
// Accountancy account
|
||||
if (!empty($arrayfields['t.numero_compte']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.numero_compte']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
|
||||
print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200', 1);
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
|
||||
print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200', 1);
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
}
|
||||
// Subledger account
|
||||
if (!empty($arrayfields['t.subledger_account']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.subledger_account']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $langs->trans('From').' ';
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
|
||||
} else {
|
||||
@ -719,8 +773,7 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
|
||||
print '<div class="nowrap">';
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) {
|
||||
print $langs->trans('to').' ';
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
} else {
|
||||
@ -730,39 +783,30 @@ if (!empty($arrayfields['t.subledger_account']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Label operation
|
||||
if (!empty($arrayfields['t.label_operation']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.label_operation']['checked'])) {
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" size="7" class="flat" name="search_mvt_label" value="'.$search_mvt_label.'"/>';
|
||||
print '</td>';
|
||||
}
|
||||
// Debit
|
||||
if (!empty($arrayfields['t.debit']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.debit']['checked'])) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input type="text" class="flat" name="search_debit" size="4" value="'.dol_escape_htmltag($search_debit).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Credit
|
||||
if (!empty($arrayfields['t.credit']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.credit']['checked'])) {
|
||||
print '<td class="liste_titre right">';
|
||||
print '<input type="text" class="flat" name="search_credit" size="4" value="'.dol_escape_htmltag($search_credit).'">';
|
||||
print '</td>';
|
||||
}
|
||||
// Lettering code
|
||||
if (!empty($arrayfields['t.lettering_code']['checked']))
|
||||
{
|
||||
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 '<br><span class="nowrap"><input type="checkbox" name="search_not_reconciled" value="notreconciled"'.($search_not_reconciled == 'notreconciled' ? ' checked' : '').'>'.$langs->trans("NotReconciled").'</span>';
|
||||
print '</td>';
|
||||
}
|
||||
// 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="'.$search_ledger_code.'"></td>';
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
$parameters = array('arrayfields'=>$arrayfields);
|
||||
@ -770,8 +814,7 @@ $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // N
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Date creation
|
||||
if (!empty($arrayfields['t.date_creation']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.date_creation']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
|
||||
@ -782,8 +825,7 @@ if (!empty($arrayfields['t.date_creation']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Date modification
|
||||
if (!empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.tms']['checked'])) {
|
||||
print '<td class="liste_titre center">';
|
||||
print '<div class="nowrap">';
|
||||
print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
|
||||
@ -794,8 +836,7 @@ if (!empty($arrayfields['t.tms']['checked']))
|
||||
print '</td>';
|
||||
}
|
||||
// Date export
|
||||
if (!empty($arrayfields['t.date_export']['checked']))
|
||||
{
|
||||
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"));
|
||||
@ -813,23 +854,49 @@ print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
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_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.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.numero_compte']['checked'])) print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
if (!empty($arrayfields['t.subledger_account']['checked'])) print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $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 ');
|
||||
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.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.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.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.numero_compte']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.numero_compte']['label'], $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
|
||||
}
|
||||
if (!empty($arrayfields['t.subledger_account']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.subledger_account']['label'], $_SERVER['PHP_SELF'], "t.subledger_account", "", $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;
|
||||
if (!empty($arrayfields['t.date_creation']['checked'])) print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.tms']['checked'])) print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.date_export']['checked'])) print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
if (!empty($arrayfields['t.date_creation']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.date_creation']['label'], $_SERVER['PHP_SELF'], "t.date_creation", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['t.tms']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.tms']['label'], $_SERVER['PHP_SELF'], "t.tms", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
if (!empty($arrayfields['t.date_export']['checked'])) {
|
||||
print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||
}
|
||||
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
|
||||
print "</tr>\n";
|
||||
|
||||
@ -840,10 +907,11 @@ $line = new BookKeepingLine();
|
||||
// --------------------------------------------------------------------
|
||||
$i = 0;
|
||||
$totalarray = array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) break; // Should not happen
|
||||
if (empty($obj)) {
|
||||
break; // Should not happen
|
||||
}
|
||||
|
||||
$line->id = $obj->rowid;
|
||||
$line->doc_date = $db->jdate($obj->doc_date);
|
||||
@ -878,28 +946,39 @@ while ($i < min($num, $limit))
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Piece number
|
||||
if (!empty($arrayfields['t.piece_num']['checked']))
|
||||
{
|
||||
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']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// 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']))
|
||||
{
|
||||
if (!empty($arrayfields['t.doc_date']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($line->doc_date, 'day').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Document ref
|
||||
if (!empty($arrayfields['t.doc_ref']['checked']))
|
||||
{
|
||||
if ($line->doc_type == 'customer_invoice')
|
||||
{
|
||||
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';
|
||||
@ -911,8 +990,7 @@ while ($i < min($num, $limit))
|
||||
$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')
|
||||
{
|
||||
} elseif ($line->doc_type == 'supplier_invoice') {
|
||||
$langs->loadLangs(array('bills'));
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
@ -924,8 +1002,7 @@ while ($i < min($num, $limit))
|
||||
$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')
|
||||
{
|
||||
} elseif ($line->doc_type == 'expense_report') {
|
||||
$langs->loadLangs(array('trips'));
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
@ -937,6 +1014,10 @@ while ($i < min($num, $limit))
|
||||
$filedir = $conf->expensereport->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 == 'bank') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
$objectstatic = new AccountLine($db);
|
||||
$objectstatic->fetch($line->fk_doc);
|
||||
} else {
|
||||
// Other type
|
||||
}
|
||||
@ -947,73 +1028,78 @@ while ($i < min($num, $limit))
|
||||
// Picto + Ref
|
||||
print '<td class="nobordernopadding nowrap">';
|
||||
|
||||
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report')
|
||||
{
|
||||
if ($line->doc_type == 'customer_invoice' || $line->doc_type == 'supplier_invoice' || $line->doc_type == 'expense_report') {
|
||||
print $objectstatic->getNomUrl(1, '', 0, 0, '', 0, -1, 1);
|
||||
print $documentlink;
|
||||
} elseif ($line->doc_type == 'bank') {
|
||||
print $objectstatic->getNomUrl(1);
|
||||
$bank_ref = strstr($line->doc_ref, '-');
|
||||
print " " . $bank_ref;
|
||||
} else {
|
||||
print $line->doc_ref;
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
print "</td>\n";
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Account number
|
||||
if (!empty($arrayfields['t.numero_compte']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.numero_compte']['checked'])) {
|
||||
print '<td>'.length_accountg($line->numero_compte).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Subledger account
|
||||
if (!empty($arrayfields['t.subledger_account']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.subledger_account']['checked'])) {
|
||||
print '<td>'.length_accounta($line->subledger_account).'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Label operation
|
||||
if (!empty($arrayfields['t.label_operation']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.label_operation']['checked'])) {
|
||||
print '<td>'.$line->label_operation.'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Amount debit
|
||||
if (!empty($arrayfields['t.debit']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.debit']['checked'])) {
|
||||
print '<td class="nowrap right">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
if (!$i) {
|
||||
$totalarray['pos'][$totalarray['nbfield']] = 'totaldebit';
|
||||
}
|
||||
$totalarray['val']['totaldebit'] += $line->debit;
|
||||
}
|
||||
|
||||
// Amount credit
|
||||
if (!empty($arrayfields['t.credit']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.credit']['checked'])) {
|
||||
print '<td class="nowrap right">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalcredit';
|
||||
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']))
|
||||
{
|
||||
if (!empty($arrayfields['t.lettering_code']['checked'])) {
|
||||
print '<td class="center">'.$line->lettering_code.'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
// 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']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Fields from hook
|
||||
@ -1022,24 +1108,27 @@ while ($i < min($num, $limit))
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
// Creation operation date
|
||||
if (!empty($arrayfields['t.date_creation']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.date_creation']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($line->date_creation, 'dayhour').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Modification operation date
|
||||
if (!empty($arrayfields['t.tms']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.tms']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($line->date_modification, 'dayhour').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Exported operation date
|
||||
if (!empty($arrayfields['t.date_export']['checked']))
|
||||
{
|
||||
if (!empty($arrayfields['t.date_export']['checked'])) {
|
||||
print '<td class="center">'.dol_print_date($line->date_export, 'dayhour').'</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
}
|
||||
|
||||
// Action column
|
||||
@ -1054,7 +1143,9 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
if (!$i) {
|
||||
$totalarray['nbfield']++;
|
||||
}
|
||||
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user